Forum > Graphics

PGdkPixbuf to byte array

(1/1)

mrdebug:
How can I save a PGdkPixbuf object into a byte array using fpc?
These functions:

--- Code: ---gdk_pixbuf_save_to_buffer
gdk_pixbuf_save_to_bufferv
gdk_pixbuf_save_to_callback
gdk_pixbuf_save_to_callbackv
--- End code ---
there aren't in fpc.

Marc:
have a look at gdk_pixbuf_get_pixels (and you may also need gdk_pixbuf_get_rowstride)

Or do you need more than pixels ?

mrdebug:
I need a way to obtain an array to send at a client.

Marc:
What is the difference between a pointer to a bunch of pixels and an array of pixels ?

mrdebug:
When you execute the function to obtain the array of pixels you can select the format of the image in the array (I need jpeg compression.).
I have extended the gtk2pixbas.pas unit with this code:


--- Code: ---type AByteIn= array of byte;
type PAByteIn= ^AByteIn;

type TGdkPixbufSaveFunc= function(buffer:PChar; count:gsize; error:PPGError; AAByteIn:PAByteIn): gboolean; cdecl;
function gdk_pixbuf_save_to_callback(pixbuf:PGdkPixbuf; save_func:TGdkPixbufSaveFunc; data:gpointer; _type:Pchar; error:PPGError): gboolean; cdecl; external gdkpixbuflib;
--- End code ---

The code works well but obtain an jpeg image requires some seconds.
With RGBGraphics libraries obtain a jpeg image requires 150 milliseconds.

Do you now a faster way?

Navigation

[0] Message Index

Go to full version