1 /* copyright: Steve Dekorte, 2002
2 * All rights reserved. See _BSDLicense.txt.
4 * This is an object wrapper for libpng.
6 * It's currently only useful for decoding a libpng file
7 * to a byte array and providing info about the
8 * format, width, height and # of components.
10 * It's possible to use an external UArray for loading by calling
11 * PNGImage_setExternalUArray_(), but be carefull not to use the
12 * PNGImage instance after freeing it's external byte array.
15 #ifndef PNGIMAGE_DEFINED
16 #define PNGIMAGE_DEFINED 1
18 #include "IoImageApi.h"
30 unsigned char ownsBuffer
;
34 IOIMAGE_API PNGImage
*PNGImage_new(void);
35 IOIMAGE_API PNGImage
*PNGImage_newWithPath_(char *fname
);
36 IOIMAGE_API
void PNGImage_free(PNGImage
*self
);
38 IOIMAGE_API
void PNGImage_path_(PNGImage
*self
, const char *path
);
39 IOIMAGE_API
char *PNGImage_path(PNGImage
*self
);
41 IOIMAGE_API
void PNGImage_error_(PNGImage
*self
, const char *path
);
42 IOIMAGE_API
char *PNGImage_error(PNGImage
*self
);
44 IOIMAGE_API
void PNGImage_load(PNGImage
*self
);
45 IOIMAGE_API
void PNGImage_save(PNGImage
*self
);
47 IOIMAGE_API
int PNGImage_width(PNGImage
*self
);
48 IOIMAGE_API
int PNGImage_height(PNGImage
*self
);
50 IOIMAGE_API
void PNGImage_width_(PNGImage
*self
, int w
);
51 IOIMAGE_API
void PNGImage_height_(PNGImage
*self
, int h
);
52 IOIMAGE_API
void PNGImage_components_(PNGImage
*self
, int h
);
54 IOIMAGE_API
int PNGImage_pngColorType(PNGImage
*self
); /* private */
56 IOIMAGE_API
unsigned char PNGImage_isRGB8(PNGImage
*self
);
57 IOIMAGE_API
unsigned char PNGImage_isRGBA8(PNGImage
*self
);
58 IOIMAGE_API
unsigned char PNGImage_isL8(PNGImage
*self
);
59 IOIMAGE_API
unsigned char PNGImage_isLA8(PNGImage
*self
);
60 IOIMAGE_API
int PNGImage_components(PNGImage
*self
);
62 IOIMAGE_API UArray
*PNGImage_byteArray(PNGImage
*self
);
64 /* Whomever calls PNGImage_setExternalUArray_ is responsible
65 * for freeing "ba" and for making sure that this
66 * PNGImage is not still using it after it is freed.
68 IOIMAGE_API
void PNGImage_setExternalUArray_(PNGImage
*self
, UArray
*ba
);