en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en de en en en en en nl en en en en en en de en en en en en en en nl en en hu en en en en en en en en en en en en en nl en en en en en en en en en en en en nl en en fa en en fr en da en en en en en en en nl en en en en en en en en en en en en es en en en en en en en nl vi en en en en en en en en en en en en en nl en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
colored rectangular areas in a bitmap - how?
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
11 Feb 2009, 04:21 AM
How should I create colored rectangular areas in a bitmap, please? The speed of execution is important, BTW.
Join Date: Jun 1999
11 Feb 2009, 05:25 AM
'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
Join Date: Aug 2005
11 Feb 2009, 05:32 AM
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?
'--------------------------------------------------------------------- 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: changed first two coordiante parameters in Bitblt for PS.rcPaint.nleft, PS.rcPaint.ntop and it made no difference at all. Does this mean that the PS.rcPaint rect is the same as the whole client rect, even though I only invalidated a little bit of it?
*** 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.
Join Date: Aug 2005
11 Feb 2009, 05:34 AM
Originally posted by Paul Dixon View Post
fonely. I'm doing it to replace GRAPHIC BOX, which mixes but poorly with subclassing.
Join Date: Aug 1998
11 Feb 2009, 08:46 AM
Port Washington WI USA
Join Date: Feb 1999
11 Feb 2009, 09:19 AM
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.
Join Date: Aug 2005
11 Feb 2009, 11:22 AM
Originally posted by Chris Boss View Post
Thanks Chris, I am investigating. It is much faster.
**** added - there is a very useful tutorial here: http://www.codeproject.com/KB/GDI/updatergn.aspx
Last edited by Chris Holbrook; 11 Feb 2009, 11:50 AM.
Join Date: Aug 2005
11 Feb 2009, 04:29 PM
see source code forum for implementation of "Dirty Rectangles": http://www.powerbasic.com/support/pb...291#post309291
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 04:18 AM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.