Board index » delphi » Fast Drawing Grid on Canvas?
Hayk Petrosya
![]() Delphi Developer |
Sun, 26 Dec 2004 06:51:27 GMT
|
Hayk Petrosya
![]() Delphi Developer |
Sun, 26 Dec 2004 06:51:27 GMT
Fast Drawing Grid on Canvas?
Hi,
I have Bitmap on which I have to draw a grid and I find out that if Bitmap So I was wondering if there any faster way to do that? Thanks. |
Paul Nicholl
![]() Delphi Developer |
Sun, 26 Dec 2004 07:11:43 GMT
Re:Fast Drawing Grid on Canvas?Look up ScanLine under TBitmap... -- Paul Nicholls (Delphi 5 Professional) HomePage: www.southcom.com.au/~phantom Quote"Hayk Petrosyan" <hayk_petros...@yahoo.com> wrote in message Quote> Hi, |
bcb
![]() Delphi Developer |
Sun, 26 Dec 2004 10:48:51 GMT
Re:Fast Drawing Grid on Canvas?Hello, This link should help. Quote"Paul Nicholls" <paul-nicho...@hotmail.com> wrote in message Quote> Look up ScanLine under TBitmap... |
Jon Q. Jacob
![]() Delphi Developer |
Sun, 26 Dec 2004 11:14:47 GMT
Re:Fast Drawing Grid on Canvas?Quote> "Life is like a road - occasionally you run into potholes or get Life is like a road trip. Sometimes you're the bug; sometimes you're the windshield. Sorry. I couldn't resist. |
Paul Nicholl
![]() Delphi Developer |
Sun, 26 Dec 2004 11:52:52 GMT
Re:Fast Drawing Grid on Canvas?"Jon Q. Jacobs" <jqjac...@gte.net> wrote in message news:3d2ba676$1_1@dnews... Quote> > "Life is like a road - occasionally you run into potholes or get Cheers, HomePage: www.southcom.com.au/~phantom |
RandomAcces
![]() Delphi Developer |
Sun, 26 Dec 2004 22:14:21 GMT
Re:Fast Drawing Grid on Canvas?Quote"Hayk Petrosyan" <hayk_petros...@yahoo.com> wrote in message Quote> Hi, calls. Regards |
Hayk Petrosya
![]() Delphi Developer |
Mon, 27 Dec 2004 00:51:17 GMT
Re:Fast Drawing Grid on Canvas?ScanLine works really fast, like 20 times probably. But it's not trivial to draw a Grid where you need to draw only every 6 pixel when I am using pf1bit mode. It's easy if scale is like 8, 16, 24 but for other numbers I need some other algorithm. Anyone have ready algorithm to do that? Thanks! Quote"Paul Nicholls" <paul-nicho...@hotmail.com> wrote in message Quote> Look up ScanLine under TBitmap... |
Jens Grusche
![]() Delphi Developer |
Mon, 27 Dec 2004 03:01:40 GMT
Re:Fast Drawing Grid on Canvas?Quote> i := 0; Quote> P[i shr 3] := 1 shl (7-(i and 7)); Jens P.S. I use [i shr 3] instead of [i div 8], the result is the same, but |
Hayk Petrosya
![]() Delphi Developer |
Mon, 27 Dec 2004 05:22:56 GMT
Re:Fast Drawing Grid on Canvas?Thanks! I will try that. Some other strange thing is happening too. If my Scale is something other Did you experienced anything like that? Quote"Jens Gruschel" <j...@pegtop.net> wrote in message Quote> > i := 0; |
Jens Grusche
![]() Delphi Developer |
Tue, 28 Dec 2004 05:57:54 GMT
Re:Fast Drawing Grid on Canvas?Quote> Some other strange thing is happening too. If my Scale is something other div 8) can result in the same value (for example if i = 0 and scale = 3). In such a case you set the same byte twice. The most simple way to avoid this would be... P[i shr 3] := P[i shr 3] OR (1 SHL ... Note that this cannot happen if scale >= 8 (if I'm not missing something Jens |
Hayk Petrosya
![]() Delphi Developer |
Tue, 28 Dec 2004 06:50:16 GMT
Re:Fast Drawing Grid on Canvas?Actually I wasn't talking about thath :) I wrote some algorithm to handle that thing. The point of my last message Thanks. Quote"Jens Gruschel" <j...@pegtop.net> wrote in message Quote> > Some other strange thing is happening too. If my Scale is something |
Thérèse Hanque
![]() Delphi Developer |
Tue, 28 Dec 2004 17:02:18 GMT
Re:Fast Drawing Grid on Canvas?Hi Hayk, Quote> while i < Bitmap.Width do begin operation you must apply. Not only the line may be in different positions inside the byte, but in some cases you might have to draw more than one line inside the same byte. Let's say that B is the limit between two bytes, x is a bit that must not be BIxxxxxIxBxxxxIxxxBxxIxxxxxBIxxxxxIxB etc. In this case you have 3 different patterns, but if Scale is 7 you will have more! Thrse |
Thérèse Hanque
![]() Delphi Developer |
Tue, 28 Dec 2004 18:34:16 GMT
Re:Fast Drawing Grid on Canvas?Hi Hayk, Quote> ScanLine works really fast, like 20 times probably. But it's not trivial to Scale := 6; Thrse |
Thérèse Hanque
![]() Delphi Developer |
Tue, 28 Dec 2004 18:58:40 GMT
Re:Fast Drawing Grid on Canvas?Quote> If CurrentByte <> PreviousByte then the same as Jens's suggestion?)... Thrse |
Thérèse Hanque
![]() Delphi Developer |
Tue, 28 Dec 2004 19:33:00 GMT
Re:Fast Drawing Grid on Canvas?Hi Hayk, Quote> The point of my last message Is your Bitmap.Width a multiple of 8? Thrse |