Question about fetching a GIF image from assembly

  • Thread starter Thread starter JimC
  • Start date Start date
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.
 
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.
 
Back
Top