GoImage using EmbeddedResources


I want to load an embedded gif file into a GOImage and can't seem to get it to work. (See commented out code); When refering to the actual file name it works as shown below. However i want the gif file to be distributed as an embedded resource. Can you tell what I am doing wrong. The bitmap variable seems to be loaded properly.
public void Init(String imgname, String s)
{ GoImage img = new GoImage(); //Assembly assembly = Assembly.GetExecutingAssembly(); //String gifPath = "Schemer.Images." + imgname; //Bitmap bitmap = new Bitmap(assembly.GetManifestResourceStream(gifPath)); //ImageList imageList = new ImageList(); //imageList.Images.Add(bitmap); //img.Image = imageList.Images[0]; img.Name = Program.GifPath + imgname; img.Selectable = false; img.AutoRescales = false; img.AutoResizes = false; img.Size = new SizeF(16, 16); Add(img); GoText t = new GoText(); t.Selectable = false; t.BackgroundOpaqueWhenSelected = true; t.Text = s; Add(t); }

Is imageList.Images[0] valid when you look at it in the debugger?

  GoImage im = new GoImage();
  im.Image = imageList1.Images[1];
  im.Location = new PointF(200, 200);

works for me.

Hi Jake,

imageList.Images[0] look good in the debugger. That is it is not null and the size of the bitmap is set correctly (16x16). I did not actually see the bitmaps image. I also tried
img.ImageList = imageList;
img.Index = 0;
The only other this is i am not adding to a document but a GoGroup which works fine when I use the bitmaps file name. Also any problem using a GIF format but adding it as Bitmap format.
Bitmap bitmap = new Bitmap(assembly.GetManifestResourceStream(gifPath));

The imageList1 in my sample code above is created by dragging an ImageList item from the VS Toolbox to the Design window in a WinForms app. maybe if you try that simple approach…

Gif isn’t the problem. .NET Bitmap handles gif, etc.


I also tried that with the same results. I'm wondering about the GoGroup.Add being the problem. I may try this on the sample code.

Back off to the code sample I had above… Create the GoImage, set a location and add it to the Document. See if you can get that work ing first.

Hi Jake,
I was mising this line of code as shown in the demo project. All is well.
GoImage.DefaultResourceManager = new System.Resources.ResourceManager("Demo1.Images", this.GetType().Assembly);