/*
 *  picture.h
 *  PSP Development
 *
 *  Created by XArt on 19/03/2007.
 *  Copyright 2007 XArt. All rights reserved.
 *
 *  PNG for Mac PowerPC (Big-Endian) Tested by XArt
 *  PNG for Mac intel (Little-Endian) Tested by Bronx
 */

#ifndef _PICTURE_H_
#define _PICTURE_H_

#include <stdio.h>
#include <stdlib.h>

#ifdef _PSP
#include <malloc.h>
#include <png.h>
#else
#include "libpng/png.h"
#include "libpng/pngconf.h"
extern void * memalign (size_t boundary, size_t size);
#endif

#ifdef PSP
#include <psptypes.h>
#else
#ifndef _VAR_TYPEDEFS_
#define _VAR_TYPEDEFS_
typedef unsigned char	u8;
typedef char	         s8;
typedef unsigned short	u16;
typedef short	         s16;
typedef unsigned int	   u32;
typedef int             s32;
#endif
#endif

#ifndef _IMAGE_
#define _IMAGE_
struct Image{
   int   x;                // Image x position
   int   y;                // Image y position
   int   width;            // Image width in pixels
   int   height;           // Image height in pixels
   int   depth;            // 24 = 32-bit RGB / 32 = 32-bit RGB+Alpha (DEPTH NOT YET USED)
   
   void *pixels;           // Allways 32-bits per pixels
};
#endif

class Picture
{
private:
protected:
   Image* loadPNG(const char* filename, int offset);
   void Picture::savePNG(const char* filename, Image *image);
public:
    
   Image* loadPicture(const char* filename, int offset);
   Image* loadPicture(const char* filename);
   void savePicture(const char* filename, Image *image);
   void freePicture(Image *image);
};
#endif
