Hi All,
I have found three problems, The third problem, is debatable since the
behaviour also appears to exist in vb6, so I'll document the just the first
2 problems for now.
Both problems concern the ImageList control containing 32bpp png images with
alpha channel information and have been reproduced on both Windows XP SP1
with Visual Studio 2003 and Longhorn with the Visual Studio 'Whidbley' beta
Problem 1.
The ImageList control looses it's alpha channel information when further
images are added to the control
Steps to reproduce:
Step 1.
Create a vb project and add an imagelist control and a single picturebox to
the form.
Step 2.
Add the following two lines to the form's 'New' routine.
Application.EnableVisualStyles
Application.DoEvents 'Apparently this fixes some known problems with the
EnableVisualStyles call
Using EnableVisualStyles will enable the ImageList control to draw 32bpp
images with alpha channel information correctly.
Step 3.
In the property window for the ImageList add several 32bpp Images (Note they
must contain valid alpha channel information)
Step 4.
In the Paint Event for the picturebox control add the following code to draw
the first image from the image list.
Me.ImageList1.Draw(e.Graphics, 0, 0, 0)
Step 5.
Run the application and the first image from the ImageList control should be
drawn correctly with it's alpha intact.
All's well so far.
Step 6.
Close the application and go back to the ImageList's property window and add
a few more 32bpp png images.
Step 7.
Run the application again.
And hey presto, the ImageList control has now lost all its alpha channel
information, and the image is drawn with a solid black area where the alpha
channel information was.
As a workaround I have been able to create a routine that adds images to the
ImageList control and then serializes the ImageList collection at runtime
using the same format used in the .resx file. This then retains the alpha
information. However this is a pain to do, and I was hopping that this bug
had already been documented and would be fixed in Whidbley, but it still
appears unfixed in Whidbley.
Problem 2.
With the same project as above and with the ImageList's alpha channel still
intact, change the line
Me.ImageList1.Draw(e.Graphics, 0, 0, 0)
to
Me.ImageList1.Draw(e.Graphics, 0, 0, 20, 20 0)
and run the application
This should draw the image scaled up from 16x16 to 20x20 (provided the
images in the ImageList are 16x16 to start with). However the above routine
again draws the image with solid black areas where the alpha channel
information should be. As a workaround it is possible to use unmanaged code
to draw the scaled image with it's alpha channel intact using the original
ImageList_DrawEx Api call. Look at the decompiled code for the ImageList
control and you should easily see what the problem is.
Finally getting an Image Object out of the ImageList collection returns an
Image object without retaining it's alpha channel information.
I will send you a small program with some 32bpp images that will reproduce
the problem in the next couple of days.
Regards
Neal
"Ying-Shen Yu[MSFT]" said:
Hi Neal,
You may post the detail info on your problem in this thread, it would be
better if you could also provide a small sample to repro this problem. I'll
have a look at it and confirm with our product group.
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, "online" should be removed before
sending.