Re: Is posible create a png surface from a png buffer read from a zip file?

Elmar Haneke <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
> I found thecairo_image_surface_create_from_png_stream
> <http://cairographics.org/manual/cairo-PNG-Support.html#cairo-image-surface-create-from-png-stream> ()
> is hard to manage and not references directly a buffer. It wil be easy
> to implement ?. Thanks for your comments.

This is the right procedure to do so wis some few lines of glue code.

For an pascal stream I use

   
sf:=cairo_image_surface_create_from_png_stream(@ReadFromStream,PNG_data);

there PNG_data is an stream containing PNG image.

the glue-code is rather simple:

function ReadFromStream(closure: Pointer; data: PByte; length:
LongWord):cairo_status_t; cdecl;
var
  Stream: TStream absolute closure;
begin
  if Stream.Read(data^, Length) = int64(Length) then
    result := CAIRO_STATUS_SUCCESS
  else
    result := CAIRO_STATUS_READ_ERROR;
end;

Hope that helps

Elmar

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.