Jump to content
Sign in to follow this  
n4gix

Drawing a bitmap with GDI+ ?

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Guest adameke777

>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 ?

Share this post


Link to post
Share on other sites

>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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

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...