Recent

Author Topic: PGdkPixbuf to byte array  (Read 5545 times)

mrdebug

  • Full Member
  • ***
  • Posts: 160
PGdkPixbuf to byte array
« on: May 28, 2010, 04:34:29 am »
How can I save a PGdkPixbuf object into a byte array using fpc?
These functions:
Code: [Select]
gdk_pixbuf_save_to_buffer
gdk_pixbuf_save_to_bufferv
gdk_pixbuf_save_to_callback
gdk_pixbuf_save_to_callbackv
there aren't in fpc.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Re: PGdkPixbuf to byte array
« Reply #1 on: May 28, 2010, 05:40:51 am »
have a look at gdk_pixbuf_get_pixels (and you may also need gdk_pixbuf_get_rowstride)

Or do you need more than pixels ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

mrdebug

  • Full Member
  • ***
  • Posts: 160
Re: PGdkPixbuf to byte array
« Reply #2 on: May 28, 2010, 07:12:36 am »
I need a way to obtain an array to send at a client.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Re: PGdkPixbuf to byte array
« Reply #3 on: May 30, 2010, 06:24:59 pm »
What is the difference between a pointer to a bunch of pixels and an array of pixels ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

mrdebug

  • Full Member
  • ***
  • Posts: 160
Re: PGdkPixbuf to byte array
« Reply #4 on: May 31, 2010, 02:31:57 am »
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: [Select]
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;

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?

 

TinyPortal © 2005-2018