Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Using a Bitmap stored as a resource

Featured Replies

  • Moderator

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

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

  • Author
  • Moderator

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

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.

  • Author
  • Moderator

>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 [email protected]

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Code sent by email.

  • Author
  • Moderator

Thank you.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.