Main Site Documentation

VS2012 and Bitmap resources


When I was using VS2010 I could simply Add Existing File of type BMP and it would load them into the resources and give me a GetBitmap call to retrieve them and then I could use them in the app like this.

gprs0 = Resources.GetBitmap(Resources.BitmapResources.gprs0);

Now when I load them in VS2012 they are imported as a BinaryResource.

There doesn’t appear to be any options to prevent this.


As a follow up.

When I check the bitmap in the Resource editor, the property “Type” for the bitmap shows that they are being loaded as System.Byte[ ] in VS2012 and System.Drawing.Bitmap in VS2010.


Ah, thanks Andre. Is funny, I did a search but found nothing.

I can edit the resource but as soon as you add a new one, it recreates the damn thing again!

Oh well, until MS fix this I guess I have to plod along. :slight_smile:


One suggestion instead of changing the resource file would be to add a bitmap to your project from the binary file like so:

static Bitmap stitch = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Disney_Stitch_Small), Bitmap.BitmapImageType.Jpeg);

It would save the trouble of the resource file resetting after each new addition.


Thanks Aron, that will work as I preload the bitmaps at startup anyway.