FLTK 1.4.4: fl_write_png.cxx File Reference

FLTK 1.4.4

Loading...
Searching...
No Matches
fl_write_png.cxx File Reference

PNG image support functions. More...

`#include <config.h>`
`#include <FL/Fl_PNG_Image.H>`
`#include <FL/Fl_RGB_Image.H>`
`#include <FL/fl_string_functions.h>`
`#include <FL/fl_utf8.h>`
`#include <stdio.h>`
`#include <time.h>`

## Functions
int | fl_write_png (const char *filename, const char *pixels, int w, int h, int d, int ld)
| Write raw image data to a PNG image file.
int | fl_write_png (const char *filename, const unsigned char *pixels, int w, int h, int d, int ld)
| Write raw image data to a PNG image file.
int | fl_write_png (const char *filename, Fl_RGB_Image *img)
| Write an RGB(A) image to a PNG image file.

## Detailed Description

PNG image support functions.

## Function Documentation

## ◆ fl_write_png() [1/3]

int fl_write_png | ( | const char * | filename,
|  | const char * | pixels,
|  | int | w,
|  | int | h,
|  | int | d,
|  | int | ld )

Write raw image data to a PNG image file.

This is a very basic and restricted function to create a PNG image file from raw image data, e.g. a screenshot.

The image data must be aligned w/o gaps after each row (ld = 0 or ld = w * d) or `ld` must be the total length of each row, i.e. w * d + gapsize. If ld == 0 then ld = w * d is assumed.

The total data size must be (w * d + gapsize) * h = ld' * h where ld' = w * d if ld == 0.

For further restrictions and return values please see fl_write_png(const char *filename, Fl_RGB_Image *img).

Parameters

  [in] | filename | Output filename, extension should be '.png'
  [in] | pixels | Image data
  [in] | w | Image data width
  [in] | h | Image data height
  [in] | d | Image depth: 1 = GRAY, 2 = GRAY + alpha, 3 = RGB, 4 = RGBA
  [in] | ld | Line delta: default (0) = w * d

Returns
  success (0) or error code, see ...

See also
  fl_write_png(const char *filename, Fl_RGB_Image *img)

## ◆ fl_write_png() [2/3]

int fl_write_png | ( | const char * | filename,
|  | const unsigned char * | pixels,
|  | int | w,
|  | int | h,
|  | int | d,
|  | int | ld )

Write raw image data to a PNG image file.

See also
  fl_write_png(const char *filename, const char *pixels, int w, int h, int d, int ld)

## ◆ fl_write_png() [3/3]

int fl_write_png | ( | const char * | filename,
|  | Fl_RGB_Image * | img )

Write an RGB(A) image to a PNG image file.

This is a very basic and restricted function to create a PNG image file from an RGB image (Fl_RGB_Image).

The image data must be aligned w/o gaps, i.e. ld() MUST be zero or equal to data_w() * data_h().

The image file is always written with the original image size data_w() and data_h(), even if the image has been scaled.

Image depth 1 (gray), 2 (gray + alpha channel), 3 (RGB) and 4 (RGBA) are supported.

Note
  Currently there is no error handling except for errors when opening the file. This may be changed in the future.

Parameters

  [in] | filename | Output filename, extension should be '.png'
  [in] | img | RGB image to be written

Returns
  success (0) or error code: negative values are errors

Return values

  0 | success, file has been written
  -1 | png or zlib library not available
  -2 | file open error

See also
  fl_write_png(const char *, int, int, int, const unsigned char *)