/*************************************************************************
 * FastSprite Example Code
 *
 * File: Image.h
 *
 * This file contains the Image class defination
 *
 * Author: Ashley Roll - ash@digitalnemesis.com
 *
 * Copyright (c) Digital Nemesis Pty Ltd, 1999. All Rights Reserved
 * Permission is granted to use and distribute this document and related
 * source code free of charge provided this and all
 * similar messages and copyrights in the related files remains intact.
 *************************************************************************/

#if !defined(_Image_H_INCLUDED_)
#define _Image_H_INCLUDED_


typedef unsigned char	UInt8;
typedef unsigned short	UInt16;
typedef unsigned int	UInt32;

typedef char		Int8;
typedef short		Int16;
typedef int		Int32;

// This image datatype can store both normal bitmaps and
// transparent bitmaps.
// 
// the "transparent" image format is a compressed one that 
// allows easy skipping of pixels that don't need to be set.
//
// This is achieved by having a set of rendering instructions and
// a list of data. The data is stored in the ImageBits and the 
// instructions are stored in the ImageCodes.
//
// The image codes are 16 bit numbers. If they are negative, they 
// indicate a number of pixels to skip in the current line, if it is
// positive, it is the number of pixels to draw. A code of 0 means the
// end of the current line, a 0 following a 0 means the end of the image.
// 
// The pixels to skip are not stored in the ImageBits, but are discarded when
// they are encoded, Therefore the ImageBits contains the stream of pixels to draw
// excluding the "transparent" ones.
//
// As this class represents both types of images, If Codes() == NULL, then 
// this should be treated as a normal bitmap and all pixles rendered, if it is
// not NULL, then the codes need to be interrupted.

typedef UInt16 ImageBits;	// actual image data
typedef Int16  ImageCodes;	// the image codes for drawing transparent images

class Image 
{
public:
	// constructor
	Image(UInt32 w, UInt32 h, UInt32 bpp, ImageBits* bits, ImageCodes* codes)
		{ m_nWidth = w; m_nHeight = h, m_nBitsPerPixel = bpp; m_pBits = bits; m_pCodes = codes; };

	~Image() {};
	
	// Accessors for internal data
	UInt32		Width( void ) {return m_nWidth;};
	UInt32		Height( void ) {return m_nHeight;};
	UInt32		BitsPerPixel( void ) {return m_nBitsPerPixel;};
	ImageBits*	Bits( void ) {return m_pBits;};
	ImageCodes*	Codes( void ) {return m_pCodes;};

	// Set Accessors
	void		SetBitsPerPixel(UInt32 bpp) {m_nBitsPerPixel = bpp;};

protected:
	UInt32		m_nWidth;		// image width
	UInt32		m_nHeight;		// image height
	UInt32		m_nBitsPerPixel;	// colour format (15 | 16)
	ImageBits*	m_pBits;		// the image's bits
	ImageCodes* 	m_pCodes;		// the image code data for transparency.
};

#endif /* _Image_H_INCLUDED_ */
