Jump to content
Sign in to follow this  
n4gix

Using a Bitmap stored as a resource

Recommended Posts

Currently, I am using the following to fetch a bitmap from the HD to "refresh" my GDI+ drawing surface:Image image(L"AircraftEaglesoft Liberty XL2texturevision.bmp");Rect destinationRect(0, 0, 600 * dx, 590 * dy);graphics.DrawImage(ℑ,destinationRect,0, 0, 600, 590, UnitPixel);I have the "vision.bmp" in the .h and .rc files, and may reference it as BMP_VT_REFR.What do I need to do to access this bitmap from the resource and use it as it is used in the code above?


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest mgipson

Bill.If you have a look at the documentation for Gdiplus::Bitmap you will find that it has constructors that can create a Bitmap object from a resource. Have a look on MSDN here:http://msdn.microsoft.com/library/default...._bitmapName.aspThere are various methods to do the same thing. I use FindResource, LockResource, CreateStreamOnHGlobal and Gdiplus::Bitmap::FromStream myself as I already had the code to do that. One thing you might need to be aware of is in your resource file, you probably normally put something like this:EFIS_SCREEN BITMAP DISCARDABLE "resefisefisbackground.bmp"That causes the resource compiler to remove the bitmap header information. I have always found that to load a bitmap from a resource I have to define it like this in the resource file.EFIS_SCREEN RCDATA DISCARDABLE "resefisefisbackground.bmp"Mark

Share this post


Link to post
Share on other sites

EFIS_SCREEN RCDATA DISCARDABLE "resefisefisbackground.bmp"That may well be the "missing piece of the puzzle."So far, this compiles, but there's no "bitmap" to refresh the drawing: if(trigger == 1) { g_hInstance = GetModuleHandle("ESLibertyXL2.gau"); vision_clear_bitmap = new Bitmap(g_hInstance, (WCHAR*)MAKEINTRESOURCE(BMP_VT_REFR)); trigger = 0; } Rect destinationRect(0, 0, 600 * dx, 590 * dy); graphics.DrawImage(vision_clear_bitmap,destinationRect,0, 0, 600, 590, UnitPixel);EDIT: Nope... still nothing working... In the .rc file:BMP_VT_BG BITMAP DISCARDABLE "resvision.BMP"BMP_VT_LM BITMAP DISCARDABLE "resvision_lightmask.bmp"BMP_VT_COVER BITMAP DISCARDABLE "resvision_cover.BMP"BMP_VT_REFR RCDATA DISCARDABLE "resvision_refresh.bmp"In the .h file:#define BMP_VT_BG 0x2300#define BMP_VT_LM 0x2310#define BMP_VT_COVER 0x2320#define BMP_VT_REFR 0x2330


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites
Guest mgipson

I have never used the constructor for Bitmap that takes the resource information. Perhaps it doesn't work inside MSFS? If you like I can send you my bitmap loading code, it's a bit more complex but works fine for me as I am doing the same thing you are trying on a couple of gauges.

Share this post


Link to post
Share on other sites

>I have never used the constructor for Bitmap that takes the>resource information. Perhaps it doesn't work inside MSFS? If>you like I can send you my bitmap loading code, it's a bit>more complex but works fine for me as I am doing the same>thing you are trying on a couple of gauges.Thank you. My email is n4gix@comcast.net


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Thank you.


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...