Pixel propertie question 
Author Message
 Pixel propertie question

Hello, I have a problem .......... How I could create a pixel routine in
mousedrag event of canvas control for drawing like a free pencil. I tried
very different methods but I fail, please help me.

canvas1.graphics.Pixel(x,y)=rgb(0,0,0)



Mon, 02 Feb 2004 05:19:44 GMT  
 Pixel propertie question

Quote:
> Hello, I have a problem .......... How I could create a pixel routine in
> mousedrag event of canvas control for drawing like a free pencil. I tried
> very different methods but I fail, please help me.

save the last position and draw lines between current and last.

Mfg
Christian

--
Noch ein Bier
fr den Mann am G4

http://www.christians-software.de (Kostenlose Mac/Win Software)



Tue, 03 Feb 2004 06:07:12 GMT  
 Pixel propertie question
Mario Gajardo Tassara wrote :

Quote:
> Hello, I have a problem .......... How I could create a pixel routine in
> mousedrag event of canvas control for drawing like a free pencil. I tried
> very different methods but I fail, please help me.

> canvas1.graphics.Pixel(x,y)=rgb(0,0,0)

This method is slow (In all cases, for RealBasic 2.1.2); I use

canvas1.foreColor=RGB(0,0,0)
canvas1.drawLine x,y,x,y 'Note: Canvas coordinates



Tue, 03 Feb 2004 23:42:34 GMT  
 Pixel propertie question

Quote:
> Mario Gajardo Tassara wrote :

>> Hello, I have a problem .......... How I could create a pixel routine in
>> mousedrag event of canvas control for drawing like a free pencil. I tried
>> very different methods but I fail, please help me.

>> canvas1.graphics.Pixel(x,y)=rgb(0,0,0)

> This method is slow (In all cases, for RealBasic 2.1.2); I use

> canvas1.foreColor=RGB(0,0,0)
> canvas1.drawLine x,y,x,y 'Note: Canvas coordinates

Neither method seems to work well in my testing (RB 3.2.1). And in any
event, if you're doing the drawing in the MouseDrag event, any drawing will
be lost when the canvas needs to be refreshed. Seems to me you'd need to
simultaneously draw to an offscreen picture that would be drawn into the
canvas when it needs refreshed, which would slow things down even more.

George



Wed, 04 Feb 2004 02:40:56 GMT  
 Pixel propertie question
Thanks boys (George Clark, arnaud and Christian Schmitz) for your help ????

Im now improving my application ....



Wed, 04 Feb 2004 04:43:13 GMT  
 Pixel propertie question

Quote:

> Hello, I have a problem .......... How I could create a pixel routine in
> mousedrag event of canvas control for drawing like a free pencil. I tried
> very different methods but I fail, please help me.

> canvas1.graphics.Pixel(x,y)=rgb(0,0,0)

As was suggested, you'll probably want to draw into an offscreen picture.
But dont drawpicture that to screen. Just draw to both the picture and the
canvas. Use the offscreen pic if you get a paint event or you want to save
what you drew.

If you want to draw a connected line then save the last coodinates and draw
a line to the new one, ie

MouseDown:
OldX = X
OldY = Y

Mousedrag:
graphics.DrawLine X,Y, OldX, OldY //should draw to canvas and offscreen pic
OldX = X
OldY = Y

If you want to draw as points you might try graphics.DrawOval X,Y,1,1. This
is 16% faster than DrawRect for plotting a pixel. But I didnt speed test
DrawLine as someone suggested ( how did I miss that? ).

Anyways, be careful with graphics.Pixel. If you're out of bounds you'll get
an exception error which will close your program if you dont handle it. I
would use DrawOval or DrawLine so you dont have to worry about exceptions.

-Laz



Thu, 05 Feb 2004 11:01:43 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

2. Win32 ASM programming of Sound and Painting to screen Pixel by pixel

3. Direct pixel-by-pixel drawing (with Tk)

4. faster pixel , pentopt and a question ?

5. Plotting a single pixel (possible newbie question)

6. Question about changing a pixel by directly writing to video memory

7. CW2.003 - Printing Properties question..

8. Objects properties - Ada design issues question

9. Properties of CL symbols (probably an RTFM question)

10. libxml2 python, all properties question

11. question on properties

12. In Vo DataWindow SingleLineEdit Properties has "Input Method Editor" Properties

 

 
Powered by phpBB® Forum Software