How to Place the image at specific location of the Picture Conrol in VC++ - c++

I m trying to overlay an image on a live video.The IDE used is Visual Studio Professional 2010. The code is developed in C++.When I try to overlay image on the live video, I m loading the image using a handle i.e.
HANDLE hBitmap;
hBitmap = LoadImage(NULL, L"C:\\Users\\User\\Documents\\Visual Studio 2010\\Projects\\BMP_Image.bmp",IMAGE_BITMAP, 0,0, LR_LOADFROMFILE );
I am using the mechanism of Alpha Blending to overlay the image on to the video. Problem I have encountered is, The image is overlayed five consecutive times on to the video .
I m passing the ID of a picture control, placed on the dialog box in the rc file, to load the live video and display it. I m not using any MFCs in the code. The video is rendered by using Direct 2D mechanism
The video resolution is 640*480 and bitmap image resolution is 128*128. If I take this bitmap , the video will produce five times of overlayed image on to the video..
I got the coordinates of dialog box using GetWindowRect() and ScreentoClient(). But I want the coordinates of the Picture control.
I have following doubts:
How to get the coordinates of the picture control???
How to place the image at specific location in a picture control???
Looking forward for ur positive response as earliest...
Regards,
Vivek

You can use the following function for retreiving the handle of your picture control:
::GetDlgItem( hWnd of your dialog, Id of your picture control)
By retreiving its handle, you can get to other info like its position, size and
::GetWindowRect(hWnd, &rc)
If you overlay the image through some API calls such as StretchBlt, you can place it anywhere you want.

Related

Draw on image from cvShowImage

using Visual Studio 2012; c++; openCV.
I show an image using cvShowImage, it gives me a window.
I want draw a form with mouse(a rectangle for exemple) on the image including in this window !!
Use the SetMouseCallback function to setup a callback for mouse events. Capture the vents and draw what you like to a cvImage and show the updated image in the same window.
http://docs.opencv.org/2.4.9/modules/highgui/doc/user_interface.html

Save wxWidgets window screenshot

I have a wxWidgets application. I wan't to get the window screen as image and save it into a file.
I know that the wxImage can be saved easily:
wxImage im;
im.Create(window_width, window_height)
/**assign some data**/
im.SaveFile("path/screen.png", wxBITMAP_TYPE_PNG);
However, how do I gather the window (and I want only the window!) pixel data?
You can use wxClientDC to access the window data. Then just Blit() them to a wxMemoryDC with a wxBitmap selected into it and finally convert the bitmap to wxImage.
Here is some detailed code showing how to do this - it is the second article down.
http://forums.wxwidgets.org/viewtopic.php?p=32313

how to change the background colour of CImage object in mfc?

I have an windows app which contains some dialogs. the dialogs have been built using mfc. I am drawing some images (.png) on every dialog using CImage::Draw() method. I want to mention that I am not using any picture contol on the dialog to render these images instead I am loading them at runtime using some handle.till this everything is ok. now when the image is loaded the background of those images are coming as white. the images in the resource file does not have the white background. my question is how to change the background of these images while drawing them on the dialog? I want the background of the image similar to the color of default dialog which i am using.
One more question the .png images are not rendering well(the images are scattered) in the dialogs of windows server 2008 R2 machine. what could be the possible remedy for this?
any help will be appreciated.
Your PNG images are obviously not 32-bit. You need an alpha channel and a transparent background. Open your images in e.g. Paint.NET. I bet your background is white there too! Regarding the image quality, are you stretching your images on draw?
Edit: For 8-bit imagers, I believe a call to SetTransparentColor is required. For 32-bit images, perhaps this function will do: TransparentBlt

win32 c++ owner draw button with transparent image

i've implemented a owner draw button into my win32 app (no MFC). The button is a normal 20x20 bitmap (round icon with transparency). The problem is that the button is positioned on a solid background and i can see the buttons gray background (since the bitmap is round). I've tried responding to WM_CTLCOLORBTN with NULL_BRUSH but no luck.. I've tried displaying the button using a bitmap and a ico file but wont budge.. Does anyone know how to solve this problem?
This is my problem, the settings icon should be transparent at the edges (not white/gray)
It sounds like you're trying to make a non-rectangular control.
You could call SetWindowRgn to tell Windows that your control is non-rectangular.
In addition to what #joel's answer, if you want to make some area transperant put a unique color in the area where you want to have transperancy using some image editors (RGB(0xFF,0x00,0xFF)) is mostly used Then use TransperantBlt
You say it's a solid background but your image shows some kind of orange-yellow gradient as a background. If it really was a standard windows button solid color you can load the bitmap with LoadImage using the LR_LOADMAP3DCOLORS or LR_LOADTRANSPARENT. Since you have a gradient you'll have to use a more complicated technique to mask out the bitmap.
http://www.winprog.org/tutorial/transparency.html

How to stretch a bitmap image to some specific Co Ordinates using WIN32 core and VC++?

I just want to create a program which crops an image and sends the cropped image to some remote location.
I have loaded the image using BitBlt(). I dont know, How to uniformly display all the images ? all of same size. stretching is allowed. I have created a static control and now I want to display all the images inside this static control only...
I am able to display images using STM_SETIMAGE, but the problem is that images are not displayed uniformly. So I thought to resize the images before sending them to SendMessage(). I have tried BitBlt() and StretchBlt() but I dont know why nothing works in my code.
The detailed Code
Any Help, will be appreciated...
Thanks in advance,
You might want to try using StretchBlt() instead of BitBlt(). It allows you to specify the source and destination rectangles which will crop and stretch the image.
http://msdn.microsoft.com/en-us/library/dd145120(v=vs.85).aspx
If you store your image internally as a DIB, using StretchDIBits() would be my recommendation.