Paste: cairo png write fail

Author: hsuh
Mode: factor
Date: Wed, 30 Sep 2009 16:01:54
Plain Text |
USING: accessors cairo cairo.ffi fry images images.memory
kernel math.rectangles ;
IN: cairo-png

: make-png-image ( dim quot -- image )
    '[
        <image-surface>
        dup "hello.png" cairo_surface_write_to_png drop
        &cairo_surface_destroy
        <cairo> &cairo_destroy
        @
    ] make-memory-bitmap
    BGRA >>component-order
    ubyte-components >>component-type ; inline

: hello-cairo ( -- )
    { 300 300 }
    [
        { 100 100 } { 200 200 } <rect> fill-rect
    ] make-png-image drop ;

MAIN: hello-cairo

Annotation: fixed

Author: blei
Mode: factor
Date: Wed, 30 Sep 2009 16:22:00
Plain Text |
USING: accessors cairo cairo.ffi fry images images.memory
kernel math.rectangles colors.constants ;
IN: cairo-png

: make-png-image ( dim quot -- image )
    '[
        <image-surface>
        &cairo_surface_destroy
        [
            <cairo> &cairo_destroy
            @
        ] keep
        "hello.png" cairo_surface_write_to_png drop
    ] make-memory-bitmap
    BGRA >>component-order
    ubyte-components >>component-type ; inline

: hello-cairo ( -- )
    { 300 300 }
    [
        { 100 100 } { 200 200 } <rect> fill-rect 
    ] make-png-image drop ;

MAIN: hello-cairo

Annotation: even better

Author: blei
Mode: factor
Date: Wed, 30 Sep 2009 16:33:41
Plain Text |
USING: accessors cairo cairo.ffi fry images images.memory
kernel math.rectangles colors.constants images.memory.private
destructors ;
IN: cairo-png

: make-png-image ( dim quot filename -- )
    '[
        _ [ malloc-bitmap-data ] keep
        <image-surface> &cairo_surface_destroy
        [ <cairo> &cairo_destroy @ ]
        [ _ cairo_surface_write_to_png drop ] bi
    ] with-destructors ; inline

: hello-cairo ( -- )
    { 300 300 }
    [
        { 100 100 } { 200 200 } <rect> fill-rect 
    ] "hello.png" make-png-image ;

MAIN: hello-cairo

New Annotation

Summary:
Author:
Mode:
Body: