February 2, 200620 yr 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 Bj
February 2, 200620 yr 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
February 2, 200620 yr >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 ?
February 3, 200620 yr 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
February 3, 200620 yr 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 Bj
February 3, 200620 yr 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