PGdkPixbuf from stream lazarus / 39-Graphics ---------------------------------------------------------------------- mrdebug · 2010-05-20 15:20 Does anybody knows how to create a new PGdkPixbuf from byte array or stream? There isn't gdk_pixbuf_new_from_stream gtk2 function in pfc. ---------------------------------------------------------------------- theo · 2010-05-20 16:25 What do you want to achieve? ---------------------------------------------------------------------- mrdebug · 2010-05-20 16:39 I'm writing a client for a videoserver. The Lcl components are too slow to show a jpeg sequence. To obtain the fastest refresh I'm writing a gtk2 form. I can read a jpeg image from file but I don't understand how can I create a PGdkPixbuf from an byte array or stream. The gdk_pixbuf_new_from_stream function does not exists in pfc. ---------------------------------------------------------------------- theo · 2010-05-20 17:07 You could try sth like this: Code: [Select]  {$ifdef LCLGtk2}    Cairo, gdk2, gtkDef, gtkProc,   {$endif}    Graphics, Classes, SysUtils, opbitmap; {$ifdef LCLGtk2} function gdk_cairo_create(drawable: PGdkDrawable): Pcairo_t; cdecl; external gdklib; procedure OpBitmapPaint32(Canvas:Graphics.TCanvas; Bmp: TOpBitmap; X, Y: integer); var cr: Pcairo_t;   surface: Pcairo_surface_t; begin   Bmp.PixelFormat := pf32bit;   cr := gdk_cairo_create(TGtkDeviceContext(Canvas.Handle).Drawable);   surface := cairo_image_surface_create_for_data(Bmp.ScanLine[0], CAIRO_FORMAT_RGB24, Bmp.Width, Bmp.Height, Bmp.Data.LineLength);   if surface <> nil then   begin     cairo_set_source_surface(cr, surface, X, Y);     cairo_paint(cr);   end;   cairo_destroy(cr);   cairo_surface_destroy(surface); end; {$endif} Where OpBitmap.ScanLine[0] points to an array of 32bit ARGB.