From 07d34d83e416510a2a07e031146ac3d8f40fcccf Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Sat, 8 Feb 2025 17:44:49 +0100 Subject: [PATCH] Gtk3: fixed TGtk3DeviceContext.getPixel(). Patch by Anton Kavalenka. issue #41413 --- lcl/interfaces/gtk3/gtk3objects.pas | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/gtk3/gtk3objects.pas b/lcl/interfaces/gtk3/gtk3objects.pas index 516938edbb..2ed7fbc73c 100644 --- a/lcl/interfaces/gtk3/gtk3objects.pas +++ b/lcl/interfaces/gtk3/gtk3objects.pas @@ -2004,17 +2004,18 @@ end; function TGtk3DeviceContext.getPixel(x, y: Integer): TColor; var - pixbuf: PGdkPixbuf; - pixels: pointer; + pixels,row: pointer; + stride:integer; begin Result := 0; - pixbuf := gdk_pixbuf_get_from_surface(CairoSurface, X, Y, 1, 1); - if Assigned(pixbuf) then + cairo_surface_flush (CairoSurface); + pixels := cairo_image_surface_get_data(Cairosurface); + if Assigned(pixels) then begin - pixels := gdk_pixbuf_get_pixels(pixbuf); - if Assigned(pixels) then - Result := PLongInt(pixels)^ and $FFFFFF; // take first 3 bytes at pixels^ - g_object_unref(pixbuf); + stride := cairo_image_surface_get_stride(CairoSurface); + row:=pixels+(fncOrigin.Y+Y)*stride; + inc(row,(fncOrigin.X+X)*sizeof(longint)); + Result := PLongInt(row)^ and $FFFFFF; // take first 3 bytes at pixels^ end; end;