GTKD Cairo get pixel color

TheDGuy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jan 2 10:10:07 PST 2016


> ```
> import cairo.ImageSurface;
> ImageSurface.createForData(c,cairo.FORMAT_ARGB32,256,256,256*4);
> ```
>
> You need to import the ImageSurface module, and the 
> createForData function is in the ImageSurface class which is in 
> the cairo.ImageSurface module.

Thanks, that was the problem!

Now i can read the buffer from a png image and save the buffer as 
a file:

		auto pngImage = 
ImageSurface.createFromPng("C:\\Users\\Standardbenutzer\\Desktop\\DSC00564-1.png");
		auto buffer = pngImage.getData();
		auto cS = ImageSurface.createForData(buffer, 
cairo_format_t.ARGB32,pngImage.getWidth(),pngImage.getHeight(),pngImage.getStride());
		cS.writeToPng("test.png");

but how do i do that with my GTKD Context in my "drawCallback()" 
function?


More information about the Digitalmars-d-learn mailing list