Fastest way to drawcolor lines on TImage?

Fastest way to drawcolor lines on TImage?

Post by Bony » Thu, 26 Jun 2003 04:50:22



Hi, i need to draw lot of random color lines on the form as
fast as possible. what is the fastest way to do this?

1. Drawing  directly on the Form's canvas?

2. Drawing  on TImage locate on the form?

3. Drawing on TPicture locate on the form?

What will it be faster: using "MoveTo" and "LineTo" commands?
or using "ScanLine" for drawing the lines pixel by pixel in a
loop?

Should i draw directly to the component on the screen? (the
form, the TImage...) or must i draw first on a memory Bitmap and
then copy to the screen with BitBlt? why is it faster than
drawing directly to the screen?

Sorry for so many question, but i hope that you can help me :-)

Thanks everyone!

Bony

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Chri » Thu, 26 Jun 2003 10:58:17


Hi Bony

If you see my post (following yours) you will see a good reason NOT to
draw directly to the forms canvas.

I don't do this much myself but I would suggest drawing to a hidden
canvas as the easiest way and then copying to the visible canvas (on the
form)

that way your updates will be reasonably fast without adding to the
complexity of the project

it would be fastest to draw directly to a bitmap and then blit that to
the screen but that will add greatly to the programming required

Chris


Quote:> Hi, i need to draw lot of random color lines on the form as
> fast as possible. what is the fastest way to do this?

> 1. Drawing  directly on the Form's canvas?

> 2. Drawing  on TImage locate on the form?

> 3. Drawing on TPicture locate on the form?

> What will it be faster: using "MoveTo" and "LineTo" commands?
> or using "ScanLine" for drawing the lines pixel by pixel in a
> loop?

> Should i draw directly to the component on the screen? (the
> form, the TImage...) or must i draw first on a memory Bitmap and
> then copy to the screen with BitBlt? why is it faster than
> drawing directly to the screen?

> Sorry for so many question, but i hope that you can help me :-)

> Thanks everyone!

> Bony


 
 
 

Fastest way to drawcolor lines on TImage?

Post by Bony » Thu, 26 Jun 2003 15:28:40


Thanks for the answer, but i still don't understand, why if
i draw a line in a memory Bitmap and than copy it to a TImage
on the form it would be faster then drawing it directly to the
TImage on the first time? let's say i have TImage on the form
with the size 100x100 pixels, and i have same size Bitmap on the
memory. if i draw a line (0,0)-(0,70) directly to the TImage it
will only have to draw 70 pixels and that's it. if i first copy
it to a memory Bitmap it will draw the same 70 pixels to the
memory, but when i copy the Bitmap to the TImage canvas it will
have to copy and draw 100x100 pixels on the TImage!! it looks
like it should take MUCH more time! so why is the first
solution of drawing directly to the TImage on the first time is
slower solution?

What if i use 'ScanLine' to draw a line on the TImage locate on
the form? even than it will be faster to use a memory TBitmap?
why?

Thanks for any help,

Bony


>Hi Bony

>If you see my post (following yours) you will see a good reason NOT to
>draw directly to the forms canvas.

>I don't do this much myself but I would suggest drawing to a hidden
>canvas as the easiest way and then copying to the visible canvas (on the
>form)

>that way your updates will be reasonably fast without adding to the
>complexity of the project

>it would be fastest to draw directly to a bitmap and then blit that to
>the screen but that will add greatly to the programming required

>Chris


>> Hi, i need to draw lot of random color lines on the form as
>> fast as possible. what is the fastest way to do this?

>> 1. Drawing  directly on the Form's canvas?

>> 2. Drawing  on TImage locate on the form?

>> 3. Drawing on TPicture locate on the form?

>> What will it be faster: using "MoveTo" and "LineTo" commands?
>> or using "ScanLine" for drawing the lines pixel by pixel in a
>> loop?

>> Should i draw directly to the component on the screen? (the
>> form, the TImage...) or must i draw first on a memory Bitmap and
>> then copy to the screen with BitBlt? why is it faster than
>> drawing directly to the screen?

>> Sorry for so many question, but i hope that you can help me :-)

>> Thanks everyone!

>> Bony

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Hans Galem » Thu, 26 Jun 2003 16:09:59



> If you see my post (following yours) you will see a good reason NOT to
> draw directly to the forms canvas.

Cannot discover anything in that post that compares drawing on a forms canvas
with drawing on a canvas anywhere else.

Hans.

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Hans Galem » Thu, 26 Jun 2003 16:18:29



> Hi, i need to draw lot of random color lines on the form as
> fast as possible. what is the fastest way to do this?

