Question about fetching a GIF image from assembly

J

JimC

I use reflection to get a GIF image that contains a transparency
mask (the white background should be transparent) that is
part of my C# project build. The problem is that the image's
transparency property disappears when I render it making
it look as if were a JPEG image.

The code I use is:

Assembly assem = this.GetType().Assembly;
Stream streamTransPic =
assem.GetManifestResourceStream("MyProject.images.transPic.gif");
transPic = System.Drawing.Image.FromStream(streamTransPic);

It is rendered with Graphics.DrawImage method in

gObj.DrawImage (transPic, rect);

where gObj is an instance of Graphics and rect has already been
defined.

If I read the image from a file rather than storing it in the compiled
assembly, its GIF transparency property is present when I render
it. But I don't want to use separate data files with production code.
 
J

JimC

JimC said:
I use reflection to get a GIF image that contains a transparency
mask (the white background should be transparent) that is
part of my C# project build. The problem is that the image's
transparency property disappears when I render it making
it look as if were a JPEG image.

The code I use is:

Assembly assem = this.GetType().Assembly;
Stream streamTransPic =
assem.GetManifestResourceStream("MyProject.images.transPic.gif");
transPic = System.Drawing.Image.FromStream(streamTransPic);

It is rendered with Graphics.DrawImage method in

gObj.DrawImage (transPic, rect);

where gObj is an instance of Graphics and rect has already been
defined.

If I read the image from a file rather than storing it in the compiled
assembly, its GIF transparency property is present when I render
it. But I don't want to use separate data files with production code.

Sorry. Let's cancel this question. I discovered that I had stored a
GIF image which didn't have the transparency mask present. When I
replaced it and recompiled, everything worked the way it should
for a GIF image.
 

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