Icon Extraction with .NET

J

Josh Collins

Hey folks,

I'm sure this is a tired topic, but I've exhausted all my resources looking
for a fix to this issue.

I'm trying to extract an icon from either an ICO, DLL, EXE, etc. I can
retrieve these icons and place them either a picture box or an ImageList
with no problem. In Windows 2000 and earlier everything is great. But in
XP when I have to deal with the alpha channel in the 32 bit icons it get
hairy.

When displaying the icons in a listview object they look correct, but I
really want to use them in either a picture box, or in a label via an
imageList (which results in the nasty black outline). I am already using a
manifest file.

Does anyone have any ideas with this issue?

Thanks In Advance
josh
 
J

Jeff Gentile

I'm having similar problems. When I load button with icon image at design
time it works fine. But if set image on button as icon from resource in
embedded .resource file using resource manager class it has a black line.

I've also tried to set the transparency style of the form and made the
button background color transparent before loading resource, which did not
help (see below).

Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True)

- at form initialization

Button1.BackColor = Color.Transparent

- at form load
 
J

Jeff Gentile

Did some more work with the .resources file and got my code to work.

1) create the image as an icon.
2) add icon to .resource file as bitmap (NOT icon) . i used the
reseditor.exe compiled from the vb .net software (its included as source
file in samples).
3) compile the .resource file into the assemply (i.e. into the .exe)
3) load the bitmap resource directly to the button using the resouce manager
class

see below
Dim myAssembly As System.Reflection.Assembly

myAssembly = Me.GetType.Assembly

Dim myManager As New
System.Resources.ResourceManager("mynamespace.myresource", myAssembly)

Button1.Image = CType(myManager.GetObject("myimage"), System.Drawing.Bitmap)
 
J

Josh Collins

I've looked over this example. I could not display his extracted icons in a
picture box or as the image on a label. I still get the black shadow of the
alpha channel.

josh
 

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

Top