Add Image to Base64 Encoded ImageStream in Resources (resx)

Posted by NickAldwin on Stack Overflow See other posts from Stack Overflow or by NickAldwin
Published on 2010-06-14T16:45:58Z Indexed on 2010/06/14 17:42 UTC
Read the original article Hit count: 580

Filed under:
|
|

I'm working on an older project, updating it. Part of the program has a toolstrip with many buttons on it, each with an image. I found that the images are stored in a Base64 encoded imagestream in the resx for the form and accessed as such:

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
...
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
...
this.toolStrip1.ImageList = this.imageList1;
...
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
...
this.toolStripButton1.ImageIndex = 0;  //There are 41 images, so this can be between 0 and 40

I need to add another button with a new image. How can I add an image to this stream?

I cannot use the designer, as it crashes as soon as I load the form (I believe because it uses a custom component with unsafe code).

I could always just add a new image resource separate from the stream, but that would make that one button different and thus it would create problems with consistency, causing upkeep problems later. So I'm wondering if there is any way for me to edit the imagestream. I can access the raw base64 string, but I have no idea where to go from here.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET