// Borland C++ Builder
// Copyright (c) 1995, 2002 by Borland Software Corporation
// All rights reserved

// (DO NOT EDIT: machine generated header) 'EnDiGrph.pas' rev: 6.00

#ifndef EnDiGrphHPP
#define EnDiGrphHPP

#pragma delphiheader begin
#pragma option push -w-
#pragma option push -Vx
#include <EnMisc.hpp>	// Pascal unit
#include <Graphics.hpp>	// Pascal unit
#include <Controls.hpp>	// Pascal unit
#include <Classes.hpp>	// Pascal unit
#include <ExtCtrls.hpp>	// Pascal unit
#include <SysUtils.hpp>	// Pascal unit
#include <Windows.hpp>	// Pascal unit
#include <SysInit.hpp>	// Pascal unit
#include <System.hpp>	// Pascal unit

//-- user supplied -----------------------------------------------------------

namespace Endigrph
{
//-- type declarations -------------------------------------------------------
typedef tagRGBQUAD TRgbQuadArray[256];

#pragma pack(push, 1)
struct TBitmapInfo
{
	tagBITMAPINFOHEADER BmpHeader;
	tagRGBQUAD Palette[256];
} ;
#pragma pack(pop)

#pragma pack(push, 1)
struct TRgb
{
	Byte Blue;
	Byte Green;
	Byte Red;
	Byte Filler;
} ;
#pragma pack(pop)

typedef void __fastcall (*TSetPixelProc)(const Sysutils::PByteArray ScanLine, const int X, const int Value);

typedef int __fastcall (*TGetPixelFunc)(const Sysutils::PByteArray ScanLine, const int X);

#pragma pack(push, 1)
struct TIndexCacheEntry
{
	TRgb Color;
	short Index;
} ;
#pragma pack(pop)

class DELPHICLASS TRgbToPaletteConverter;
class PASCALIMPLEMENTATION TRgbToPaletteConverter : public System::TObject 
{
	typedef System::TObject inherited;
	
protected:
	Windows::TMaxLogPalette *pPalette;
	TIndexCacheEntry Cache[1020];
	int Hits;
	int Misses;
	
public:
	__fastcall TRgbToPaletteConverter(Windows::TMaxLogPalette &Palette);
	Word __fastcall GetIndex(TRgb Color);
public:
	#pragma option push -w-inl
	/* TObject.Destroy */ inline __fastcall virtual ~TRgbToPaletteConverter(void) { }
	#pragma option pop
	
};


#pragma option push -b-
enum TTransparentPixel { tpTopLeft, tpTopRight, tpBottomLeft, tpBottomRight, tpUseTransparentColor };
#pragma option pop

class DELPHICLASS TDibGraphic;
class PASCALIMPLEMENTATION TDibGraphic : public Graphics::TGraphic 
{
	typedef Graphics::TGraphic inherited;
	
protected:
	HBITMAP FBitmapHandle;
	HDC FDC;
	Byte *FBits;
	HPALETTE FPaletteHandle;
	Enmisc::TImageFormat FImageFormat;
	#pragma pack(push, 1)
	TBitmapInfo FBitmapInfo;
	#pragma pack(pop)
	
	#pragma pack(push, 1)
	Windows::TMaxLogPalette FPalette;
	#pragma pack(pop)
	
	int FScanLineSize;
	Graphics::TCanvas* FCanvas;
	int FImageToLoad;
	bool FMultiLoad;
	Classes::TList* FFrames;
	int FImageDelay;
	bool FAnimated;
	Extctrls::TTimer* FAnimationTimer;
	int FCurrentFrame;
	TGetPixelFunc FGetPixelFunc;
	TSetPixelProc FSetPixelProc;
	Classes::TNotifyEvent FAfterDraw;
	TRgbToPaletteConverter* FRgbToPaletteConverter;
	HBITMAP FOldBitmapHandle;
	Enmisc::TEnvisionProgressEvent FOnReadWriteProgress;
	TTransparentPixel FTransparentPixel;
	#pragma pack(push, 1)
	TRgb FTransparentColor;
	#pragma pack(pop)
	
