Main Site Documentation

VS2012 and Bitmap resources


#1

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.


#2

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.


#3

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:


#4

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.


#5

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