Toolbar Images with "Dirty Edges"

  • Thread starter Thread starter Mitchell Vincent
  • Start date Start date
M

Mitchell Vincent

I've been trying to get a standard toolbar to play nice with some nice icons
that I have. When I put them on a button or anything they look perfect, but
through an imagelist and on a toolbar they all have this blue aura around
them. I assume that is from the transparency, but I don't understand why
almost any other control displays them properly.. There really is no
replacement for the toolbar (without paying!), so I hope someone can tell me
how to get these icons to behave! I have them in ICO and PNG format, both
product the same "dirty edge" effect when placed on a toolbar button...

If anyone has any suggestions for a low cost commercial toolbar control, I'm
not opposed to buying something to make this look nice..

Thanks!
 
Hi Mitchell,

Have you tried to set the ImageList's ColorDepth to 32bit and imagesize to
a large one(e.g. 32,32) which may make the icon more "nice"?
Also since the icon is usually 32x32 or even 16x16 pixels, which have
little pixels to present the image, so if we add a large picture into the
imagelist as a icon which may cause the icon distortion.

If you still have any concern, please feel free to post there.


Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
The imagelist does not play nice with Alpha. Icons are generally OK, but it
depends on the icons format.

Load the images into the imagelist at runtime and you will get better
results, but the alpha will still be slightly bluish.
You'll also notice that the images in the imagelist only play nicely with
some controls, set a labels image to one of the imagelist alpha images and
you will really see ugly results.

As a workaround you can create icons from the png images at runtime and then
add them to the imagelist(labels still wont like them).
\\\
Dim ico As Icon
Dim bmp As New Bitmap("someimage.png")
ico = Icon.FromHandle(bmp.GetHicon)
ImageList1.Images.Add(ico)
bmp.Dispose()
ico.Dispose()
///
It would probably be better to add the pngs as Embedded Resource rather than
have them distrubuted seperately.
 
I guess the imagelist is just too dysfunctional where alpha is concerned for
my use. I have the images in both ICO (all dimensions) and PNG format and
none of them look even half way decent using an imagelist to attach them to
a toolbar..

I just wanted to make sure that it wasn't just me!

Thanks guys!
 
If you use the code I suggested to load the png images, as icons, into the
imagelist at runtime then they will look just fine in a toolbar.
You could easily update the code to use the images added as Embedded
Resource, and make a Method of it.

i.e.
\\\
Private Sub Form_Load(ByVal sender As Object, e As EventArgs) _
Handles MyBase.Load
ImageListAddResourcePng(ImageList1,"Image1.png")
ImageListAddResourcePng(ImageList1,"Image2.png")
End Sub

Private Sub ImageListAddResourcePng(ByVal imgList as ImageList , _
ByVal ResourceName As String)
Dim bmp As Bitmap = New Bitmap(Me.GetType, ResourceName)
Dim ico As Icon = Icon.FromHandle(bmp.GetHicon)
imgList.Images.Add(ico)
bmp.Dispose()
ico.Dispose()
End Sub
///
 
Hi Mitchell,

Have you tried Mick's suggestion?
If you still have any concern, please feel free to post here.

Best regards,

Perter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top