Announcement
Collapse
No announcement yet.
colored rectangular areas in a bitmap - how?
Collapse
X
-
see source code forum for implementation of "Dirty Rectangles": http://www.powerbasic.com/support/pb...291#post309291
-
Originally posted by Chris Boss View Post"Dirty Rectangles"
**** added - there is a very useful tutorial here: http://www.codeproject.com/KB/GDI/updatergn.aspxLast edited by Chris Holbrook; 11 Feb 2009, 11:50 AM.
Leave a comment:
-
The solution is a technique called "Dirty Rectangles"!
When only small portions of the screen are being updated quickly, you can define a region (multiple rectangles combined) which contains only the area which needs to be repainted.
Create a region and then add every area you plan to update (you draw on) to the region to create a complex region.
Then call InvalidateRgn to make windows repaint only that region.
Using dirty rectangles can increase the update speed significantly depending upon how much area is being updated.Last edited by Chris Boss; 11 Feb 2009, 09:22 AM.
Leave a comment:
-
Originally posted by Paul Dixon View Postuse GRAPHIC BOX?
Leave a comment:
-
So far...
This code draws a box with the specified line and fill colors on a DC - a memory DC in the application, then triggers WM_PAINT in the target control, and WM_PAINT does the rest. Can it be done better/faster?
Code:'--------------------------------------------------------------------- sub MyDrawBox ( hDC as dword, lX as long, lY as long, lW as long, lH as long, lBoxColor as long, lBGColor as long) local hOldPen, holdBrush, hbrush as dword local r as rect holdbrush = selectobject(hdc, CreateSolidBrush(lBGColor)) setrect byval varptr(r), lX, lY, lX + lW, lY + lH hOldPen = SelectObject(hDC, CreatePen(%PS_SOLID, 1, lBoxColor)) rectangle hDC, lX, lY, lX + lW, lY + lH DeleteObject SelectObject(hDC, hOldPen) DeleteObject selectobject(hdc, holdbrush) invalidaterect ghStatic, byval varptr(r), 1 end sub '------------------------------------------------------------------------- (wndproc) .... case %wm_paint hDC = BeginPaint(ghStatic, PS) bitblt HDC, 0, 0, PS.rcPaint.nright - PS.rcPaint.nleft, _ PS.rcPaint.nbottom - PS.rcPaint.ntop, gHCDC, 0, 0, %SRCCOPY endpaint ghStatic, ps
*** later yet: yes, the whole of the client gets invalidated. Why? How to code around this - a global changedrect?Last edited by Chris Holbrook; 11 Feb 2009, 05:56 AM.
Leave a comment:
-
Chris,
use GRAPHIC BOX?
Code:'PBCC5 program #BREAK ON FUNCTION PBMAIN () AS LONG GRAPHIC WINDOW "Rectangles",1,1,400,400 TO hWin??? GRAPHIC ATTACH hWin???,0 FOR r&=1 TO 200 STEP 5 FillColour&=r&*2+256 GRAPHIC BOX (r&*2,r&*3) - (r&*4,r&*5) ,,%RED,FillColour& NEXT WAITKEY$ END FUNCTION
Leave a comment:
-
colored rectangular areas in a bitmap - how?
How should I create colored rectangular areas in a bitmap, please? The speed of execution is important, BTW.Tags: None
Leave a comment: