ImageList_LoadImage equivalent in .Net

S

Sven K

Here my way to get an imageList from resource stream.

// Create storage for bitmap strip
ImageList images = new ImageList();

// Define the size of images we supply
images.ImageSize = imageSize;

// Get the assembly that contains the bitmap resource
Assembly myAssembly = Assembly.GetAssembly(assemblyType);

// Get the resource stream containing the images
Stream imageStream =
myAssembly.GetManifestResourceStream(imageName);

if (imageStream == null)
return null;

// Load the bitmap strip from resource
Bitmap pics = new Bitmap(imageStream);

if (makeTransparent)
{
Color backColor = pics.GetPixel(transparentPixel.X,
transparentPixel.Y);

// Make backColor transparent for Bitmap
pics.MakeTransparent(backColor);
}

// Load them all !
images.Images.AddStrip(pics);

return images;
 

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