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
Related
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:
I built simple c++ Windows Form project with Visual Studio 2015.
My application has toast (Windows 10), and that shows icon like this.
Application icon has transparent background.
How can I remove blue background of icon?
Source Code: https://github.com/chaeyk/SoundDeviceToggle
Apologies, A bit late BUT ... in my effort to try and help๐
... Did you try both a transparent pixel PNG?png here
... and/or a transparent pixel GIF?gif here
( see 2 attached 1x1px images )
NOTE: I'm not sure what filetype you may need, but the same instance applies. If anyone wants me to supply a transparent image of a certain type eg. png, ico etc let me know.๐
Else, you can easily generate transparent PNG's ...
https://png-pixel.com/
and
https://onlinegiftools.com/create-1x1-pixel-gif
I am showing thumbnails (in a WTL/ATL/C++ application) using IShellItemImageFactory. Everything works fine all the way up to windows 8. There, some icons come with some black lines where transparency should be. It is slight but visible: http://i59.tinypic.com/ru2vmf.png
It happens to a minority of icons only.
After extracting the bitmap I show it (exactly as returned by GetImage(SIIGBF_RESIZETOFIT)) in a standard static control with STM_SETIMAGE. The glitch is still there if I add the bitmap in an imagelist
what can be the problem?
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
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.