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.

Drawing a bitmap with GDI+ ?

Featured Replies

  • Commercial Member

Hi,I'm in the proces of making a TCAS gauge using GDI+ and I have a big (?) problem ! My gauge has a background image which works fine and I can draw on it but the drawings are not getting refreshed as I change the drawing (previous layer of drawing stays). So I have to use the Clear() method but... then you have to specify a color and you loose the background image.So on to the next step, after I do Clear() I create an Image object:Image* backgroundbmp as New Image(L"c:directoryfile.bmp");graphics->DrawImage(backgroundbmp, 1, 1 );Compiles fine, gauge starts nicely but... no background image is being drawn. Am I don't something wrong here ? Any help would be strongly appreciated !Bj

simcheck_sig_banner_devteam.jpg

 

Bj

  • Author
  • Moderator

This way works:Image image(L"AircraftXL2texturevision.bmp");Rect destinationRect(0, 0, 600 * dx, 590 * dy); graphics.DrawImage(ℑ,destinationRect,0, 0, 600, 590, UnitPixel);Using this instead of the Clear() method will "repaint" the background prior to your vector drawing. However, this is very costly in terms of frame rates, because it will engender constant HD activity...A better approach would be to load the bitmap only once, then save it to its own DC. Then, each loop, blitbit the saved DC back to your drawing DC...

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

>A better approach would be to load the bitmap only once, then>save it to its own DC. Then, each loop, blitbit the saved DC>back to your drawing DC...Bill,What would be an advantage of bitblting the bitmap over using DrawImage ?

  • Author
  • Moderator

>What would be an advantage of bitblting the bitmap over using>DrawImage ?The image is retained in memory and copied from there.Alternatively, you could simply compile the bitmap as a gauge resource, and use it directly.

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member

Hi Bill,You're always there to help ! Really appreciated.I've found a very framerate friendly workaround to my "problem". I dropped the "Clear" method and draw directly on the gauge bitmap (static) but I draw a "FillEllipse" as the CRT main window first, this clears all the drawing on the TCAS screen in one go without that need to redraw the bitmap. Works really well and is very framerate friendly.Thanks for the help !Bj

simcheck_sig_banner_devteam.jpg

 

Bj

  • Author
  • Moderator

Excellent!That is yet another way to accomplish your goal. Now, extend that idea a bit further and you might consider clearing only the area(s) that change from one cycle to the next...

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.