> 1. Drawing  directly on the Form's canvas?
> 2. Drawing  on TImage locate on the form?
> 3. Drawing on TPicture locate on the form?

If you make the routines in a nice way you can switch between
those three types. Make the drawingroutines in such a way that
one of the parameters is a TCanvas *Canvas and you can decide
for yourself.

Quote:> What will it be faster: using "MoveTo" and "LineTo" commands?
> or using "ScanLine" for drawing the lines pixel by pixel in a
> loop?

Think MoveTo and so on.

Quote:> Should i draw directly to the component on the screen? (the
> form, the TImage...) or must i draw first on a memory Bitmap and
> then copy to the screen with BitBlt?

There is another problem. If you draw on the Canvas of a TForms or
TPaintBox you have to repaint all everytime the window was covered.
Drawing on a Image->Picture->Bitmap->Canvas needs only one paint.

 > why is it faster than
 > drawing directly to the screen?

Don't know if this is the case.

Hans.

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Bony » Fri, 27 Jun 2003 07:49:42


Thanks Hans, you right and i will try it! :-)

Say, What is a TCanvas? is it a component which i can put on my
form and draw on it? or is it kind of a memory Bitmap? what is
the different between TCanvas and TImage? when will i use this
and when will i use that?

And another question -

How can i use 'LineScan' for drawing directly on a TImage which
is on my main form? (without using a memory Bitmap!) an
example even a small one will be great.

How do i do the same to draw on directly the form's Canvas?

Thanks!

Bony



>> Hi, i need to draw lot of random color lines on the form as
>> fast as possible. what is the fastest way to do this?

>> 1. Drawing  directly on the Form's canvas?
>> 2. Drawing  on TImage locate on the form?
>> 3. Drawing on TPicture locate on the form?

>If you make the routines in a nice way you can switch between
>those three types. Make the drawingroutines in such a way that
>one of the parameters is a TCanvas *Canvas and you can decide
>for yourself.

>> What will it be faster: using "MoveTo" and "LineTo" commands?
>> or using "ScanLine" for drawing the lines pixel by pixel in a
>> loop?

>Think MoveTo and so on.

>> Should i draw directly to the component on the screen? (the
>> form, the TImage...) or must i draw first on a memory Bitmap and
>> then copy to the screen with BitBlt?

>There is another problem. If you draw on the Canvas of a TForms or
>TPaintBox you have to repaint all everytime the window was covered.
>Drawing on a Image->Picture->Bitmap->Canvas needs only one paint.

> > why is it faster than
> > drawing directly to the screen?

>Don't know if this is the case.

>Hans.

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Chri » Fri, 27 Jun 2003 13:22:42





>> If you see my post (following yours) you will see a good reason NOT
>> to draw directly to the forms canvas.

> Cannot discover anything in that post that compares drawing on a forms
> canvas with drawing on a canvas anywhere else.

> Hans.

he said he wanted to draw lots of lines on a canvas quickly
if he called Canvas->Handle everytime it would slow the routine down to a
crawl

From his other post He does not know what a canvas is so the point was mute

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Chri » Fri, 27 Jun 2003 13:32:35


It really depends on what you want to do

drawing on a canvas sends the output to the screen this is slow
if you only need to draw one line in response to a user dragging the
mouse etc.. the use the canvas associated with TImage

MyImage->Canvas->LineTo(X,Y)

but if you want to draw lots of lines and then put them on the screen
with minimum or no flicker then draw them to another Canvas and then
copy it to the image canvas or create your own bitmap and draw it there
and then blit that directly to the screen

you said you want fast!

fast is working directly with memory

slow is Canvas or any of the putpixel functions

Chris


> Thanks for the answer, but i still don't understand, why if
> i draw a line in a memory Bitmap and than copy it to a TImage
> on the form it would be faster then drawing it directly to the
> TImage on the first time? let's say i have TImage on the form
> with the size 100x100 pixels, and i have same size Bitmap on the
> memory. if i draw a line (0,0)-(0,70) directly to the TImage it
> will only have to draw 70 pixels and that's it. if i first copy
> it to a memory Bitmap it will draw the same 70 pixels to the
> memory, but when i copy the Bitmap to the TImage canvas it will
> have to copy and draw 100x100 pixels on the TImage!! it looks
> like it should take MUCH more time! so why is the first
> solution of drawing directly to the TImage on the first time is
> slower solution?

> What if i use 'ScanLine' to draw a line on the TImage locate on
> the form? even than it will be faster to use a memory TBitmap?
> why?

