Icon to Bmp [100% Resolved]
How do you convert a icon resource to a valid type for the Image property of a label?
Thanks for any help.
VB Code:
Imports System.IO.Stream
'...
'...
Dim s As System.IO.Stream = Me.GetType.Assembly.GetManifestResourceStream("MyIcon.ico")
Dim bmp As Icon = New Icon(s) 'Crashes here
s.Close()
Me.Label.Image = bmp.ToBitmap
bmp.Dispose()
Re: Icon to Bmp [99% Resolved]
Yes, I remember reading that thread awhile ago. Thanks, but maybe the code
should be in codebank?
Btw, congradulations on the MCP! :thumb:
Re: Icon to Bmp [99% Resolved]
Quote:
Originally Posted by RobDog888
Yes, I remember reading that thread awhile ago. Thanks, but maybe the code
should be in codebank?
Btw, congradulations on the MCP! :thumb:
funny , I'm MCP since 2002 but I just stolen the link from your sig...:D (You just reminded me).
Yah , I thought pax added it to the codebank .
Re: Icon to Bmp [99% Resolved]
I'm not able to replicate the issue you're seeing in my tests and I may be missing something, but why bother loading the resource as an Icon only to convert it to a Bitmap (the conversion between formats could be why you're losing the transparency, though I couldn't replicate it.)
The Bitmap class can handle the ICO format, i.e.
VB Code:
Me.Label.Image = New Bitmap(Me.GetType(), "MyIcon.ico")
1 Attachment(s)
Re: Icon to Bmp [99% Resolved]
Dont I have to do something else to tell it to pull from the resource?
I'm still learning.
I attached the icon so you can replicate the issue.
VB Code:
Me.Label1.Image = New Bitmap(Me.GetType(), "2_138.ico")
Re: Icon to Bmp [99% Resolved]
Works fine for me, maybe it has something to do with your container, this is in a UserControl of some sort isn't it?
My tests are with a standard Label with/without a Transparent background on a form.
If you want to email me the project, I'd be happy to look at it for you.
Re: Icon to Bmp [99% Resolved]
I dont know what was going on but it works now. :confused: I just removed
the image that was assigned to the label during design time by way of the
properties window and ran the code you gave me.
Thanks for your help! :thumb:
Re: Icon to Bmp [100% Resolved]
Thanks for the tip and help in both threads. I gave you Reps! :thumb: