February 9, 200620 yr 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
February 9, 200620 yr 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
February 9, 200620 yr 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
February 10, 200620 yr 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.
February 11, 200620 yr 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
February 11, 200620 yr 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