> Thanks for any help,

> Bony


>>Hi Bony

>>If you see my post (following yours) you will see a good reason NOT to
>>draw directly to the forms canvas.

>>I don't do this much myself but I would suggest drawing to a hidden
>>canvas as the easiest way and then copying to the visible canvas (on
>>the form)

>>that way your updates will be reasonably fast without adding to the
>>complexity of the project

>>it would be fastest to draw directly to a bitmap and then blit that to
>>the screen but that will add greatly to the programming required

>>Chris


>>> Hi, i need to draw lot of random color lines on the form as
>>> fast as possible. what is the fastest way to do this?

>>> 1. Drawing  directly on the Form's canvas?

>>> 2. Drawing  on TImage locate on the form?

>>> 3. Drawing on TPicture locate on the form?

>>> What will it be faster: using "MoveTo" and "LineTo" commands?
>>> or using "ScanLine" for drawing the lines pixel by pixel in a
>>> loop?

>>> Should i draw directly to the component on the screen? (the
>>> form, the TImage...) or must i draw first on a memory Bitmap and
>>> then copy to the screen with BitBlt? why is it faster than
>>> drawing directly to the screen?

>>> Sorry for so many question, but i hope that you can help me :-)

>>> Thanks everyone!

>>> Bony

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Hans Galem » Fri, 27 Jun 2003 16:03:50



>>>If you see my post (following yours) you will see a good reason NOT
>>>to draw directly to the forms canvas.

>>Cannot discover anything in that post that compares drawing on a forms
>>canvas with drawing on a canvas anywhere else.

>>Hans.

> he said he wanted to draw lots of lines on a canvas quickly
> if he called Canvas->Handle everytime it would slow the routine down to a
> crawl

Please read my comment again. Comparing drawing on two different canvasses is
something different as a making a slight change in code which makes it much
faster.

I said that there is nothing in your post that compares different canvasses.

So I don't understand then that you come back with the speed improvement (which
is great, by the way).

Quote:> From his other post He does not know what a canvas is so the point was mute

Huh ?

Hans.

 
 
 

Fastest way to drawcolor lines on TImage?

Post by Hans Galem » Fri, 27 Jun 2003 16:19:54



> Say, What is a TCanvas?

Type TCanvas in the editor, place the cursor on this word and call the
help with pressing <F1>.

 > is it a component which i can put on my
 > form and draw on it?

It is a class that is used in many components. You can instantiate one
for yourself with:

    TCanvas *Canvas = new TCanvas;
    // use it
    delete Canvas;

 > or is it kind of a memory Bitmap?

Those two things cannot be compared.

 > what is

Quote:> the different between TCanvas and TImage? when will i use this
> and when will i use that?

TImage and TForm have have a property Canvas. I.e:

    TImage *Image;
    TForm *Form;
    TPaintBox *PaintBox;

    Image->Canvas;
    Image->Picture->Bitmap->Canvas;
    Form->Canvas;
    PaintBox->Canvas;

Quote:> How can i use 'LineScan' for drawing directly on a TImage which
> is on my main form? (without using a memory Bitmap!) an
> example even a small one will be great.

You mean BitMap->ScanLine ?

Examples can be fount easily if you do a google advanced newsgroups searc.
text: BitMap ScanLine' and so on
groups" *cppbuilder*

Quote:> How do i do the same to draw on directly the form's Canvas?

TCanvas has no ScanLine.

But if the canvas can be anywhere, as I said before make your drawing routines
in such a way that they expest a TCanvas as parameter and draw to that canvas.

Hans.

P.S. Could you and Chris please stop quoting and requoting complete messages ?

 
 
 

1. pasting multiple TImages into one TImage (FASTEST WAY)

HI all.
I would like suggestions for the fastest way to paste multiple TImage into
one TImage  using pure delphi (not in ASM)
The TImages are all the same size and are stored in an Array of TImage.

known :

    - All images are the same size and Stretch=fasle must be assumed

    - All start on the same X plane when pasting and appear one under the
other

TIA

Ori

2. Looking for poly converter utility.

3. Fast line detection algorithm for broken line segments

4. Pictures from Toronto??

5. Drawing faster JPEGS in a TImage

6. what is the maximum bits per pixels?

7. Fastest way to change TImage.Picture

8. How to code a AC category 0 or F in baseline JPG

9. Fastest copy routine: TBitmap -> TImage

10. Faster than TImage ?

11. Fast way to display a 2D matrix in memory onto a Timage

12. Illiminate Flicker with function Line To (Timage.canvas)

13. Moving Lines within a TImage