Class Hierarchy   Compound List   Compound Members   Related Pages  

Bitbuf.h

This is the verbatim text of the Bitbuf.h include file.

#ifndef BITBUF_INCLUDED
#define BITBUF_INCLUDED

#ifndef SBITMAP_INCLUDED
#include "sbitmap.h"
#endif

#include NATIVE_PALETTE
#include NATIVE_DISPLAY

#define CalcITabIndex(r, g, b) (((int)(r)&0xF0) << 4 | ((int)(g)&0xF0) | ((int)(b)&0xF0) >> 4)
#define CalcITabIndexRGB(rgb) (((rgb)->red&0xF0) << 4 | ((rgb)->green&0xF0) | ((rgb)->blue&0xF0) >> 4)


class NativePlayerWnd;

const U8 colorRamp6[] = { 0, 0x33, 0x66, 0x99, 0xCC, 0xff };


enum PixelFormat { 
	pix1,
	pix2,
	pix4,
	pix8,

	pix16,
	pix16A,
	pix24,
	pix32,
	pix32A
};



struct SColorInfo {
	// ---------------- Platform independant -----------------
	SColorInfo* next;	// Pointer to the next SColorInfo.
	int refCount;

	SColorTable ctab;	// This is the 256 Palette entries.
	U8 itab[16*16*16];	// The inverse color table - a mapping of RGB to indexes.

	// ---------------- Platform dependant -------------------

	void CreateOSPalette();

	void DestroyOSPalette();
};


class CBitBuffer {
  public:
	CBitBuffer();
	~CBitBuffer();

	BOOL inverted()		{ return ( m_inverted != 0 ); }
	int  pixelFormat()	{ FLASHASSERT( bitmap ); return bitmap->PixelFormat();  }
	int  depth()		{ FLASHASSERT( bitmap ); return bitmap->Depth();  }
	char* baseAddess()	{ FLASHASSERT( bitmap ); return (char*) bitmap->Bits();  }
	int  scanLine()		{ FLASHASSERT( bitmap ); return bitmap->ScanLine();  }
	int  width()		{ FLASHASSERT( bitmap ); return bitmap->Width();   }
	int  height()		{ FLASHASSERT( bitmap ); return bitmap->Height();  }

	void invalidate();	// Deletes the current palette and sets the entire buffer to
						// be invalid. (Be careful when you call this.)
	
	int xorg()					{ return m_xorg; }
  	SColorInfo* getSColorInfo() { return m_cinfo; }
	void setAllowPurge( BOOL );
	BOOL allowPurge()			{ return ( m_allowPurge != 0 ); }

	void bltToScreen(	NativePlayerWnd*,				// where to go get platform dependant info
						int x, int y,				// upper left target on screen
						int cx, int cy,
						int xSource,	int ySource	// where to start drawing from
					);	
	void clearScreen( NativePlayerWnd* );

	BOOL CreateScreenBits( NativePlayerWnd* native, SRECT* frame );	// pass frame in global screen coordinates

	BOOL LockBits() { return bitmap && bitmap->Bits != 0; }
	void UnlockBits() {}

	void FreeBits();

	BOOL BitsValid();

	void Flush()		{ if ( bitmap ) bitmap->Flush();  }

	NativeBitmap* bitmap;
  private:

	// The bitmap info
	BOOL m_inverted;	// set if we are using the bottom up DIB format

	int m_xorg;			// an offset for aligning the offscreen pixels to the screen pixels

	// Color table info
	SColorInfo* m_cinfo;

	// Flags the determine whether the destructor should free these objects
	BOOL m_allowPurge;

	int m_bmiSize;
};


SColorInfo* CreateColorInfo(SColorTable*);	// create a new color info
SColorInfo* GetColorInfo(SColorTable*);		// search the shared color infos for a match, otherwise create a new one

inline void AttachColorInfo(SColorInfo* cinfo) {cinfo->refCount++;}
void ReleaseColorInfo(SColorInfo*);

BOOL ColorTableEqual(SColorTable* c1, SColorTable* c2);
void ColorTableCopy(SColorTable* src, SColorTable* dst);

void SetStandardColors(SColorTable*);

extern const U8 colorRamp6[6];	 // the standard color ramp for our 8-bit color table

#endif

Version 1.0 of the Flash 4 Porting SDK                        Middlesoft, Inc.