	void __fastcall AnimateTimer(System::TObject* Sender);
	void __fastcall SetMultiLoad(const bool Multi);
	void __fastcall SetAnimated(const bool InAnimated);
	virtual bool __fastcall GetEmpty(void);
	virtual int __fastcall GetHeight(void);
	virtual int __fastcall GetWidth(void);
	virtual void __fastcall SetWidth(int Value);
	virtual void __fastcall SetHeight(int Value);
	Word __fastcall GetXDotsPerInch(void);
	Word __fastcall GetYDotsPerInch(void);
	void __fastcall SetXDotsPerInch(const Word XDpi);
	void __fastcall SetYDotsPerInch(const Word YDpi);
	Sysutils::PByteArray __fastcall GetScanLine(const int Y);
	TRgb __fastcall GetRGB(const int X, const int Y);
	void __fastcall SetRGB(const int X, const int Y, const TRgb RGB);
	Byte __fastcall GetPaletteIndex(const int X, const int Y);
	void __fastcall SetPaletteIndex(const int X, const int Y, Byte Index);
	HPALETTE __fastcall GetPaletteHandle(void);
	Windows::PMaxLogPalette __fastcall GetPalettePtr(void);
	TDibGraphic* __fastcall GetFrame(int FrameNo);
	int __fastcall GetFrameCount(void);
	void __fastcall SetCurrentFrame(int FrameNo);
	/* virtual class method */ virtual bool __fastcall CanRead(TMetaClass* vmt, const Classes::TStream* Stream);
	
public:
	__fastcall virtual TDibGraphic(void);
	__fastcall virtual ~TDibGraphic(void);
	virtual void __fastcall Assign(Classes::TPersistent* Source);
	virtual void __fastcall AssignTo(Classes::TPersistent* Dest);
	virtual void __fastcall Draw(Graphics::TCanvas* ACanvas, const Types::TRect &Rect);
	void __fastcall AssignFromBitmapHandle(const HBITMAP InBitmapHandle);
	void __fastcall AssignFromDIBHandle(const unsigned InDibHandle);
	virtual int __fastcall GetImageCount(const Classes::TStream* Stream);
	bool __fastcall IsEmpty(void);
	__property int ImageToLoad = {read=FImageToLoad, write=FImageToLoad, nodefault};
	virtual void __fastcall LoadFromStream(Classes::TStream* Stream);
	virtual void __fastcall SingleLoadFromStream(const Classes::TStream* Stream, const int ImageToLoad);
	virtual void __fastcall SaveToStream(Classes::TStream* Stream);
	virtual void __fastcall AppendToStream(Classes::TStream* Stream);
	void __fastcall AppendToFile(const AnsiString FileName);
	virtual void __fastcall LoadFromClipboardFormat(Word AFormat, unsigned AData, HPALETTE APalette);
	virtual void __fastcall SaveToClipboardFormat(Word &AFormat, unsigned &AData, HPALETTE &APalette);
	unsigned __fastcall AsDibHandle(void);
	virtual void __fastcall NewImage(const int Width, const int Height, const Enmisc::TImageFormat ImageFormat, Windows::PMaxLogPalette pPalette, const Word InXDotsPerInch, const Word InYDotsPerInch);
	void __fastcall Clear(void);
	void __fastcall Fill(const TRgb Color);
	__property Enmisc::TImageFormat ImageFormat = {read=FImageFormat, nodefault};
	__property Sysutils::PByteArray Bits = {read=FBits};
	__property Sysutils::PByteArray ScanLine[int Y] = {read=GetScanLine};
	__property int ScanLineSize = {read=FScanLineSize, nodefault};
	__property TRgb RGB[int X][int Y] = {read=GetRGB, write=SetRGB};
	__property Byte PaletteIndex[int X][int Y] = {read=GetPaletteIndex, write=SetPaletteIndex};
	__property TRgbToPaletteConverter* RgbToPaletteConverter = {read=FRgbToPaletteConverter};
	__property Windows::TMaxLogPalette Palette = {read=FPalette};
	__property Windows::PMaxLogPalette PalettePtr = {read=GetPalettePtr};
	__property HPALETTE PaletteHandle = {read=GetPaletteHandle, nodefault};
	__property HBITMAP BitmapHandle = {read=FBitmapHandle, nodefault};
	__property Word XDotsPerInch = {read=GetXDotsPerInch, write=SetXDotsPerInch, nodefault};
	__property Word YDotsPerInch = {read=GetYDotsPerInch, write=SetYDotsPerInch, nodefault};
	__property Graphics::TCanvas* Canvas = {read=FCanvas};
	__property HDC DC = {read=FDC, nodefault};
	__property TBitmapInfo BitmapInfo = {read=FBitmapInfo, write=FBitmapInfo};
	__property bool MultiLoad = {read=FMultiLoad, write=SetMultiLoad, nodefault};
	__property int ImageDelay = {read=FImageDelay, write=FImageDelay, nodefault};
	__property bool Animated = {read=FAnimated, write=SetAnimated, nodefault};
	__property TDibGraphic* Frames[int FrameNo] = {read=GetFrame};
	__property int FrameCount = {read=GetFrameCount, nodefault};
	__property int CurrentFrame = {read=FCurrentFrame, write=SetCurrentFrame, nodefault};
	__property TTransparentPixel TransparentPixel = {read=FTransparentPixel, write=FTransparentPixel, nodefault};
	__property TRgb TransparentColor = {read=FTransparentColor, write=FTransparentColor};
	__property Classes::TNotifyEvent AfterDraw = {read=FAfterDraw, write=FAfterDraw};
	__property Enmisc::TEnvisionProgressEvent OnReadWriteProgress = {read=FOnReadWriteProgress, write=FOnReadWriteProgress};
};


typedef TMetaClass*TDibGraphicClass;

//-- var, const, procedure ---------------------------------------------------
extern PACKAGE TSetPixelProc CSetPixelArray[6];
extern PACKAGE TGetPixelFunc CGetPixelArray[6];
extern PACKAGE TRgb CWhiteRgb;
extern PACKAGE TRgb CBlackRgb;
extern PACKAGE Windows::TMaxLogPalette *pBlackWhitePalette;
extern PACKAGE Windows::TMaxLogPalette *pGray16Palette;
extern PACKAGE Windows::TMaxLogPalette *pGray256Palette;
extern PACKAGE Windows::TMaxLogPalette *pColor16Palette;
extern PACKAGE Windows::TMaxLogPalette *pColor256Palette;
extern PACKAGE double ScreenGamma;
extern PACKAGE TRgb __fastcall MakeRgb(Byte Red, Byte Green, Byte Blue);
extern PACKAGE Word __fastcall GetBitDepth(const Enmisc::TImageFormat ImageFormat);
extern PACKAGE AnsiString __fastcall ImageFormatStr(const Enmisc::TImageFormat ImageFormat);
extern PACKAGE void __fastcall RegisterDibGraphic(const AnsiString Extension, const AnsiString Description, const void * DibGraphicClass);
extern PACKAGE TMetaClass* __fastcall GuessDibGraphicClass(const Classes::TStream* Stream);
extern PACKAGE TMetaClass* __fastcall FindDibGraphicClass(const AnsiString FileName);
extern PACKAGE TDibGraphic* __fastcall NewDibGraphic(const AnsiString FileName);
extern PACKAGE void __fastcall StretchBltTransparent(const HDC DestDC, const int DestX, const int DestY, const int DestWidth, const int DestHeight, const HDC SourceDC, const int SourceX, const int SourceY, const int SourceWidth, const int SourceHeight, const unsigned TransparentColor);
extern PACKAGE unsigned __fastcall EffectiveTransparentColor(const TDibGraphic* Graphic);
extern PACKAGE void __fastcall SwapRBOnScanLine(const Sysutils::PByteArray pScanLine, const int ScanLineSize);
extern PACKAGE bool __fastcall GraphicsIdentical(const TDibGraphic* Graphic1, const TDibGraphic* Graphic2);
extern PACKAGE void __fastcall SetPixelBc1(const Sysutils::PByteArray ScanLine, const int X, const int Value);
extern PACKAGE int __fastcall GetPixelBc1(const Sysutils::PByteArray ScanLine, const int X);
extern PACKAGE void __fastcall SetPixelBc4(const Sysutils::PByteArray ScanLine, const int X, const int Value);
extern PACKAGE int __fastcall GetPixelBc4(const Sysutils::PByteArray ScanLine, const int X);
extern PACKAGE void __fastcall SetPixelBc8(const Sysutils::PByteArray ScanLine, const int X, const int Value);
extern PACKAGE int __fastcall GetPixelBc8(const Sysutils::PByteArray ScanLine, const int X);
extern PACKAGE void __fastcall SetPixelBc24(const Sysutils::PByteArray ScanLine, const int X, const int Value);
extern PACKAGE int __fastcall GetPixelBc24(const Sysutils::PByteArray ScanLine, const int X);
extern PACKAGE void __fastcall SetBWPalette(Windows::TMaxLogPalette &Palette);
extern PACKAGE void __fastcall SetGray16Palette(Windows::TMaxLogPalette &Palette);
extern PACKAGE void __fastcall SetGray256Palette(Windows::TMaxLogPalette &Palette);
extern PACKAGE void __fastcall SetColor16Palette(Windows::TMaxLogPalette &Palette);
extern PACKAGE void __fastcall SetColor256Palette(Windows::TMaxLogPalette &Palette);

}	/* namespace Endigrph */
using namespace Endigrph;
#pragma option pop	// -w-
#pragma option pop	// -Vx

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// EnDiGrph
