Resources.Getbitmap problem in 2012 SDK 4.3

I have a project that has been running fine with 2010 NETMF 4.2 RTM (QFE2). In that project I use bitmaps. For instance:

Bitmap bmpLogo = Resources.GetBitmap(Resources.BitmapResources.Logo);

I upgraded to VS 2012 and NETMF SDK 4.3 and the latest Gadgeteer Package 2013 R2.

If I open the 2010 project up in 2012 Resources.Getbitmap is available and it all works fine.

However, if I start a new project in 2012 with the same references, Resources.Getbitmap and Resources.BitmapResources are no longer available. Any ideas on how to get a bitmap resource and assign it to a bitmap in 2012?

There is a Resources.GetBytes and a Resources.BinaryResources that points to the same bitmap resource file -> Resources.BinaryResources.Logo. However, I can find an easy way to convert the byte array that is returned to a Bitmap.

2 Likes

Something like:


new Bitmap( Resources.GetBytes(...), ... )
2 Likes

@ Architect - Thanks for info. I was waiting to see if anyone else replyed as well. It still did not work. I also ran across other problems with 4.3. The method to get to the IO pins on the extender card has changed. When I update to the new methods, they don’t work. I had to get things done so I reverted to 2010 and 4.2. I’ll try again another time. Thanks for the reply.

There is no 4.3 on GHI devices. You have to use 4.2 on VS2012 or VS2010. It doesn’t matter.

Show you code please, it should work.

Edit. Just to make it clear. You do need to install NETMF 4.3 to work in VS2012, but when you create a project you need to switch the target framework to 4.2.

@ Architect - Thanks for the reply. I was targeting 4.3 so that explains the IO problems. Moving back to 4.2 and the IO works great.

This is what I’m using for the bitmap:

bmpScreenSaver = new Bitmap(Resources.GetBytes(Resources.BinaryResources.Screen_Saver_Logo), Bitmap.BitmapImageType.Bmp);

It gives the following exception:
An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Graphics.dll

Using the same resource in a 2010 project and the following for loading it works fine:

bmpScreenSaver = Resources.GetBitmap(Resources.BitmapResources.Screen_Saver_Logo);

That is weird. I know for sure it should work. Something must be wrong with the binary data. Can you please remove the resource and re-add it.

Check the following codeshare:

https://www.ghielectronics.com/community/codeshare/entry/797

AlienInvadersGame.cs - LoadContent method loads the bitmap that way without any problems.

This issue was as well discovered by ourselves last week and believe it stems from the core. We have reported this issue to Microsoft: https://netmf.codeplex.com/workitem/2121

However, we were able to see success with BMP and JPEG, unlike your case.

@ James

I used GetBytes and GIF file inside Agent emulator application (4.3).


 _bkg = new Bitmap(Resources.GetBytes(Resources.BinaryResources.test), Bitmap.BitmapImageType.Gif);

In fact, the reason I have used GIF is because I couldn’t make BMP work. So it is completely the opposite from what you have described in the workitem.

A mystery.

I suggest anyone finding an issue to add to codeplex so Microsoft knows about this random issue. I am almost positive it related to the file size.

For some reason James’ link is hidden. It’s now also hidden in the reply page :slight_smile:

Funny

There seems to be a few more of GHI employees whos lins are hidden. the kickstarter link here https://www.ghielectronics.com/community/forum/topic?id=13263 is hidden but others are not. weird!

We will fix it shortly.

@ Architect - Thank you. This worked. It took a while to get back to it. I had reverted back to 4.2 because of other upgrading issues and schedules. I had a chance to go back to this and your suggestion worked. I had a bitmap that was fine when using GetBitmap but now gives an exception so I just changed the bitmap and it works fine. Thanks again for the help.