• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Transparent pictures

Started by COeXe, 22 April 2009, 14:30:54

Previous topic - Next topic

COeXe

Hi there,

I'm having trouble with pictures like the one from the attachment.
While windows itself is able to show it transparent (no black background as is shown when opened with paint for example), I can not manage to do so.
My plan is to add it to an ImageList in the end. Resizing works just fine, as does everything else.
If I set the mask-color (when adding to the ImageList) to clBlack, the black part disappears (which is nothing special so far) but the resulting image is too grainy.
How can I do this? I can't imaging it being too difficult if even the windows explorer does it right...


Thanks in advance!

Galfar

27 April 2009, 16:22:33 #1 Last Edit: 27 April 2009, 18:08:04 by Galfar
Which Delphi version do you use (or Lazarus)?
Do you have Imaging package installed in the IDE?
I looked at your image and it has proper alpha channel, why do you want to use mask with it? You resized it to what size and how? Resizing in ImageList most probably uses no filtering.

COeXe

Hi there,
I'm usign D2009.
This specific sample I posted will not be resized, but others of the same kind are.
I'm developing an application which shows Thumbnails of pictures (64x64) and other filetypes are displayed with special icons which are not resized. You can think of it kind of like a filebrowser.

I don't really want to use a mask with those pictures, but as I can't get the alphachannel to work, it is the best thing I can do so far.
My code looks something like this (just out of my mind right now, but it really isn't any more I'm doing):


SingleImage := TSingleImage.CreateFromStream(AStream);
try
  ConvertImageToBitmap(SingleImage, ABitmap);
finally
  FreeAndNil(SingleImage);
end;
AImageList.AddMasked(ABitmap, clNone);


For the actual displaying I use the ImageLists Draw method.
I even rebuild the whole thing around TMultiImage, because I hold the ImageList responsible. I then tried to display it with DisplayImage. I also tried to set the Transparent-Property to True on several occasions and converted the format (which of course made it worse, but you never know ...).

Thanks for your response. :)

Galfar

Still having the this problem?
I found some links mentioning PNGs with alpha and ImageList, maybe they coudl help you:
http://stackoverflow.com/questions/532777/pngs-in-delphi-2009-imagelists-and-images
https://forums.codegear.com/thread.jspa?threadID=3172&tstart=0

You'll probably have to display these images using AlphaBlend function (http://msdn.microsoft.com/en-us/library/aa452850.aspx) instead of DisplayImage or Draw (both these work practically in the same way).

COeXe

Thanks a lot for those links.
What I need could be achieved simply be setting DrawingStyle to dsTransparent (that I have already tried ...) AND ColorDepth to cd32Bit (who figured? -.-).

Now the Draw-Method does everything I need. :)

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk