C++ displaying an image with SDL2 with different formats than .bmp - c++

I am trying to display an image in SDL2 and the only guide I found was a guide about how to display a .bmp image. What I would like to do is displaying an image or setting a temporary image as a background. For example if I press LEFT_KEY the program should proceed to the next image. Any relevant guides or any examples you can share? It is not needed to set the image as a background (stretched), my goal is to display an image and being able to scroll through other images by pressing a key.

Use SDL_Image:
https://www.libsdl.org/projects/SDL_image/
Example:
Loading PNGs with SDL_image

Related

Can't use a transparent BMP with MFC Button control

I am really confused here ...
I am trying to add a MFC Button control onto my dialog in the IDE.
I want it to just show a BMP file. I have another already on the dialog that shows with a transparent background.
This is the image for the good button:
This is the other button image I downloaded. But it is PNG:
I have tried to convert it so that it is 32 bit BMP so that it is transparent:
But it is failing. It shows with a black background:
You can see on that screenshot that the lower image shows OK. But not the new one. How do I fix this image file?
Update:
I used a different image in the end for the question mark. But for others I ended up using PNG and manually using the load method as outlined below:

Opencv highgui display window

I installed opencv and ran few examples.. I can run simple image display program.. (http://docs.opencv.org/doc/tutorials/introduction/display_image/display_image.html ) The image window does not show the coordinates and rgb pixels values as in the this video. http://www.youtube.com/watch?feature=player_embedded&v=1OJEqpuaGc4. Do anybody know why and how to get the coordinates and rgb values at the bottom of the window as in the exmaple video...
Thanks
I figured out at last.. opencv library has to be compiled with qt rather than gtk
You can do it manually by using a mouse callback:
http://bsd-noobz.com/opencv-guide/45-3-using-mouse

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

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.

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

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.