Macaw OS C reference

Function decodepicture

#include <macaw.h>
int decodepicture(
    const void *png,
    int n,
    int maxw,
    int maxh,
    int background,
    int sprite,
    int *w,
    int *h
);

Makes a picture from PNG data in memory, such as a file you've read or something downloaded. It's shrunk to fit if it's too big.

Parameters

pngconst void *
Where the PNG's bytes are.
nint
How many bytes there are.
maxwint
The widest the picture can be, in pixels, or 0 for any width (up to 4096).
maxhint
The tallest the picture can be, in pixels, or 0 for any height (up to 4096).
backgroundint
The colour see-through parts are put on, as 0xRRGGBB, or -1 for white.
spriteint
1 for pixel art: no dithering, and see-through parts stay colour 0. 0 for a photo.
wint *
Where to put the PNG's own width before shrinking: pass the address of an int, like &w, or NULL.
hint *
Where to put the PNG's own height before shrinking: pass the address of an int, like &h, or NULL.

Returns int

The picture's number, or 0 if the data isn't a PNG it can read.

In Pictures, with newpicture, loadpicture, freepicture, picturewidth, pictureheight, drawpicture, drawpart, drawinto, drawpictureex, drawpartex, savepicture, parsepicture, decodepicturefile, importpicture, importpicturefile, pictureget, pictureset, picturesize, pictureclear, picturecopy, picturegetrgb, picturesetrgb.