Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2001-10

How to draw pixels ?

12 messages · 5 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luis R. Hilario
to Inpromptu: How to draw pixels ?
Mattias Gaertner wrote 12 lines
On Wed, 3 Oct 2001 11:53:01 -0400 Inpromptu wrote: > How to draw pixels ? Just the same like lines, circles and boxes. Any component with a canvas can be drawn onto: Canvas.Pixels[x,y] := clRed; But these pixels are not stored. You must draw them in every OnPaint event of the component, which can be pretty slow.

But we must remember that it does not work.
Or already functions?

|------------------------------| | Luis R. Hilario | | http://www.luis-digital.8m.com | |------------------------------| _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

Reply by email

Mattias Gaertner
to Inpromptu: How to draw pixels ?
I think I wote a function some time ago to convert to TColor. Check the gtk files for a procedure ???ToTColor

I found a TGDKColorToTColor function.
A GDKColor consists of Pixel, Red, Green and Blue, so it is no problem to convert this to TColor. But gdk_image_get_pixel returns a mere pixel index. How can we convert this to TColor?

Ideas?

Mattias Gaertner

Reply by email

Marc Weustink
to Marc Weustink: Pffff... It was to long ago that I did something with GTK drawing. From what I remember…
Mattias Gaertner wrote 12 lines
On Mon, 08 Oct 2001 00:48:10 +0200 Marc Weustink wrote: > Pffff... It was to long ago that I did something with GTK drawing. From > what I remember there is a GTK/GDK finction to get the RGB values forn an > index. > > BTW how doe you set the pixel ? (see TGtkObject.SetPixel in gtkobject.inc) With gdk_image_put_pixel. The TColor is converted to a TGDKColor via gdk_colormap_alloc_color with gdk_colormap_get_system as the colormap.

Ok, then yot get a GDKColor fron the get_pixel.

From the description of the GDKColormap structure itself, I think you can lookup the index in this map. I only don't know if the SystemMAp is a pseudo colormap, but we can find out.

Marc

Reply by email

Mattias Gaertner
to Shane Miller: I think I wote a function some time ago to convert to TColor. Check the gtk files for a…
Show quoted text 5 lines
Pffff... It was to long ago that I did something with GTK drawing. From what I remember there is a GTK/GDK finction to get the RGB values forn an index. BTW how doe you set the pixel ?

(see TGtkObject.SetPixel in gtkobject.inc)
With gdk_image_put_pixel. The TColor is converted to a TGDKColor via gdk_colormap_alloc_color with gdk_colormap_get_system as the colormap.

Mattias

Reply by email

Marc Weustink
to Mattias Gaertner: On Mon, 08 Oct 2001 09:16:50 +0200 I think you are right. gdk_image_get_pixel returns a…

+ From: Mattias Gaertner
+
+ On Mon, 08 Oct 2001 09:16:50 +0200
+ Marc Weustink wrote:
+
+ > >(see TGtkObject.SetPixel in gtkobject.inc)
+ > >With gdk_image_put_pixel. The TColor is converted to a
+ > >TGDKColor via gdk_colormap_alloc_color with
+ > >gdk_colormap_get_system as the colormap.
+ >
+ > Ok, then yot get a GDKColor fron the get_pixel.
+ >
+ > From the description of the GDKColormap structure itself,
+ > I think you can lookup the index in this map. I only don't
+ > know if the SystemMAp is a pseudo colormap, but we can
+ > find out.
+
+ I think you are right. gdk_image_get_pixel returns a index in
+ the colormap (gdk_colormap_get_system). But this index can
+ also be a pseudo color (Direct Color or True Color). How can
+ we find out?

Reply by email

Mattias Gaertner
to Marc Weustink: Pffff... It was to long ago that I did something with GTK drawing. From what I remember…
Show quoted text 9 lines
>(see TGtkObject.SetPixel in gtkobject.inc) >With gdk_image_put_pixel. The TColor is converted to a TGDKColor via >gdk_colormap_alloc_color with gdk_colormap_get_system as the colormap. Ok, then yot get a GDKColor fron the get_pixel. From the description of the GDKColormap structure itself, I think you can lookup the index in this map. I only don't know if the SystemMAp is a pseudo colormap, but we can find out.

I think you are right. gdk_image_get_pixel returns a index in the colormap (gdk_colormap_get_system). But this index can also be a pseudo color (Direct Color or True Color). How can we find out?

I committed some new code for TColorDialog. The selected color can now be set.

Mattias

Reply by email

Mattias Gaertner
to Inpromptu: How to draw pixels ?
How to draw pixels ?

Just the same like lines, circles and boxes. Any component with a canvas can be drawn onto:

Canvas.Pixels[x,y] := clRed;

But these pixels are not stored. You must draw them in every OnPaint event of the component, which can be pretty slow.

Mattias Gaertner

Reply by email

Mattias Gaertner
to Inpromptu: How to draw pixels ?
Show quoted text 16 lines
Mattias Gaertner wrote: > > On Wed, 3 Oct 2001 11:53:01 -0400 > Inpromptu wrote: > > > How to draw pixels ? > > Just the same like lines, circles and boxes. Any component with a canvas can be drawn onto: > > Canvas.Pixels[x,y] := clRed; > > But these pixels are not stored. You must draw them in every OnPaint event of the component, which can be pretty slow. > But we must remember that it does not work. Or already functions?

Sorry, you are right, there was a bug. I fixed the SetPixel. But I don't know how to fix the GetPixel, because I don't know how to convert the result of gdk_image_get_pixel to TColor. Can anyone give me a hint?

I also fixed the TCustomForm.OnResize event and some smaller bugs.

Mattias

Reply by email

Shane Miller
to Inpromptu: How to draw pixels ?

I think I wote a function some time ago to convert to TColor. Check the gtk files for a procedure ???ToTColor

Shane

Earlier message 44 lines
----- Original Message ----- From: "Mattias Gaertner" To: Sent: Sunday, October 07, 2001 2:37 AM Subject: Re: [lazarus] How to draw pixels ? > On Fri, 05 Oct 2001 20:21:25 -0400 > "Luis R. Hilario" wrote: > > > Mattias Gaertner wrote: > > > > > > On Wed, 3 Oct 2001 11:53:01 -0400 > > > Inpromptu wrote: > > > > > > > How to draw pixels ? > > > > > > Just the same like lines, circles and boxes. Any component with a canvas can be drawn onto: > > > > > > Canvas.Pixels[x,y] := clRed; > > > > > > But these pixels are not stored. You must draw them in every OnPaint event of the component, which can be pretty slow. > > > > > > > But we must remember that it does not work. > > Or already functions? > > Sorry, you are right, there was a bug. I fixed the SetPixel. > But I don't know how to fix the GetPixel, because I don't know how to convert the result of gdk_image_get_pixel to TColor. Can anyone give me a hint? > > > I also fixed the TCustomForm.OnResize event and some smaller bugs. > > > Mattias > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus

Reply by email

Marc Weustink
to Shane Miller
Mattias Gaertner wrote 13 lines
On Sun, 7 Oct 2001 13:55:03 -0500 "Shane Miller" wrote: > I think I wote a function some time ago to convert to TColor. Check the gtk > files for a procedure ???ToTColor I found a TGDKColorToTColor function. A GDKColor consists of Pixel, Red, Green and Blue, so it is no problem to convert this to TColor. But gdk_image_get_pixel returns a mere pixel index. How can we convert this to TColor?

Pffff... It was to long ago that I did something with GTK drawing. From what I remember there is a GTK/GDK finction to get the RGB values forn an index.

BTW how doe you set the pixel ?

Marc

Reply by email