Re: Icon transparency after Serialization
- From: "Michael Phillips, Jr." <mphillips53@xxxxxxxxxxxxxxx>
- Date: Sun, 16 Oct 2005 19:39:25 -0400
How are you serializing the HICON that is returned?
For 32bpp Alpha Icons, You can't convert them
to a BI_RGB bitmap because by design
a BI_RGB 32bpp bitmap is formatted as a DWORD where
each color is in this format:
0x00BBGGRR <------the alpha channel is ignored
You want each DWORD to look like this:
0xAARRGGBB
This would require creating a BI_BITFIELDS bitmap with
a BITMAPV5HEADER which supports alpha channels.
This method would allow you to serialize the icon as an
32bpp alpha channeled bitmap.
If you use the Windows API function GetIconInfo,
you can retrieve the Icon's bitmap masks(i.e., AND, XOR).
Using the information in that article that I posted, you can
serialize the icon in its own format. Some Interop coding may be necessary.
It is not difficult. I use the following site:
http://www.pinvoke.net/
The above site saves much time in setting up the structures
and Windows GDI API calls necessary for interop PINVOKE.
"Mike_IntermediateVB" <MikeIntermediateVB@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote
in message news:D1E639C9-4045-4660-8283-AA3600AE3F05@xxxxxxxxxxxxxxxx
> Thats an interesting article, (written in 1995) and I see the reference
> about
> the Icons Masks. I do need to learn a bit about accessing windows API's. I
> have used lots of examples (and use one that gets the Icons for me )
> perhaps
> you know of some reference webpages that might help me understand how to
> access these API's form .net (or VB6), then I can have a play around.
>
> I am currently using a 'File Icon Class' from VbAccelerator to get the
> icons
> LINK->
> http://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Getting_File_Icons_Using_The_Shell/article.asp
> This article also shows the issue with the shadows. When I retrieve the
> Icon using this class, it displays fine. When I save it the db (serialize
> and
> save as blob) and then redisplay (using same code) it has lost the alpha
> channel (as seen in article), All I can think of is that it's the
> serialization causing the problem.
>
> Thanks anyhow for your reply.
>
>
>
> "Michael Phillips, Jr." wrote:
>
>> Icons have there own image format.
>> They have a header, a directory and the image with
>> the masks.
>>
>> If you write the image to the blob in the proper format,
>> then you should not have any problems deserializing the
>> image when reading from the blob.
>>
>> The following article should help you out:
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_icons.asp
>>
>>
>> "Mike_IntermediateVB" <Mike_IntermediateVB@xxxxxxxxxxxxxxxxxxxxxxxxx>
>> wrote
>> in message news:EE5B38BC-EEC8-43CA-9D91-83A359438AEB@xxxxxxxxxxxxxxxx
>> >I am developing an application that stores files in a database, Along
>> >with
>> > the file I'd like to store the files Icon. I have created a File object
>> > that
>> > I can serialize, compress and write to the blob field of a database.
>> > This
>> > is
>> > working quite well, however for the last week I have been trying to
>> > figure
>> > out how I can preserve an Icons transparency though out this process. I
>> > would
>> > not mind converting the icon to a bitmap, so long as the resulting
>> > image
>> > look
>> > correct.
>> >
>> > I have tried various methods of loading the Icons in the first
>> > instance,
>> > but
>> > it seams to be the serialisation process upsets the image.
>> >
>> > My latest attempt was to try and create a mask from the (alpha channel)
>> > transparent colour of the Icon by creating an off screen bitmap with a
>> > background color that is not likely to be in the Icon. Then paste the
>> > icon
>> > over this background.
>> > Which I had hoped I could then save to the Db and when I redisplay it
>> > simply
>> > make the defined color transparent. However, after the paste I still
>> > get
>> > an
>> > odd black blob where the Icon has a shadow effect.
>> >
>>
>>
>>
.
- Follow-Ups:
- Re: Icon transparency after Serialization
- From: Mike_IntermediateVB
- Re: Icon transparency after Serialization
- References:
- Re: Icon transparency after Serialization
- From: Michael Phillips, Jr.
- Re: Icon transparency after Serialization
- From: Mike_IntermediateVB
- Re: Icon transparency after Serialization
- Prev by Date: Re: Icon transparency after Serialization
- Next by Date: Re: Icon transparency after Serialization
- Previous by thread: Re: Icon transparency after Serialization
- Next by thread: Re: Icon transparency after Serialization
- Index(es):
Relevant Pages
|