Back to index

lightning-sunbird  0.9+nobinonly
Functions
write_png.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void write_png_argb32 (char *buffer, FILE *file, int width, int height, int stride)

Function Documentation

void write_png_argb32 ( char *  buffer,
FILE file,
int  width,
int  height,
int  stride 
)

Definition at line 58 of file write_png.c.

{
    int i;
    png_struct *png;
    png_info *info;
    png_byte **rows;
    png_color_16 white;
    
    rows = malloc (height * sizeof(png_byte*));

    for (i = 0; i < height; i++) {
       rows[i] = buffer + i * stride;
    }

    png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
    info = png_create_info_struct (png);

    png_init_io (png, file);
    png_set_IHDR (png, info,
                width, height, 8,
                PNG_COLOR_TYPE_RGB_ALPHA, 
                PNG_INTERLACE_NONE,
                PNG_COMPRESSION_TYPE_DEFAULT,
                PNG_FILTER_TYPE_DEFAULT);

    white.red = 0xff;
    white.blue = 0xff;
    white.green = 0xff;
    png_set_bKGD (png, info, &white);

    png_set_write_user_transform_fn (png, unpremultiply_data);
    png_set_bgr (png);

    png_write_info (png, info);
    png_write_image (png, rows);
    png_write_end (png, info);

    png_destroy_write_struct (&png, &info);

    free (rows);
}

Here is the call graph for this function:

Here is the caller graph for this function: