Seems like CMFCToolBar Allowing only BITMAP Images ( which are of color depth 24 ) to place on Buttons. How to get rid of this limitation. i am neither able to place a PNG nor a bit map with color depth 32 (alpha channel included).
i tried attaching my CPngImage to CBitmap but didn't work.
CPngImage image;
image.Load(AfxGetInstanceHandle(), IDB_PNG1);
bitmap.Attach(image.Detach());
so, finally my doubt can we add a PNG/ Bitmap with alpha channel to CMFCToolBar Button as Image?
Does this work: Icons on menus of MFC Feature Pack classes ? You'd probably have to adapt it a bit to get it to work in your specific case. I'd suggest staying away from using PNG for toolbar icons etc; you can use AlphaConv (google a bit to find it - it moves around a bit it seems) to convert from png to 32 bit bmp.
Related
I have many PNG files with transparency and these PNG fiels seem to be indexed.
I would like to :
Put 2 identical PNG side to side with a space between both
Resize the result with a smooth resize filter (or Mitchell, Linear, Spline or other)
Keep transparency and originals colors
Do you have an example to do that ?
This question is related to other PNG resize questions but...
AFAIK, You can't resize an indexed image and keep the original palette. Resizing the image will necessitate the mixing of colors, especially in reducing the image.
The original author of the PNGImage component (the basis of the Delphi native component) had a forum where he, and others, posted code snippets on how to do things using the PNGImage component.
Before the forum was taken down I grabbed a copy of all of the code snippets and placed them on the CodeGear Code Central website.
Most if not all of these work with native PNG images and do maintain the Alpha channel.
Here is the complete list of examples included in the package:
Smooth rotates a PNG object
Resizes a TPNGObject using a smooth algorithm
Slice one PNG into several smaller ones
Saves an image as either a bitmap or a png.
Sample chunk descendant
Read all tEXt-Chunks and write values into a TStrings object
Display a message box with information extracted from the PNG File
Finds and cuts a block from a PNG image
This method converts the png into a jpeg object
This method converts the png into a bmp object
Overlay one PNG over another (This makes the image half transparent)
Flips a png image vertically and saves back
Draws a png image over the desktop
Here is the link: CodeCentral PNG Methods
I'm using the color information in the texture still when the alpha is set to 0. The PNG file is correctly saved with the color preserved. If I use the content pipeline and set it to non-premultiplied, everything works fine. Texture2D.FromStream is documented as non-premultiplied but it's wiping out the color. When debugging in PIX and looking at the texture, all pixels with 0 alpha are set to black.
Is there a way I can bypass the content pipeline and still keep my color for transparent pixels?
I'm not able to help too much just now as I don't have code in front of me but I done this a few days ago myself and it had all the correct transparency that was expected. Perhaps it's your image that has an issue? I used a PNG saved using Paint.Net.
As seen in this image http://imgur.com/Qrqqo the boat, tree trunk and ladder all have transparency which allow them to be on a second layer and the tileset itself is loaded using from stream (User generated content ftw).
So if no-one has answered this before I get to my computer with code then I'll take a look at what I have and post a sample if needed.
How to get a TPicture from a TImageList?
I need to do Image1.Picture:=...TPicture from an image list, to load an image into a TImage.
An image list stores all my PNG images that are transparent.
I tried to use a bitmap (GetBitmap), but what I need is transparency. Unfortunatelly, I have a white background using a bitmap.
Thanks!
The regular TImageList uses bitmaps. Although they can be partially transparent, it is actually just a fake. In Delphi you can draw bitmaps to be transparent by assigning them a single transparent color. That exact color will be drawn a 100% transparent, while the other colors are not. Usually the color is taken from the bottom left corner of the image.
TPicture itself doesn't do anything. It is merely a container for TGraphic descendants. You'll have to find a type of image that can be transparent.
A convenient format is PNG. PNG event supports an alpha channel, which means that every pixel can be assigned a different transparency value.
Fortunately there are TPngImageLists that combine the ease of TImageList with the power of PNG. You can read this article. It is in Dutch, but maybe Google Translate can help you. Or maybe you can find an english resource on this subject. I've used this imagelist and it's great, because you can have actual icons with an alpha channel and still use them with regular toolbars and speedbuttons.
I want to convert some animated PNG (APNG) images to animated GIF. I can successfully convert with a utility I found on the web called apng2gif. Expertly named if I may say. The problem is it does not convert the images with sufficient color depth so the output is a little bit to pixelated and not so smooth relative to the original.
Does anyone know of any other image converters that might convert APNG to GIF with more that 16 bit color depth?
The problem is not with the converter, but with GIF format itself:
http://en.wikipedia.org/wiki/Graphics_Interchange_Format
The format supports up to 8 bits per pixel thus allowing a single image to reference a palette of up to 256 distinct colors.
If you need the GIF to blend better with the background, click on Settings button in apng2gif and then choose the background color you want.
I am able to use PNGs that have drop shadows but the effect when displayed on the BlackBerry looks like it collapses the transparent channel down from its original smooth gradient to only several transparent values giving it a choppy look.
The same issue is encountered by drawing on the UI using BlackBerry fields or the graphics.drawBitmap method. Anyone want to share hints for getting great looking transparent effects on the BlackBerry?
Dither your images or pre-composite them. When loading an image on a BlackBerry, you get at most 4 bits of alpha data, which allows 4 bits each for RGB. So, if you want to dither your transparent images, go for RGB4444. If you don't dither them, that's what causes 8-bit alpha to just be mapped to the nearest 4-bit value.
If you include no alpha data (i.e., precomposite), you can get RGB565, which will have a better image quality overall, but you will have to deal with static positioning for your dropshadows.