unit PGraphic;
//
// PixelGraphicLibrary for Delphi 2 and Delphi 3
//
// Version: 1.0 beta 5 for Delphi 2 and Delphi 3
//
// Copyright © 1996-1998 Peter Beyersdorf, Germany
//
// See PGraphic.hlp for description, conditions of use, distribution,
// ordering/registering...
//
// Peter Beyersdorf          Phone: +49-511-559211
// Software-Development      Fax: +49-511-559213
// Engelsgrube 29
// D-23552 Luebeck           http://www.beyersdorf.com/
// Germany                   info@beyersdorf.com
//

interface

uses Windows, Messages, Graphics, SysUtils, Classes, Forms, ExtCtrls, Controls, Menus, DsgnIntf, Dialogs, CommDlg, StdCtrls, Consts, Clipbrd, comctrls, CommCtrl;

{$A+}

const
   WM_THREADREADY=WM_USER+0;    { for internal use }
   WM_THREADPROGRESS=WM_USER+1; { for internal use }
   WM_STARTTHREAD=WM_USER+3; { for internal use }

type

   TRGB = $00000000..$00FFFFFF;

   TBitCount = (
      bc1,        { 1 bit per pixel, 2 colors, palette based }
      bc4,        { 4 bits per pixel, max 16 colors, palette based }
      bc8,        { 8 bits per pixel, max 256 colors, palette based }
      bc24);      { 24 bits per pixel, true-color }

   TPaletteIdent = (
      pNone,
      pTrueColor,
      pUnknown,
      pBlackWhite,
      pSysGray4,
      pSys16,
      pGray4,
      pGray16,
      pGray236,
      pGray256,
      pSpecial125,
      pSpecial216,
      pSpecial252,
      pOptimized252Sys16,
      pSource);

   TPaletteKind=pNone..pSpecial252;
   TPalette8BitSys8BitGraphic=pBlackWhite..pSource;
   TPalette8BitSys24BitGraphic=pBlackWhite..pOptimized252Sys16;

   TStretchMode =(
      smFast,
      smMedium,
      smPrecise);

   TRotateMode =(
      rmFast,
      rmPrecise);

   TPGProgressEvent = procedure (Sender: TObject; Step, Max:Integer; var Abort: Boolean) of object;
   TPGSetCursorEvent = procedure (Sender: TObject; var CursorHandle: HCursor) of object;

   EPixelGraphic = class(Exception)
   end;
   EPGXYIndexOutOfRange = class(EPixelGraphic)
   end;
   EPGNoPalette = class(EPixelGraphic)
   end;
   EPGInvalidPaletteIndex = class(EPixelGraphic)
   end;
   EPGEmpty = class(EPixelGraphic)
   end;
   EPGCanWriteResolutionsEmpty = class(EPixelGraphic)
   end;
   EPGCannotWriteColorRes = class(EPixelGraphic)
   end;
   EPGFileFormatWritersEmpty = class(EPixelGraphic)
   end;
   EPGUnknownExtension = class(EPixelGraphic)
   end;
   EPGUnknownFileFormat = class(EPixelGraphic)
   end;
   EPGUnknownClipboardFormat = class(EPixelGraphic)
   end;
   EPGInvalidTempFile = class(EPixelGraphic)
   end;
   EPGBMPFileFormatReader = class(EPixelGraphic)
   end;
   EPGJPGFileFormatReaderWriter = class(EPixelGraphic)
   end;
   EPGPNGFileFormatReaderWriter = class(EPixelGraphic)
   end;
   EPGPCXFileFormatReader = class(EPixelGraphic)
   end;
   EPGPxMFileFormatReader = class(EPixelGraphic)
   end;
   EPGPxMFileFormatWriter = class(EPixelGraphic)
   end;
   EPGTGAFileFormatReader = class(EPixelGraphic)
   end;
   EPGTIFFileFormatReader = class(EPixelGraphic)
   end;
   EPGTIFFileFormatWriter = class(EPixelGraphic)
   end;
   EPGInvalidBitCountNum = class(EPixelGraphic)
   end;
   EPGInvalidSize = class(EPixelGraphic)
   end;
   EPGFilter = class(EPixelGraphic)
   end;
   EPGSaturationHue = class(EPixelGraphic)
   end;
   EPGConvFilter = class(EPixelGraphic)
   end;

   TPGFilterClass=class(TObject)
   end;

   TPGWarningAction=(
      pgwaIgnore,
      pgwaOKBox,
      pgwaOKCancelBox,
      pgwaRaise);

   TPixelGraphic = class(TGraphic)
   private
      FBackGroundBits: TRGB;
      FBitCount: TBitCount;
      FBitmapBytes: Pointer;
      FBitmapInfo: PBitmapInfo;
      FCanvas: TCanvas;
      FDither: Boolean;
      FDitherErrorLimit: Byte;
      FDitherErrorLimitAuto: Boolean;
      FDitherErrorLimits: Pointer;
      FDitherErrorLimitSoft: Boolean;
      FDitherErrors0: Pointer;
      FDitherErrors1: Pointer;
      FFastUnknownPalette: Boolean;
      FFastRead: Boolean;
      FHeight: Integer;
      FIgnorePalette: Boolean;
      FIsGrayScale: Boolean;
      FGamma: Extended;
      FNumBitmapBytes: Integer;
      FNumPaletteEntries: Integer;
      FNumScanLineBytes: Integer;
      FOnChange: TNotifyEvent;
      FOnProgress: TPGProgressEvent;
      FOnProgressEnd: TNotifyEvent;
      FOnProgressStart: TNotifyEvent;
      FPalette: HPalette;
      FPaletteAnimation: Boolean;
      FPaletteCacheArray: Pointer;
      FPaletteCacheArrayDirty: Boolean;
      FPaletteCacheColor: TRGB;
      FPaletteCacheDirty: Boolean;
      FPaletteCacheFlagArray: Pointer;
      FPaletteCacheIndex: Integer;
      FPaletteDirty: Boolean;
      FPaletteEntries: Pointer;
      FPaletteKind: TPaletteKind;
      FRGBWeighting: Boolean;
      FRotateMode: TRotateMode;
      FStretchMode: TStretchMode;
      FTransparent: Boolean;
      FTransparentBits: Integer;
      FUpdateCount: Integer;
      FReadWarningAction: TPGWarningAction;
      FRaiseEPGXYIndexOutOfRange: Boolean;
      FSaveColorResWarningAction: TPGWarningAction;
      FGDIFlushNeeded: Boolean;
      FWidth: Integer;
      FHandle: HBitmap;
   protected
      function CalcStreamSize: Integer;
      procedure DitherEnd;
      procedure DitherNextLine;
      procedure DitherSetNextPixel(XD, YD, RD, GD, BD: Integer);
      procedure DitherStart;
      procedure FreeContext;
      function GetAverageColor: TRGB;
      function GetBackGroundBits: Integer;
      function GetBackGroundColor: TRGB;
      function GetBitCount: TBitCount;
      function GetBitCountNum: Integer;
      function GetBitmapBytes: Pointer;
      function GetBits(X, Y: Integer): Integer;
      function GetCanvas: TCanvas;
      function GetDither: Boolean;
      function GetDitherErrorLimit: Byte;
      function GetDitherErrorLimitAuto: Boolean;
      function GetDitherErrorLimitSoft: Boolean;
      function GetEmpty: Boolean; override;
      function GetFastRead: Boolean;
      function GetFastUnknownPalette: Boolean;
      function GetGamma: Extended;
      function GetHandle: HBitmap;
      function GetHeight: Integer; override;
      function GetMaxNumPaletteEntries: Integer;
      function GetNumBitmapBytes: Integer;
      function GetNumPaletteEntries: Integer;
      function GetNumScanlineBytes: Integer;
      function GetOnChange: TNotifyEvent;
      function GetOnProgress: TPGProgressEvent;
      function GetOnProgressEnd: TNotifyEvent;
      function GetOnProgressStart: TNotifyEvent;
      function GetPalette: HPalette; {$IFNDEF VER100}virtual;{$ENDIF}{$IFDEF VER100}override;{$ENDIF}
      function GetPaletteAnimation: Boolean;
      function GetPaletteEntry(aIndex: Integer): TRGB;
      function GetPaletteKind: TPaletteKind;
      function GetPixel(X, Y: Integer): TRGB;
      function GetRaiseEPGXYIndexOutOfRange: Boolean;
      function GetRGBWeighting: Boolean;
      function GetReadWarningAction: TPGWarningAction;
      function GetRotateMode: TRotateMode;
      function GetSaveColorResWarningAction: TPGWarningAction;
      function GetScanLineBytes(y: Integer): Pointer;
      function GetStretchMode: TStretchMode;
      function GetTransparent: Boolean; {$IFDEF VER100}override;{$ENDIF}
      function GetTransparentBits: Integer;
      function GetWidth: Integer; override;
      procedure IdentifyPalette;
      procedure SetPaletteCacheArrayDirty; virtual;
      procedure ReadData(Stream: TStream); override;
      procedure ReadStreamBMPWithoutBitmapFileHeader(Stream: TStream; OS2: Boolean);
      procedure SaveToStreamFormatInternal(CreateFileStream: Boolean; FileName: string; Stream: TStream; Extension: string);
      procedure SetBackGroundBits(Value: Integer);
      procedure SetBackGroundColor(Value: TRGB);
      procedure SetBitCount(Value: TBitCount);
      procedure SetBitCountNum(Value: Integer);
      procedure SetBits(X, Y: Integer; Value: Integer);
      procedure SetDither(Value: Boolean);
      procedure SetDitherErrorLimit(Value: Byte);
      procedure SetDitherErrorLimitAuto(Value: Boolean);
      procedure SetDitherErrorLimitSoft(Value: Boolean);
      procedure SetFastUnknownPalette(Value: Boolean); virtual;
      procedure SetFastRead(Value: Boolean);
      procedure SetGamma(Value: Extended);
      procedure SetHeight(Value: Integer); override;
      procedure SetNumPaletteEntries(Value: Integer); virtual;
      procedure SetOnChange(Value: TNotifyEvent);
      procedure SetOnProgressStart(Value: TNotifyEvent);
      procedure SetOnProgress(Value: TPGProgressEvent);
      procedure SetOnProgressEnd(Value: TNotifyEvent);
      procedure SetPaletteAnimation(Value: Boolean);
      procedure SetPaletteKind(Value: TPaletteKind); virtual;
      procedure SetPaletteEntry(aIndex: Integer; Value: TRGB); virtual;
      procedure SetPixel(X, Y: Integer; Value: TRGB);
      procedure SetRaiseEPGXYIndexOutOfRange(Value: Boolean);
      procedure SetReadWarningAction(Value: TPGWarningAction);
      procedure SetRGBWeighting(Value: Boolean); virtual;
      procedure SetRotateMode(Value: TRotateMode);
      procedure SetSaveColorResWarningAction(Value: TPGWarningAction);
      procedure SetStretchMode(Value: TStretchMode);
      procedure SetTransparent(Value: Boolean); {$IFDEF VER100}override;{$ENDIF}
      procedure SetTransparentBits(Value: Integer);
      procedure SetWidth(Value: Integer); override;
      procedure WriteData(Stream: TStream); override;
      procedure WriteStreamBMPWithoutBitmapFileHeader(Stream: TStream);
   public
      constructor Create; override;
      destructor Destroy; override;
      procedure AddBorder(Ellipse: Boolean; BorderWidth: Integer; BorderColor: TRGB; PGSrc: TPixelGraphic);
      property AverageColor: TRGB read GetAverageColor;
      procedure Assign(Source: TPersistent); override;
      property BackGroundBits: Integer read GetBackGroundBits write SetBackGroundBits;
      property BackGroundColor: TRGB read GetBackGroundColor write SetBackGroundColor;
      procedure BeginUpdate;
      property BitCount: TBitCount read GetBitCount write SetBitCount;
      property BitCountNum: Integer read GetBitCountNum;
      property BitmapBytes: Pointer read GetBitmapBytes;
      property Bits[X, Y: Integer]: Integer read GetBits write SetBits;
      property Canvas: TCanvas read GetCanvas;
      procedure Changed(Sender: TObject); {$IFDEF VER100} override; {$ENDIF}
      procedure CopyPalette(PGSrc: TPixelGraphic);
      procedure CreateOptimizedPalette(PGSrc: TPixelGraphic; MaxNumEntries: Integer; IncludeSys16: Boolean);
      property Dither: Boolean read GetDither write SetDither;
      property DitherErrorLimit: Byte read GetDitherErrorLimit write SetDitherErrorLimit;
      property DitherErrorLimitAuto: Boolean read GetDitherErrorLimitAuto write SetDitherErrorLimitAuto;
      property DitherErrorLimitSoft: Boolean read GetDitherErrorLimitSoft write SetDitherErrorLimitSoft;
      procedure Draw(aCanvas: TCanvas; const Rect: TRect); override;
      procedure DrawOnDC(aDC: HDC; const Rect: TRect; Rop: Integer; ForceBackground: Boolean);
      procedure EndUpdate;
      procedure Erase;
      property FastRead: Boolean read GetFastRead write SetFastRead;
      property FastUnknownPalette: Boolean read GetFastUnknownPalette write SetFastUnknownPalette;
      property Gamma: Extended read GetGamma write SetGamma;
      function GetNearestPaletteIndex(aColor: TRGB): Integer; virtual;
      property Handle: HBitmap read GetHandle;
      procedure LoadFromBitmap(aBitmap: TBitmap);
      procedure LoadFromClipboard;
      procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle; APalette: HPalette); override;
      procedure LoadFromFile(const FileName: string); override;
      procedure LoadFromFileIndex(const FileName: string; Index: Integer);
      procedure LoadFromResourceID(Instance: THandle; ResID: Integer);
      procedure LoadFromResourceName(Instance: THandle; const ResName: String);
      procedure LoadFromStream(Stream: TStream); override;
      property MaxNumPaletteEntries: Integer read GetMaxNumPaletteEntries;
      property NumBitmapBytes: Integer read GetNumBitmapBytes;
      property NumPaletteEntries: Integer read GetNumPaletteEntries write SetNumPaletteEntries;
      property NumScanLineBytes: Integer read GetNumScanlineBytes;
      property ReadWarningAction: TPGWarningAction read GetReadWarningAction write SetReadWarningAction;
      property SaveColorResWarningAction: TPGWarningAction read GetSaveColorResWarningAction write SetSaveColorResWarningAction;
      property OnChange: TNotifyEvent read GetOnChange write SetOnChange;
      property OnProgress: TPGProgressEvent read GetOnProgress write SetOnProgress;
      property OnProgressEnd: TNotifyEvent read GetOnProgressEnd write SetOnProgressEnd;
      property OnProgressStart: TNotifyEvent read GetOnProgressStart write SetOnProgressStart;
      property Palette: HPalette read GetPalette;
      property PaletteAnimation: Boolean read GetPaletteAnimation write SetPaletteAnimation;
      property PaletteEntries[aIndex: Integer]:TRGB read GetPaletteEntry write SetPaletteEntry;
      property PaletteKind: TPaletteKind read GetPaletteKind write SetPaletteKind;
      property Pixels[X, Y: Integer]: TRGB read GetPixel write SetPixel;
      procedure Print(ShowDialog: Boolean; OrientationBestFit: Boolean; AOwner: TComponent);
      property RaiseEPGXYIndexOutOfRange: Boolean read GetRaiseEPGXYIndexOutOfRange write SetRaiseEPGXYIndexOutOfRange;
      property RGBWeighting: Boolean read GetRGBWeighting write SetRGBWeighting;
      procedure SaveToBitmap(aBitmap: TBitmap);
      procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; var APalette: HPalette); override;
      procedure SaveToClipboard;
      procedure SaveToFile(const FileName: string); override;
      procedure SaveToStream(Stream: TStream); override;
      procedure SaveToStreamFormat(Stream: TStream; Extension: string); virtual;
      procedure SetDimension(Width, Height: Integer; BitCount: TBitCount);
      procedure StretchDraw(PGSrc: TPixelGraphic);
      procedure StretchDrawRect(XOrgDest, YOrgDest, WidthDest, HeightDest, XOrgSrc, YOrgSrc, WidthSrc, HeightSrc: Integer; PGSrc: TPixelGraphic);
      procedure DrawRect(XOrgDest, YOrgDest, nWidth, nHeight, XOrgSrc, YOrgSrc: Integer; PGSrc: TPixelGraphic);
      property ScanLineBytes[y: Integer]: Pointer read GetScanlineBytes;
      property StretchMode: TStretchMode read GetStretchMode write SetStretchMode;
      procedure ReadFromTempFile(TempFileName: string);
      procedure ReadStreamFormat(Stream: TStream; Extension: string);
      procedure ReadStreamFormatIndex(Stream: TStream; Extension: string; Index: Integer);
      property RotateMode: TRotateMode read GetRotateMode write SetRotateMode;
      procedure RotateRect(Angle: Extended; XCenterDest, YCenterDest, XCenterSrc, YCenterSrc, XOrgSrc, YOrgSrc, WidthSrc, HeightSrc: Integer; PGSrc: TPixelGraphic);
      procedure Rotate(Angle: Extended; AutoFit: Boolean; PGSrc: TPixelGraphic);
      property Transparent: Boolean read GetTransparent write SetTransparent;
      { Note: Not supported in this version of the PixelGraphicLibrary. It might
        be supported in future versions. So FileFormatReaders should set this
        property if transparency information is stored in the file format.
        FileFormatWriters should write the transparency data stored in this
        field to the file if transparency is supported by the file format.
        This property is only included for compatibility of FileFormatReaders
        and FileFormatWriters with possible future versions. Note it is not
        said that the PixelGraphicLibrary will ever support transparency in
        TPixelGraphic. }
      property TransparentBits: Integer read GetTransparentBits write SetTransparentBits;
      { Note: Not supported in this version of the PixelGraphicLibrary. It might
        be supported in future versions. So FileFormatReaders should set this
        property if transparency information is stored in the file format.
        FileFormatWriters should write the transparency data stored in this
        field to the file if transparency is supported by the file format.
        This property is only included for compatibility of FileFormatReaders
        and FileFormatWriters with possible future versions. Note it is not
        said that the PixelGraphicLibrary will ever support transparency in
        TPixelGraphic. }
      procedure FlipHorizontal;
      procedure FlipVertical;
      procedure ApplyFilter(aFilter: TPGFilterClass; PGSrc: TPixelGraphic);
      procedure WriteToTempFile(TempFileName: string);
   end;

   TStretch = (
      sNeverKAR,
      sAlways,
      sAlwaysKAR,
      sShrink,
      sShrinkKAR,
      sEnlarge,
      sEnlargeKAR,
      sAlwaysLongerEdgeKAR,
      sShrinkLongerEdgeKAR,
      sEnlargeShrinkLongerEdgeKAR,
      sEnlargeLongerEdgeKAR,
      sZoomKAR);

   TActionMode = (
      amMoveImage,
      amMoveResizeCreateSelection,
      amMoveSelection,
      amMoveSelectionMoveImage,
      amCreateSelection,
      amNone);

   TCurrentAction = (
      caNone,
      caImageMoving,
      caSelectionMoving,
      caSelectionResizingInsideSelection,
      caSelectionResizingTopLeftPad,
      caSelectionResizingTopCenteredPad,
      caSelectionResizingTopRightPad,
      caSelectionResizingLeftCenteredPad,
      caSelectionResizingRightCenteredPad,
      caSelectionResizingBottomLeftPad,
      caSelectionResizingBottomCenteredPad,
      caSelectionResizingBottomRightPad);

   TTiling = (
      tNone,
      tRepeat,
      tMirrorHorizontal,
      tMirrorVertical,
      tMirror);

   TPGINewAutoSizeEvent = procedure(Sender: TObject; PGImageWidth, PGImageHeight: Integer) of object;

   TPGImage = class(TScrollBox)
   private
      FActionMode: TActionMode;
      FActionPoint1: TPoint;
      FActionPoint2: TPoint;
      FAllow24BitStretch: Boolean;
      FAutoSize: Boolean;
      FAutoSizeMaxHeight: Integer;
      FAutoSizeMinHeight: Integer;
      FAutoSizeMaxWidth: Integer;
      FAutoSizeMinWidth: Integer;
      FBackGroundColor: TRGB;
      FCanvas: TCanvas;
      FCenter: Boolean;
      FCreatePaintPGThread: Pointer;
      FCurrentAction: TCurrentAction;
      FDither: Boolean;
      FDitherErrorLimit: Byte;
      FDitherErrorLimitAuto: Boolean;
      FDitherErrorLimitSoft: Boolean;
      FFileName: string;
      FFlipHorizontal: Boolean;
      FFlipVertical: Boolean;
      FGraphicHeight: Integer;
      FGraphicWidth: Integer;
      FKeepOldPaintPixelGraphic: Boolean;
      FLockPaint: Boolean;
      FOnNewAutoSize: TPGINewAutoSizeEvent;
      FOnPaint: TNotifyEvent;
      FOnPainting: TNotifyEvent;
      FOnPixelGraphicChange: TNotifyEvent;
      FOnPixelGraphicProgress: TPGProgressEvent;
      FOnPixelGraphicProgressEnd: TNotifyEvent;
      FOnPixelGraphicProgressStart: TNotifyEvent;
      FOnSelectionChange: TNotifyEvent;
      FOnSelectionMade: TNotifyEvent;
      FOnSetCursor: TPGSetCursorEvent;
      FOnZoomFactorChange: TNotifyEvent;
      FPicBoxOnSetCursor: TPGSetCursorEvent;
      FPaintPixelGraphic: TPixelGraphic;
      FPaintPixelGraphicDirty: Boolean;
      FPaintPixelGraphicHeight: Integer;
      FPaintPixelGraphicWidth: Integer;
      FPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      FPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      FPicBox: TPaintBox;
      FPicBoxFrameColor: TColor;
      FPixelGraphic: TPixelGraphic;
      FProgress5Clocks: Boolean;
      FProgressClockBkColor: TColor;
      FProgressClockLineColor: TColor;
      FProgressClockVisible: Boolean;
      FProgressPassNum: Integer;
      FProgressPassesNum: Integer;
      FProgressPercent: Integer;
      FRGBWeighting: Boolean;
      FReadWarningAction: TPGWarningAction;
      FRearrangeAlways: Boolean;
      FReduceOnLoad: Boolean;
      FSelectionBrushes: array [0 .. 7] of TBrush;
      FSelectionBrushBitmaps: array [0 .. 7] of TBitmap;
      FSelection: Boolean;
      FSelectionBrushIndex: Byte;
      FSelectionColor1: TColor;
      FSelectionColor2: TColor;
      FSelectionHeight: Integer;
      FSelectionLeft: Integer;
      FSelectionStartPoint: TPoint;
      FSelectionTimer: TTimer;
      FSelectionScrollTimer: TTimer;
      FSelectionTop: Integer;
      FSelectionWidth: Integer;
      FShowHourGlass: Boolean;
      FStretch: TStretch;
      FStretchMode: TStretchMode;
      FUseThread: Boolean;
      FTiling: TTiling;
      FSaveColorResWarningAction: TPGWarningAction;
      FZoomFactor: Extended;
      FUsedZoomFactor: Extended;
      procedure WMDisplayChange(var aMessage: TMessage); message WM_DISPLAYCHANGE;
      procedure WMPaint(var aMessage: TWMPaint); message WM_PAINT;
      procedure WMThreadProgress(var aMessage: TMessage); message WM_THREADPROGRESS;
      procedure WMThreadReady(var aMessage: TMessage); message WM_THREADREADY;
   protected
      procedure AssignEvents(aPixelGraphic: TPixelGraphic; AssignOnChange: Boolean);
      procedure ForcePalette;
      function GetActionMode: TActionMode;
      function GetAllow24BitStretch: Boolean;
      function GetAutoSize: Boolean;
      function GetAutoSizeMaxHeight: Integer;
      function GetAutoSizeMinHeight: Integer;
      function GetAutoSizeMaxWidth: Integer;
      function GetAutoSizeMinWidth: Integer;
      function GetBackGroundColor: TRGB;
      function GetBorderWidth: Integer;
      function GetBorderHeight: Integer;
      function GetCanvas: TCanvas;
      function GetCenter: Boolean;
      function GetCurrentAction: TCurrentAction;
      function GetDither: Boolean;
      function GetDitherErrorLimit: Byte;
      function GetDitherErrorLimitAuto: Boolean;
      function GetDitherErrorLimitSoft: Boolean;
      function GetEmpty: Boolean;
      function GetFileName: string;
      function GetFlipHorizontal: Boolean;
      function GetFlipVertical: Boolean;
      function GetGraphicHeight: Integer;
      function GetGraphicWidth: Integer;
      function GetKeepOldPaintPixelGraphic: Boolean;
      function GetPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      function GetPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      function GetOnNewAutoSize: TPGINewAutoSizeEvent;
      function GetOnPaint: TNotifyEvent;
      function GetOnPainting: TNotifyEvent;
      function GetOnPixelGraphicChange: TNotifyEvent;
      function GetOnPixelGraphicProgress: TPGProgressEvent;
      function GetOnPixelGraphicProgressEnd: TNotifyEvent;
      function GetOnPixelGraphicProgressStart: TNotifyEvent;
      function GetOnSelectionChange: TNotifyEvent;
      function GetOnSelectionMade: TNotifyEvent;
      function GetOnSetCursor: TPGSetCursorEvent;
      function GetOnZoomFactorChange: TNotifyEvent;
      function GetPaintPixelGraphic: TPixelGraphic;
      function GetPicBox: TPaintBox;
      function GetPicBoxColor: TColor;
      function GetPicBoxCursor: TCursor;
      function GetPicBoxDragCursor: TCursor;
      function GetPicBoxDragMode: TDragMode;
      function GetPicBoxFrameColor: TColor;
      function GetPicBoxHint: string;
      function GetPicBoxParentColor: Boolean;
      function GetPicBoxParentShowHint: Boolean;
      function GetPicBoxPopupMenu: TPopupMenu;
      function GetPicBoxShowHint: Boolean;
      function GetPicBoxTag: LongInt;
      function GetPicBoxOnClick: TNotifyEvent;
      function GetPicBoxOnDblClick: TNotifyEvent;
      function GetPicBoxOnDragDrop: TDragDropEvent;
      function GetPicBoxOnDragOver: TDragOverEvent;
      function GetPicBoxOnEndDrag: TEndDragEvent;
      function GetPicBoxOnMouseDown: TMouseEvent;
      function GetPicBoxOnMouseMove: TMouseMoveEvent;
      function GetPicBoxOnMouseUp: TMouseEvent;
      function GetPicBoxOnPaint: TNotifyEvent;
      function GetPicBoxOnSetCursor: TPGSetCursorEvent;
      function GetPicBoxOnStartDrag: TStartDragEvent;
      function GetProgress5Clocks: Boolean;
      function GetProgressClockBkColor: TColor;
      function GetProgressClockLineColor: TColor;
      function GetProgressClockVisible: Boolean;
      function GetRGBWeighting: Boolean;
      function GetReadWarningAction: TPGWarningAction;
      function GetRearrangeAlways: Boolean;
      function GetReduceOnLoad: Boolean;
      procedure GetRidOfPaintPixelGraphicOrMarkItDirty;
      function GetSaveColorResWarningAction: TPGWarningAction;
      function GetSelection: Boolean;
      function GetSelectionColor1: TColor;
      function GetSelectionColor2: TColor;
      function GetSelectionLeft: Integer;
      function GetSelectionTop: Integer;
      function GetSelectionWidth: Integer;
      function GetSelectionHeight: Integer;
      function GetSelectionBoundsRect: TRect;
      function GetSelectionBoundsRectPic: TRect;
      function GetScrollBarHeight: Integer;
      function GetScrollBarWidth: Integer;
      function GetShowHourGlass: Boolean;
      function GetStretch: TStretch;
      function GetStretchMode: TStretchMode;
      function GetTiling: TTiling;
      function GetUseThread: Boolean;
      function GetUsedZoomFactor: Extended;
      function GetZoomFactor: Extended;
      procedure MouseDownPic(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
      procedure MouseMovePic(Sender: TObject; Shift: TShiftState; X, Y: Integer);
      procedure MouseUpPic(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
      procedure NilEvents(aPixelGraphic: TPixelGraphic);
      procedure Paint; virtual;
      procedure PaintPic(Sender: TObject);
      function PaintPixelGraphicNeeded: Boolean;
      procedure PaintSelection;
      procedure PaintThreadProgressInfo;
      procedure PaintWindow(DC: HDC); override;
      procedure PixelGraphicChange(Sender: TObject);
      procedure PixelGraphicProgress(Sender: TObject; Step, Max:Integer; var Abort: Boolean);
      procedure PixelGraphicProgressEnd(Sender: TObject);
      procedure PixelGraphicProgressStart(Sender: TObject);
      procedure SelectionBrushesNeeded;
      procedure SelectionTimerTimer(Sender: TObject);
      procedure SelectionScrollTimerTimer(Sender: TObject);
      procedure SetActionMode(Value: TActionMode);
      procedure SetAllow24BitStretch(Value: Boolean);
      procedure SetAutoSize(Value: Boolean);
      procedure SetAutoSizeMaxHeight(Value: Integer);
      procedure SetAutoSizeMinHeight(Value: Integer);
      procedure SetAutoSizeMaxWidth(Value: Integer);
      procedure SetAutoSizeMinWidth(Value: Integer);
      procedure SetBackGroundColor(Value: TRGB);
      procedure SetCenter(Value: Boolean);
      procedure SetDither(Value: Boolean);
      procedure SetDitherErrorLimit(value: Byte);
      procedure SetDitherErrorLimitAuto(value: Boolean);
      procedure SetDitherErrorLimitSoft(value: Boolean);
      procedure SetFileName(Value: string);
      procedure SetFlipHorizontal(Value: Boolean);
      procedure SetFlipVertical(Value: Boolean);
      procedure SetKeepOldPaintPixelGraphic(Value: Boolean);
      procedure SetOnNewAutoSize(Value: TPGINewAutoSizeEvent);
      procedure SetOnPaint(Value: TNotifyEvent);
      procedure SetOnPainting(Value: TNotifyEvent);
      procedure SetOnPixelGraphicChange(Value: TNotifyEvent);
      procedure SetOnPixelGraphicProgress(Value: TPGProgressEvent);
      procedure SetOnPixelGraphicProgressEnd(Value: TNotifyEvent);
      procedure SetOnPixelGraphicProgressStart(Value: TNotifyEvent);
      procedure SetOnSelectionChange(Value: TNotifyEvent);
      procedure SetOnSelectionMade(Value: TNotifyEvent);
      procedure SetOnSetCursor(Value: TPGSetCursorEvent);
      procedure SetOnZoomFactorChange(Value: TNotifyEvent);
      procedure SetPalette8BitSys24BitGraphic(Value: TPalette8BitSys24BitGraphic);
      procedure SetPalette8BitSys8BitGraphic(Value: TPalette8BitSys8BitGraphic);
      procedure SetPicBoxPos(ForceRearrange: Boolean);
      procedure SetPicBoxColor(Value: TColor);
      procedure SetPicBoxCursor(Value: TCursor);
      procedure SetPicBoxDragCursor(Value: TCursor);
      procedure SetPicBoxDragMode(Value: TDragMode);
      procedure SetPicBoxFrameColor(Value: TColor);
      procedure SetPicBoxHint(Value: string);
      procedure SetPicBoxParentColor(Value: Boolean);
      procedure SetPicBoxParentShowHint(Value: Boolean);
      procedure SetPicBoxPopupMenu(Value: TPopupMenu);
      procedure SetPicBoxShowHint(Value: Boolean);
      procedure SetPicBoxTag(Value: LongInt);
      procedure SetPicBoxOnClick(Value: TNotifyEvent);
      procedure SetPicBoxOnDblClick(Value: TNotifyEvent);
      procedure SetPicBoxOnDragDrop(Value: TDragDropEvent);
      procedure SetPicBoxOnDragOver(Value: TDragOverEvent);
      procedure SetPicBoxOnEndDrag(Value: TEndDragEvent);
      procedure SetPicBoxOnMouseDown(Value: TMouseEvent);
      procedure SetPicBoxOnMouseMove(Value: TMouseMoveEvent);
      procedure SetPicBoxOnMouseUp(Value: TMouseEvent);
      procedure SetPicBoxOnPaint(Value: TNotifyEvent);
      procedure SetPicBoxOnSetCursor(Value: TPGSetCursorEvent);
      procedure SetPicBoxOnStartDrag(Value: TStartDragEvent);
      procedure SetProgress5Clocks(Value: Boolean);
      procedure SetProgressClockBkColor(Value: TColor);
      procedure SetProgressClockLineColor(Value: TColor);
      procedure SetProgressClockVisible(Value: Boolean);
      procedure SetReadWarningAction(Value: TPGWarningAction);
      procedure SetRearrangeAlways(Value: Boolean);
      procedure SetReduceOnLoad(Value: Boolean);
      procedure SetRGBWeighting(Value: Boolean);
      procedure SetSaveColorResWarningAction(Value: TPGWarningAction);
      procedure SetSelection(Value: Boolean);
      procedure SetSelectionBoundsRect(Value: TRect);
      procedure SetSelectionColor1(Value: TColor);
      procedure SetSelectionColor2(Value: TColor);
      procedure SetSelectionLeft(Value: Integer);
      procedure SetSelectionTop(Value: Integer);
      procedure SetSelectionHeight(Value: Integer);
      procedure SetSelectionWidth(Value: Integer);
      procedure SetSelectionWithPointInternalPic(x, y: Integer);
      procedure SetShowHourGlass(Value: Boolean);
      procedure SetStretch(Value: TStretch);
      procedure SetStretchMode(Value: TStretchMode);
      procedure SetTiling(Value: TTiling);
      procedure SetUseThread(Value: Boolean);
      procedure SetZoomFactor(Value: Extended);
      procedure ThreadProgress(newProgressPassNum, newProgressPercent: Integer);
      procedure ThreadReady(newPaintPixelGraphic: TPixelGraphic);
      procedure WMEraseBkgnd(var aMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
      procedure WMSetCursor(var aMessage: TWMSetCursor); message WM_SETCURSOR;
   public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
      property Canvas: TCanvas read GetCanvas;
      property Empty: Boolean read GetEmpty;
      function GetPalette: HPALETTE; override;
      function GivePixelGraphic: TPixelGraphic;
      function GivePixelGraphicCopy: TPixelGraphic;
      property GraphicHeight: Integer read GetGraphicHeight; {graphic coordinates}
      function GraphicToPicPoint(aPoint: TPoint): TPoint;
      function GraphicToPicX(X: Integer): Integer;
      function GraphicToPicY(Y: Integer): Integer;
      property GraphicWidth: Integer read GetGraphicWidth; {graphic coordinates}
      procedure Invalidate; override;
      function LendPixelGraphic: TPixelGraphic;
      function LendNoModifyPixelGraphic: TPixelGraphic;
      procedure LoadFromFile(const FileName: string);
      procedure LoadFromFileIndex(const FileName: string; Index: Integer);
      procedure SaveToFile(const FileName: string); virtual;
      property PaintPixelGraphic: TPixelGraphic read GetPaintPixelGraphic;
      property PicBox: TPaintBox read GetPicBox;
      function PicToGraphicPoint(aPoint: TPoint): TPoint;
      function PicToGraphicX(X: Integer): Integer;
      function PicToGraphicY(Y: Integer): Integer;
      function PointInPic(aPoint: TPoint): Boolean; {TPGImage client coordinates}
      function PointInSelection(aPoint: TPoint): Boolean; {graphic coordinates}
      property CurrentAction: TCurrentAction read GetCurrentAction;
      procedure Rearrange;
      property SelectionBoundsRect: TRect read GetSelectionBoundsRect write SetSelectionBoundsRect; {graphic coordinates; It's a BoundsRect, that means TopLeft Point does belong to the Selection, but BottomRight doesn't!}
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure SetSelectionBounds(ALeft, ATop, AWidth, AHeight: Integer); {graphic coordinates}
      function SwapPixelGraphic(Value: TPixelGraphic): TPixelGraphic;
      procedure TakePixelGraphic(Value: TPixelGraphic);
      procedure TakePixelGraphicCopy(Value: TPixelGraphic);
      property UsedZoomFactor: Extended read GetUsedZoomFactor;
      property PixelGraphic: TPixelGraphic read LendPixelGraphic write TakePixelGraphic;
   published
      property ActionMode: TActionMode read GetActionMode write SetActionMode default amMoveImage;
      property Align;
      property Allow24BitStretch: Boolean read GetAllow24BitStretch write SetAllow24BitStretch default false;
      property AutoScroll;
      property AutoSize: Boolean read GetAutoSize write SetAutoSize default false;
      property AutoSizeMaxHeight: Integer read GetAutoSizeMaxHeight write SetAutoSizeMaxHeight default MaxInt;
      property AutoSizeMinHeight: Integer read GetAutoSizeMinHeight write SetAutoSizeMinHeight default 0;
      property AutoSizeMaxWidth: Integer read GetAutoSizeMaxWidth write SetAutoSizeMaxWidth default MaxInt;
      property AutoSizeMinWidth: Integer read GetAutoSizeMinWidth write SetAutoSizeMinWidth default 0;
      property BackGroundColor: TRGB read GetBackGroundColor write SetBackGroundColor default $00000000;
      property Center: Boolean read GetCenter write SetCenter default false;
      property Dither: Boolean read GetDither write SetDither default true;
      property DitherErrorLimit: Byte read GetDitherErrorLimit write SetDitherErrorLimit default 32;
      property DitherErrorLimitAuto: Boolean read GetDitherErrorLimitAuto write SetDitherErrorLimitAuto default true;
      property DitherErrorLimitSoft: Boolean read GetDitherErrorLimitSoft write SetDitherErrorLimitSoft default true;
      property DragCursor;
      property DragMode;
      property Enabled;
      property FlipHorizontal: Boolean read GetFlipHorizontal write SetFlipHorizontal default false;
      property FlipVertical: Boolean read GetFlipVertical write SetFlipVertical default false;
      property KeepOldPaintPixelGraphic: Boolean read GetKeepOldPaintPixelGraphic write SetKeepOldPaintPixelGraphic default false;
      property ParentShowHint;
      property Palette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic read GetPalette8BitSys24BitGraphic write SetPalette8BitSys24BitGraphic default pOptimized252Sys16;
      property Palette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic read GetPalette8BitSys8BitGraphic write SetPalette8BitSys8BitGraphic default pOptimized252Sys16;
      property PicBoxColor: TColor read GetPicBoxColor write SetPicBoxColor;
      property PicBoxCursor: TCursor read GetPicBoxCursor write SetPicBoxCursor;
      property PicBoxDragCursor: TCursor read GetPicBoxDragCursor write SetPicBoxDragCursor;
      property PicBoxDragMode: TDragMode read GetPicBoxDragMode write SetPicBoxDragMode;
      property PicBoxFrameColor: TColor read GetPicBoxFrameColor write SetPicBoxFrameColor default clBtnShadow;
      property PicBoxHint: string read GetPicBoxHint write SetPicBoxHint;
      property PicBoxParentColor: Boolean read GetPicBoxParentColor write SetPicBoxParentColor;
      property PicBoxParentShowHint: Boolean read GetPicBoxParentShowHint write SetPicBoxParentShowHint;
      property PicBoxPopupMenu: TPopupMenu read GetPicBoxPopupMenu write SetPicBoxPopupMenu;
      property PicBoxShowHint: Boolean read GetPicBoxShowHint write SetPicBoxShowHint;
      property PicBoxTag: LongInt read GetPicBoxTag write SetPicBoxTag;
      property PopupMenu;
      property Progress5Clocks: Boolean read GetProgress5Clocks write SetProgress5Clocks default true;
      property ProgressClockBkColor: TColor read GetProgressClockBkColor write SetProgressClockBkColor default clBtnFace;
      property ProgressClockLineColor: TColor read GetProgressClockLineColor write SetProgressClockLineColor default clBtnShadow;
      property ProgressClockVisible: Boolean read GetProgressClockVisible write SetProgressClockVisible default true;
      property RGBWeighting: Boolean read GetRGBWeighting write SetRGBWeighting default true;
      property RearrangeAlways: Boolean read GetRearrangeAlways write SetRearrangeAlways default false;
      property ReduceOnLoad: Boolean read GetReduceOnLoad write SetReduceOnLoad default false;
      property Selection: Boolean read GetSelection write SetSelection default false; {True, if Selection exists.}
      property SelectionColor1: TColor read GetSelectionColor1 write SetSelectionColor1 default clWhite;
      property SelectionColor2: TColor read GetSelectionColor2 write SetSelectionColor2 default clRed;
      property SelectionLeft: Integer read GetSelectionLeft write SetSelectionLeft default 0;
      property SelectionTop: Integer read GetSelectionTop write SetSelectionTop default 0;
      property SelectionWidth: Integer read GetSelectionWidth write SetSelectionWidth default 1;
      property SelectionHeight: Integer read GetSelectionHeight write SetSelectionHeight default 1;
      property ShowHint;
      property ShowHourGlass: Boolean read GetShowHourGlass write SetShowHourGlass default true;
      property Stretch: TStretch read GetStretch write SetStretch default sNeverKAR;
      property StretchMode: TStretchMode read GetStretchMode write SetStretchMode default smFast;
      property Tiling: TTiling read GetTiling write SetTiling default TNone;
      property UseThread: Boolean read GetUseThread write SetUseThread default true;
      property Visible;
      property ReadWarningAction: TPGWarningAction read GetReadWarningAction write SetReadWarningAction default pgwaOKCancelBox;
      property SaveColorResWarningAction: TPGWarningAction read GetSaveColorResWarningAction write SetSaveColorResWarningAction default pgwaOKCancelBox;
      property ZoomFactor: Extended read GetZoomFactor write SetZoomFactor;
      property FileName: string read GetFileName write SetFileName;
      property PicBoxOnClick: TNotifyEvent read GetPicBoxOnClick write SetPicBoxOnClick;
      property PicBoxOnDblClick: TNotifyEvent read GetPicBoxOnDblClick write SetPicBoxOnDblClick;
      property PicBoxOnDragDrop: TDragDropEvent read GetPicBoxOnDragDrop write SetPicBoxOnDragDrop;
      property PicBoxOnDragOver: TDragOverEvent read GetPicBoxOnDragOver write SetPicBoxOnDragOver;
      property PicBoxOnEndDrag: TEndDragEvent read GetPicBoxOnEndDrag write SetPicBoxOnEndDrag;
      property PicBoxOnMouseDown: TMouseEvent read GetPicBoxOnMouseDown write SetPicBoxOnMouseDown;
      property PicBoxOnMouseMove: TMouseMoveEvent read GetPicBoxOnMouseMove write SetPicBoxOnMouseMove;
      property PicBoxOnMouseUp: TMouseEvent read GetPicBoxOnMouseUp write SetPicBoxOnMouseUp;
      property PicBoxOnPaint: TNotifyEvent read GetPicBoxOnPaint write SetPicBoxOnPaint;
      property PicBoxOnSetCursor: TPGSetCursorEvent read GetPicBoxOnSetCursor write SetPicBoxOnSetCursor;
      property PicBoxOnStartDrag: TStartDragEvent read GetPicBoxOnStartDrag write SetPicBoxOnStartDrag;
      property OnClick;
      property OnDblClick;
      property OnDragDrop;
      property OnDragOver;
      property OnEndDrag;
      property OnMouseDown;
      property OnMouseMove;
      property OnMouseUp;
      property OnNewAutoSize: TPGINewAutoSizeEvent read GetOnNewAutoSize write SetOnNewAutoSize;
      property OnPaint: TNotifyEvent read GetOnPaint write SetOnPaint;
      property OnPainting: TNotifyEvent read GetOnPainting write SetOnPainting;
      property OnPixelGraphicChange: TNotifyEvent read GetOnPixelGraphicChange write SetOnPixelGraphicChange;
      property OnPixelGraphicProgress: TPGProgressEvent read GetOnPixelGraphicProgress write SetOnPixelGraphicProgress;
      property OnPixelGraphicProgressEnd: TNotifyEvent read GetOnPixelGraphicProgressEnd write SetOnPixelGraphicProgressEnd;
      property OnPixelGraphicProgressStart: TNotifyEvent read GetOnPixelGraphicProgressStart write SetOnPixelGraphicProgressStart;
      property OnSelectionChange: TNotifyEvent read GetOnSelectionChange write SetOnSelectionChange;
      property OnSelectionMade: TNotifyEvent read GetOnSelectionMade write SetOnSelectionMade;
      property OnSetCursor: TPGSetCursorEvent read GetOnSetCursor write SetOnSetCursor;
      property OnStartDrag;
      property OnZoomFactorChange: TNotifyEvent read GetOnZoomFactorChange write SetOnZoomFactorChange;
   end;

   TPGOpenDialog = class(TOpenDialog)
   private
      FDlgHWndPreview: HWnd;
      FDlgHWndInfo: HWnd;
      FDlgHWndParent: HWnd;
      FDlgHWnd: HWnd;
      FPaintPixelGraphic: TPixelGraphic;
      FCreatePaintPGThread: Pointer;
      FStretchMode: TStretchMode;
      FUpdateExtOnFilterIndexChange: Boolean;
      FDialogData: Pointer;
      FUseDefaultFilter: Boolean;
      FProgressClockBkColor: TColor;
      FProgressClockLineColor: TColor;
      FProgressClockVisible: Boolean;
      FPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      FPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      FTimer: TTimer;
      FInfoValid: Boolean;
      FInfoType: String;
      FInfoSubType: String;
      FInfoOptions: String;
      FInfoWidth: Integer;
      FInfoHeight: Integer;
      FInfoColors: String;
      FInfoBitsPerPixel: Integer;
      FInfoGraphicCount: Integer;
      FShowInfo: Boolean;
   protected
      function TaskModalDialog(DialogFunc: Pointer; var DialogData): Bool; override;
      function GetOptions: TOpenOptions;
      procedure SetOptions(Value: TOpenOptions);
      function GetExtensionOfFilterIndex(FilterIndex: Integer): string; virtual;
      function GetFilterCount: Integer; virtual;
      function GetDefaultFilter: string; virtual;
      function GetFileFormatReadersWriters: TList; virtual;
      function GetStretchMode: TStretchMode;
      function GetUseDefaultFilter: Boolean;
      function GetProgressClockBkColor: TColor;
      function GetProgressClockLineColor: TColor;
      function GetProgressClockVisible: Boolean;
      function GetPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      function GetPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      function GetShowInfo: Boolean;
      procedure SetStretchMode(Value: TStretchMode);
      procedure SetUseDefaultFilter(Value: Boolean);
      procedure SetProgressClockBkColor(Value: TColor);
      procedure SetProgressClockLineColor(Value: TColor);
      procedure SetProgressClockVisible(Value: Boolean);
      procedure SetPalette8BitSys24BitGraphic(Value: TPalette8BitSys24BitGraphic);
      procedure SetPalette8BitSys8BitGraphic(Value: TPalette8BitSys8BitGraphic);
      procedure SetShowInfo(Value: Boolean);
      procedure Timer(Sender: TObject);
   public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy; override;
      function Execute: Boolean; override;
   published
      property StretchMode: TStretchMode read GetStretchMode write SetStretchMode default smPrecise;
      property Options: TOpenOptions read GetOptions write SetOptions default [ofShareAware, ofHideReadOnly];
      property UseDefaultFilter: Boolean read GetUseDefaultFilter write SetUseDefaultFilter default true;
      property ProgressClockBkColor: TColor read GetProgressClockBkColor write SetProgressClockBkColor default clBtnFace;
      property ProgressClockLineColor: TColor read GetProgressClockLineColor write SetProgressClockLineColor default clBtnShadow;
      property ProgressClockVisible: Boolean read GetProgressClockVisible write SetProgressClockVisible default true;
      property Palette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic read GetPalette8BitSys24BitGraphic write SetPalette8BitSys24BitGraphic default pOptimized252Sys16;
      property Palette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic read GetPalette8BitSys8BitGraphic write SetPalette8BitSys8BitGraphic default pOptimized252Sys16;
      property ShowInfo: Boolean read GetShowInfo write SetShowInfo default true;
   end;

   TPGSaveDialog = class(TPGOpenDialog)
   protected
      function TaskModalDialog(DialogFunc: Pointer; var DialogData): Bool; override;
      function GetExtensionOfFilterIndex(FilterIndex: Integer): string; override;
      function GetFilterCount: Integer; override;
      function GetDefaultFilter: string; override;
      function GetFileFormatReadersWriters: TList; override;
   public
      constructor Create(AOwner: TComponent); override;
      function Execute: Boolean; override;
   end;

   TPGFilter=class(TPGFilterClass)
   protected
      FPGSrc: TPixelGraphic;
      constructor Create; virtual;
      destructor Destroy; override;
      procedure CalcStart(PGSrc: TPixelGraphic); virtual;
      function CalcDestPixel(X, Y: Integer): TRGB; virtual;
      procedure CalcEnd; virtual;
      function CanProcessPaletteAndIdenticalSource: Boolean; virtual;
      function CalcDestColor(aColor: TRGB): TRGB; virtual;
   end;

   TNegativeFilter=class(TPGFilter)
   private
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
      function CanProcessPaletteAndIdenticalSource: Boolean; override;
   end;

   TGrayScaleFilter=class(TPGFilter)
   private
      FRGBWeighting: Boolean;
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
      function CanProcessPaletteAndIdenticalSource: Boolean; override;
      function GetRGBWeighting: Boolean;
      procedure SetRGBWeighting(Value: Boolean);
   public
      constructor Create; override;
      property RGBWeighting: Boolean read GetRGBWeighting write SetRGBWeighting;
   end;

   TBCGFilter=class(TPGFilter)
   private
      FParValues: array[0..255] of Byte;
      FUseY: Boolean;
      FBrightness: Integer;
      FContrast: Extended;
      FGamma: Extended;
      function CalcDestColorNoVirtual(aColor: TRGB): TRGB;
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
      function CanProcessPaletteAndIdenticalSource: Boolean; override;
      procedure CalcStart(PGSrc: TPixelGraphic); override;
      function GetBrightness: Integer;
      function GetContrast: Extended;
      function GetGamma: Extended;
      function GetUseY: Boolean;
      procedure SetBrightness(Value: Integer);
      procedure SetContrast(Value: Extended);
      procedure SetGamma(Value: Extended);
      procedure SetUseY(Value: Boolean);
   public
      constructor Create; override;
      property Brightness: Integer read GetBrightness write SetBrightness;
      property Contrast: Extended read GetContrast write SetContrast;
      property Gamma: Extended read GetGamma write SetGamma;
      property UseY: Boolean read GetUseY write SetUseY;
   end;

   TXXXFilter=class(TPGFilter) {for internal use only}
   protected
      function CanProcessPaletteAndIdenticalSource: Boolean; override;
      constructor Create; override;
   public
      Par1Values: array[0..255] of Byte;
      Par2Values: array[0..255] of Byte;
      Par3Values: array[0..255] of Byte;
   end;

   TRGBFilter=class(TXXXFilter)
   protected
      function GetRedValue(i: Byte): Byte;
      function GetGreenValue(i: Byte): Byte;
      function GetBlueValue(i: Byte): Byte;
      procedure SetRedValue(i, Value: Byte);
      procedure SetGreenValue(i, Value: Byte);
      procedure SetBlueValue(i, Value: Byte);
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
   public
      property RedValues[i: Byte]: Byte read GetRedValue write SetRedValue;
      property GreenValues[i: Byte]: Byte read GetGreenValue write SetGreenValue;
      property BlueValues[i: Byte]: Byte read GetBlueValue write SetBlueValue;
   end;

   TCMYFilter=class(TXXXFilter)
   protected
      function GetCyanValue(i: Byte): Byte;
      function GetMagentaValue(i: Byte): Byte;
      function GetYellowValue(i: Byte): Byte;
      procedure SetCyanValue(i, Value: Byte);
      procedure SetMagentaValue(i, Value: Byte);
      procedure SetYellowValue(i, Value: Byte);
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
   public
      property CyanValues[i: Byte]: Byte read GetCyanValue write SetCyanValue;
      property MagentaValues[i: Byte]: Byte read GetMagentaValue write SetMagentaValue;
      property YellowValues[i: Byte]: Byte read GetYellowValue write SetYellowValue;
   end;

   TYCbCrFilter=class(TXXXFilter)
   protected
      function GetY_Value(i: Byte): Byte;
      function GetCbValue(i: Byte): Byte;
      function GetCrValue(i: Byte): Byte;
      procedure SetY_Value(i, Value: Byte);
      procedure SetCbValue(i, Value: Byte);
      procedure SetCrValue(i, Value: Byte);
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
   public
      property YValues[i: Byte]: Byte read GetY_Value write SetY_Value;
      property CbValues[i: Byte]: Byte read GetCbValue write SetCbValue;
      property CrValues[i: Byte]: Byte read GetCrValue write SetCrValue;
   end;

   THLSFilter=class(TXXXFilter)
   protected
      function GetHueValue(i: Byte): Byte;
      function GetLumValue(i: Byte): Byte;
      function GetSatValue(i: Byte): Byte;
      procedure SetHueValue(i, Value: Byte);
      procedure SetLumValue(i, Value: Byte);
      procedure SetSatValue(i, Value: Byte);
      function CalcDestColorNoVirtual(aColor: TRGB): TRGB;
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
   public
      property HueValues[i: Byte]: Byte read GetHueValue write SetHueValue;
      property LumValues[i: Byte]: Byte read GetLumValue write SetLumValue;
      property SatValues[i: Byte]: Byte read GetSatValue write SetSatValue;
   end;

   THSVFilter=class(TXXXFilter)
   protected
      function GetHueValue(i: Byte): Byte;
      function GetSatValue(i: Byte): Byte;
      function GetValValue(i: Byte): Byte;
      procedure SetHueValue(i, Value: Byte);
      procedure SetSatValue(i, Value: Byte);
      procedure SetValValue(i, Value: Byte);
      function CalcDestColorNoVirtual(aColor: TRGB): TRGB;
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      function CalcDestColor(aColor: TRGB): TRGB; override;
   public
      property HueValues[i: Byte]: Byte read GetHueValue write SetHueValue;
      property SatValues[i: Byte]: Byte read GetSatValue write SetSatValue;
      property ValValues[i: Byte]: Byte read GetValValue write SetValValue;
   end;

   TDistributionShape=(dsGaussian, dsTent, dsRect);

   TConvFilter=class(TPGFilter)
   private
      FElements: Pointer;
      FWidth: Integer;
      FHeight: Integer;
      FHorzOffset: Integer;
      FVertOffset: Integer;
      FBias: Extended;
      FAmplification: Extended;
   protected
      function CalcDestPixel(X, Y: Integer): TRGB; override;
      procedure CalcStart(PGSrc: TPixelGraphic); override;
      procedure FillWithDistribution(s: Extended; ds: TDistributionShape; UseDistance: Boolean);
      function GetBias: Extended;
      function GetElement(x, y: Integer): Integer;
      function GetHeight: Integer;
      function GetHorzOffset: Integer;
      function GetAmplification: Extended;
      function GetVertOffset: Integer;
      function GetWidth: Integer;
      procedure SetBias(Value: Extended);
      procedure SetElement(x, y, Value: Integer);
      procedure SetHeight(Value: Integer);
      procedure SetHorzOffset(Value: Integer);
      procedure SetAmplification(Value: Extended);
      procedure SetVertOffset(Value: Integer);
      procedure SetWidth(Value: Integer);
   public
      constructor Create; override;
      destructor Destroy; override;
      procedure SetBlur(r, p: Extended);
      procedure SetContour(s, a: Extended; ds: TDistributionShape; UseDistance: Boolean; WhiteBackGround: Boolean);
      procedure SetDetail(s, p: Extended; ds: TDistributionShape; UseDistance: Boolean);
      procedure SetSharpen(s, p: Extended; ds: TDistributionShape; UseDistance: Boolean);
      procedure SetSmooth(s, p: Extended; ds: TDistributionShape; UseDistance: Boolean);
      property Bias: Extended read GetBias write SetBias;
      property Elements[x, y: Integer]: Integer read GetElement write SetElement;
      property Height: Integer read GetHeight write SetHeight;
      property HorzOffset: Integer read GetHorzOffset write SetHorzOffset;
      property Amplification: Extended read GetAmplification write SetAmplification;
      property VertOffset: Integer read GetVertOffset write SetVertOffset;
      property Width: Integer read GetWidth write SetWidth;
   end;

   TFilterDialog = class(TComponent) {for internal use}
   private
      FFilter: TPGFilter;
      FFilterDialogForm: TForm;
      FTrackBar1Needed: Boolean;
      FTrackBar1Min: Integer;
      FTrackBar1Max: Integer;
      FTrackBar1Frequency: Integer;
      FTrackBar1Default: Integer;
      FLabel1aWidth: Integer;
      FLabel1aCaption: string;
      FLabel1bCaption: string;
      FLabel1cCaption: string;
      FLabel1dCaption: string;
      FLabel1eWidth: Integer;
      FTrackBar1Position: Integer;
      FTrackBar2Needed: Boolean;
      FTrackBar2Min: Integer;
      FTrackBar2Max: Integer;
      FTrackBar2Frequency: Integer;
      FTrackBar2Default: Integer;
      FLabel2aWidth: Integer;
      FLabel2aCaption: string;
      FLabel2bCaption: string;
      FLabel2cCaption: string;
      FLabel2dCaption: string;
      FLabel2eWidth: Integer;
      FTrackBar2Position: Integer;
      FTrackBar3Needed: Boolean;
      FTrackBar3Min: Integer;
      FTrackBar3Max: Integer;
      FTrackBar3Frequency: Integer;
      FTrackBar3Default: Integer;
      FLabel3aWidth: Integer;
      FLabel3aCaption: string;
      FLabel3bCaption: string;
      FLabel3cCaption: string;
      FLabel3dCaption: string;
      FLabel3eWidth: Integer;
      FTrackBar3Position: Integer;
      FLabel4Caption: string;
      FCaption: string;
      FPreviewNeeded: Boolean;
      FCheckBoxNeeded: Boolean;
      FCheckBoxChecked: Boolean;
      FCheckBoxCaption: string;
      FRadioButtonsNeeded: Boolean;
      FRadioButton1Checked: Boolean;
      FRadioButton1Caption: string;
      FRadioButton2Checked: Boolean;
      FRadioButton2Caption: string;
      FOrigPixelGraphic: TPixelGraphic;
      FHandlePreviewDirty: TNotifyEvent;
      FProgressClockBkColor: TColor;
      FProgressClockLineColor: TColor;
      FProgressClockVisible: Boolean;
      FPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      FPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      procedure OnControlChanged(Sender: TObject);
   protected
      procedure FillStrings; virtual;
      function CreateFilter: TPGFilter; virtual; abstract;
      procedure FillFilter(Filter: TPGFilter); virtual; abstract;
      function CalcLabel1eCaption: string; virtual;
      function CalcLabel2eCaption: string; virtual;
      function CalcLabel3eCaption: string; virtual;
      procedure SaveValuesForUndo; virtual; abstract;
      procedure SetSavedUndoValues; virtual; abstract;
      function Execute: Boolean;
      constructor Create(aOwner: TComponent); override;
      destructor Destroy; override;
   end;

   TPreviewFilterDialog = class(TFilterDialog)
   protected
      function GetPalette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic;
      function GetPalette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic;
      function GetProgressClockBkColor: TColor;
      function GetProgressClockLineColor: TColor;
      function GetProgressClockVisible: Boolean;
      procedure SetPalette8BitSys24BitGraphic(Value: TPalette8BitSys24BitGraphic);
      procedure SetPalette8BitSys8BitGraphic(Value: TPalette8BitSys8BitGraphic);
      procedure SetProgressClockBkColor(Value: TColor);
      procedure SetProgressClockLineColor(Value: TColor);
      procedure SetProgressClockVisible(Value: Boolean);
   public
      function Execute(aPixelGraphic: TPixelGraphic): Boolean;
   published
      property Palette8BitSys24BitGraphic: TPalette8BitSys24BitGraphic read GetPalette8BitSys24BitGraphic write SetPalette8BitSys24BitGraphic default pOptimized252Sys16;
      property Palette8BitSys8BitGraphic: TPalette8BitSys8BitGraphic read GetPalette8BitSys8BitGraphic write SetPalette8BitSys8BitGraphic default pOptimized252Sys16;
      property ProgressClockBkColor: TColor read GetProgressClockBkColor write SetProgressClockBkColor default clBtnFace;
      property ProgressClockLineColor: TColor read GetProgressClockLineColor write SetProgressClockLineColor default clBtnShadow;
      property ProgressClockVisible: Boolean read GetProgressClockVisible write SetProgressClockVisible default false;
   end;

   TXXXFilterDialog = class(TPreviewFilterDialog) {for internal use}
   private
      UndoPar1: Integer;
      UndoPar2: Integer;
      UndoPar3: Integer;
      function GetPar1: Integer;
      function GetPar2: Integer;
      function GetPar3: Integer;
      procedure SetPar1(Value: Integer);
      procedure SetPar2(Value: Integer);
      procedure SetPar3(Value: Integer);
   protected
      procedure FillStrings; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
   public
      constructor Create(aOwner: TComponent); override;
   end;

   TRGBFilterDialog = class(TXXXFilterDialog)
   private
      function GetFilter: TRGBFilter;
   protected
      function CreateFilter: TPGFilter; override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TRGBFilter read GetFilter;
   published
      property Red: Integer read GetPar1 write SetPar1 default 0;
      property Green: Integer read GetPar2 write SetPar2 default 0;
      property Blue: Integer read GetPar3 write SetPar3 default 0;
   end;

   TCMYFilterDialog = class(TXXXFilterDialog)
   private
      function GetFilter: TCMYFilter;
   protected
      function CreateFilter: TPGFilter; override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TCMYFilter read GetFilter;
   published
      property Cyan: Integer read GetPar1 write SetPar1 default 0;
      property Magenta: Integer read GetPar2 write SetPar2 default 0;
      property Yellow: Integer read GetPar3 write SetPar3 default 0;
   end;

   TYCbCrFilterDialog = class(TXXXFilterDialog)
   private
      function GetFilter: TYCbCrFilter;
   protected
      function CreateFilter: TPGFilter; override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TYCbCrFilter read GetFilter;
   published
      property Y: Integer read GetPar1 write SetPar1 default 0;
      property Cb: Integer read GetPar2 write SetPar2 default 0;
      property Cr: Integer read GetPar3 write SetPar3 default 0;
   end;

   THLSFilterDialog = class(TXXXFilterDialog)
   private
      function GetFilter: THLSFilter;
   protected
      function CalcLabel1eCaption: string; override;
      function CreateFilter: TPGFilter; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
      procedure SetPar1(Value: Integer);
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: THLSFilter read GetFilter;
   published
      property H: Integer read GetPar1 write SetPar1 default 0;
      property L: Integer read GetPar2 write SetPar2 default 0;
      property S: Integer read GetPar3 write SetPar3 default 0;
   end;

   THSVFilterDialog = class(TXXXFilterDialog)
   private
      function GetFilter: THSVFilter;
   protected
      function CalcLabel1eCaption: string; override;
      function CreateFilter: TPGFilter; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
      procedure SetPar1(Value: Integer);
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: THSVFilter read GetFilter;
   published
      property H: Integer read GetPar1 write SetPar1 default 0;
      property S: Integer read GetPar2 write SetPar2 default 0;
      property V: Integer read GetPar3 write SetPar3 default 0;
   end;

   TBCGFilterDialog = class(TPreviewFilterDialog)
   private
      UndoPar1: Integer;
      UndoPar2: Integer;
      UndoPar3: Integer;
      UndoPar4: Boolean;
      function GetFilter: TBCGFilter;
   protected
      procedure FillStrings; override;
      function CreateFilter: TPGFilter; override;
      procedure FillFilter(Filter: TPGFilter); override;
      function CalcLabel2eCaption: string; override;
      function CalcLabel3eCaption: string; override;
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
      function GetBrightness: Integer;
      function GetContrast: Extended;
      function GetGamma: Extended;
      function GetUseY: Boolean;
      procedure SetBrightness(Value: Integer);
      procedure SetContrast(Value: Extended);
      procedure SetGamma(Value: Extended);
      procedure SetUseY(Value: Boolean);
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TBCGFilter read GetFilter;
   published
      property Brightness: Integer read GetBrightness write SetBrightness default 0;
      property Contrast: Extended read GetContrast write SetContrast;
      property Gamma: Extended read GetGamma write SetGamma;
      property UseY: Boolean read GetUseY write SetUseY default false;
   end;

   TGrayScaleFilterDialog = class(TPreviewFilterDialog)
   private
      UndoPar: Boolean;
      function GetFilter: TGrayScaleFilter;
   protected
      function CreateFilter: TPGFilter; override;
      procedure FillStrings; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
      procedure SetRGBWeighting(Value: Boolean);
      function GetRGBWeighting: Boolean;
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TGrayScaleFilter read GetFilter;
   published
      property RGBWeighting: Boolean read GetRGBWeighting write SetRGBWeighting default true;
   end;

   TNegativeFilterDialog = class(TPreviewFilterDialog)
   private
      function GetFilter: TNegativeFilter;
   protected
      function CreateFilter: TPGFilter; override;
      procedure FillStrings; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
   public
      constructor Create(aOwner: TComponent); override;
      property Filter: TNegativeFilter read GetFilter;
   end;

   TConvFilterDialog = class(TFilterDialog)
   private
      UndoPar1: Integer;
      UndoPar2: Integer;
      FDistributionShape: TDistributionShape;
      FUseDistance: Boolean;
      function GetFilter: TConvFilter;
   protected
      procedure FillStrings; override;
      function CreateFilter: TPGFilter; override;
      function CalcLabel1eCaption: string; override;
      function CalcLabel2eCaption: string; override;
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
      function GetStdDeviation: Extended;
      function GetPercent: Integer;
      procedure SetStdDeviation(Value: Extended);
      procedure SetPercent(Value: Integer);
      property StdDeviation: Extended read GetStdDeviation write SetStdDeviation;
      property Percent: Integer read GetPercent write SetPercent;
      function GetDistributionShape: TDistributionShape;
      function GetUseDistance: Boolean;
      procedure SetDistributionShape(Value: TDistributionShape);
      procedure SetUseDistance(Value: Boolean);
      property DistributionShape: TDistributionShape read GetDistributionShape write SetDistributionShape default dsGaussian;
      property UseDistance: Boolean read GetUseDistance write SetUseDistance default true;
   public
      constructor Create(aOwner: TComponent); override;
      function Execute: Boolean;
      property Filter: TConvFilter read GetFilter;
   end;

   TSharpenFilterDialog = class(TConvFilterDialog)
   protected
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
   published
      property DistributionShape: TDistributionShape read GetDistributionShape write SetDistributionShape default dsGaussian;
      property StdDeviation: Extended read GetStdDeviation write SetStdDeviation;
      property Percent: Integer read GetPercent write SetPercent default 50;
      property UseDistance: Boolean read GetUseDistance write SetUseDistance default true;
   end;

   TDetailFilterDialog = class(TConvFilterDialog)
   protected
      procedure FillFilter(Filter: TPGFilter); override;
   public
      constructor Create(aOwner: TComponent); override;
   published
      property DistributionShape: TDistributionShape read GetDistributionShape write SetDistributionShape default dsGaussian;
      property StdDeviation: Extended read GetStdDeviation write SetStdDeviation;
      property Percent: Integer read GetPercent write SetPercent default 75;
      property UseDistance: Boolean read GetUseDistance write SetUseDistance default true;
   end;

   TSmoothFilterDialog = class(TConvFilterDialog)
   protected
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
   published
      property DistributionShape: TDistributionShape read GetDistributionShape write SetDistributionShape default dsGaussian;
      property StdDeviation: Extended read GetStdDeviation write SetStdDeviation;
      property Percent: Integer read GetPercent write SetPercent default 100;
      property UseDistance: Boolean read GetUseDistance write SetUseDistance default true;
   end;

   TContourFilterDialog = class(TConvFilterDialog)
   private
      UndoPar3: Boolean;
   protected
      procedure SaveValuesForUndo; override;
      procedure SetSavedUndoValues; override;
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
      function GetBlackBk: Boolean;
      procedure SetBlackBk(Value: Boolean);
   public
      constructor Create(aOwner: TComponent); override;
   published
      property DistributionShape: TDistributionShape read GetDistributionShape write SetDistributionShape default dsRect;
      property StdDeviation: Extended read GetStdDeviation write SetStdDeviation;
      property Percent: Integer read GetPercent write SetPercent default 100;
      property BlackBk: Boolean read GetBlackBk write SetBlackBk default false;
      property UseDistance: Boolean read GetUseDistance write SetUseDistance default true;
   end;

   TBlurFilterDialog = class(TConvFilterDialog)
   protected
      function GetRadius: Extended;
      procedure SetRadius(Value: Extended);
      procedure FillFilter(Filter: TPGFilter); override;
      procedure FillStrings; override;
   public
      constructor Create(aOwner: TComponent); override;
   published
      property Radius: Extended read GetRadius write SetRadius;
      property Percent: Integer read GetPercent write SetPercent default 100;
   end;

   TFileFormatReaderWriter = class(TObject)
   public
      AddToPGOpenSaveDialogFilter: Boolean;
      Extension: string;
      FormatName: string;
      constructor Create;
   end;

   TBytes0_16 = array[0..16] of Byte;

   TFileFormatReader = class(TFileFormatReaderWriter)
   public
      CanIdentifyFormat: Boolean;
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; virtual;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); virtual;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); virtual;
   end;

   TBMPFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TDIBFileFormatReader = class(TBMPFileFormatReader)
   public
      constructor Create;
   end;

   TRLEFileFormatReader = class(TBMPFileFormatReader)
   public
      constructor Create;
   end;

   TJPEGMethod=(
	   jmIntPrecise, { slow but accurate integer algorithm }
	   jmIntFast,	  { faster, less accurate integer method }
	   jmFloat);     { floating-point: accurate, fast on fast hardware }

   TJPGFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TJPEGFileFormatReader = class(TJPGFileFormatReader)
   public
      constructor Create;
   end;

   TJIFFileFormatReader = class(TJPGFileFormatReader)
   public
      constructor Create;
   end;

   TPNGFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TPCXFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TPxMFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TPBMFileFormatReader = class(TPXMFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
   end;

   TPGMFileFormatReader = class(TPXMFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
   end;

   TPPMFileFormatReader = class(TPXMFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
   end;

   TTGAFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TTIFFileFormatReader = class(TFileFormatReader)
   public
      constructor Create;
      function IsFormat(Bytes0_16: TBytes0_16): Boolean; override;
      procedure ReadFromStream(Stream: TStream; PixelGraphic: TPixelGraphic; Index: Integer); override;
      procedure GetInfoFromStream(Stream: TStream; Index: Integer; var iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer); override;
   end;

   TTIFFFileFormatReader = class(TTIFFileFormatReader)
   public
      constructor Create;
   end;

   TCanWriteResolution = (cwrBlackWhite, cwrPalette1Bit, cwrGray4Bit, cwrSystem4Bit, cwrPalette4Bit, cwrGray8Bit, cwrPalette8Bit, cwrTrueColor);

   TCanWriteResolutions = set of TCanWriteResolution;

   TFileFormatWriter = class(TFileFormatReaderWriter)
   public
      MultipleGraphicsMechanismSupported: Boolean;
      { To be to true if the file format supports multiple graphics in one file
        AND if the writer uses BeginWriteToStream, AppendToStream,
        EndWriteToStream }
      CanWriteResolutions: TCanWriteResolutions;
      constructor Create;
      { Set the following fields:
            MultipleGraphicsMechanismSupported
            CanWriteResolutions
            AddToPGOpenSaveDialogFilter
            Extension
            FormatName }
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); virtual;
      { File formats that support only one graphic per file:
            Write the PixelGraphic to the Stream.
        File formats that support multiple graphics per file:
            Call BeginWriteToStream
            Call AppendToStream
            Call EndWriteToStream }
      procedure BeginWriteToStream(Stream: TStream); virtual;
      { To be used for file formats that support multiple graphics in one file:
            Write file header. }
      procedure AppendToStream(Stream: TStream; PixelGraphic: TPixelGraphic); virtual;
      { To be used for file formats that support multiple graphics in one file:
            Append the PixelGraphic to the Stream. }
      procedure EndWriteToStream(Stream: TStream); virtual;
      { To be used for file formats that support multiple graphics in one file:
            E.g. write end markers... }
   end;

   TBMPFileFormatWriter = class(TFileFormatWriter)
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
   end;

   TDIBFileFormatWriter = class(TBMPFileFormatWriter)
   public
      constructor Create;
   end;

   TJPEGCompQuality=0..100;

   TJPGFileFormatWriter = class(TFileFormatWriter)
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
   end;

   TJPEGFileFormatWriter = class(TJPGFileFormatWriter)
   public
      constructor Create;
   end;

   TJIFFileFormatWriter = class(TJPGFileFormatWriter)
   public
      constructor Create;
   end;

   TPNGFileFormatWriter = class(TFileFormatWriter)
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
   end;

   TPXMFileFormatWriter = class(TFileFormatWriter)
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
   end;

   TPBMFileFormatWriter = class(TPXMFileFormatWriter)
   public
      constructor Create;
   end;

   TPGMFileFormatWriter = class(TPXMFileFormatWriter)
   public
      constructor Create;
   end;

   TPPMFileFormatWriter = class(TPXMFileFormatWriter)
   public
      constructor Create;
   end;

   TTGAFileFormatWriter = class(TFileFormatWriter)
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
   end;

const
   tcUncompressed=1;
   tcPackBits=32773;

type
   TTIFFCompression=Integer; {must be twcUncompressed or twcPackBits}
   TTIFFTrueColorPhotInterpret=(ttcpiRGB, ttcpiCMYK);
   TTIFFGrayScalePhotInterpret=(tgspiBlackIsZero, tgspiWhiteIsZero);
   TTIFFByteOrder=(tboI, tboM);
   TTIFFResolutionUnit=(truNone, truInch, truCentimeter);

   TTIFFileFormatWriter = class(TFileFormatWriter)
   protected
      LastPosOfOffSetOfNextIFD: Integer;
      StartPos: Integer;
   public
      constructor Create;
      procedure WriteToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
      procedure BeginWriteToStream(Stream: TStream); override;
      procedure AppendToStream(Stream: TStream; PixelGraphic: TPixelGraphic); override;
      procedure EndWriteToStream(Stream: TStream); override;
   end;

   TTIFFFileFormatWriter = class(TTIFFileFormatWriter)
   public
      constructor Create;
   end;

   TPGLabel = class(TLabel)
   private
      FCallingParentInvalidate: Boolean;
   public
      constructor Create(AOwner: TComponent); override;
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   end;

   TPGRadioButton = class(TRadioButton)
   private
      FTransparent: Boolean;
      FCallingParentInvalidate: Boolean;
   protected
      function GetTransparent: Boolean;
      procedure SetTransparent(Value: Boolean);
      procedure CNCtlColorStatic(var aMessage: TWMCtlColor); message CN_CTLCOLORstatic;
      procedure CreateParams(var Params: TCreateParams); override;
      procedure WMEraseBkgnd(var aMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
   public
      constructor Create(AOwner: TComponent); override;
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   published
      property Transparent: Boolean read GetTransparent write SetTransparent default true;
   end;

   TPGCheckBox = class(TCheckBox)
   private
      FTransparent: Boolean;
      FCallingParentInvalidate: Boolean;
   protected
      function GetTransparent: Boolean;
      procedure SetTransparent(Value: Boolean);
      procedure CNCtlColorStatic(var aMessage: TWMCtlColor); message CN_CTLCOLORstatic;
      procedure CreateParams(var Params: TCreateParams); override;
      procedure WMEraseBkgnd(var aMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
   public
      constructor Create(AOwner: TComponent); override;
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   published
      property Transparent: Boolean read GetTransparent write SetTransparent default true;
   end;

   TPGGroupBox = class(TGroupBox)
   private
      FTransparent: Boolean;
      FCallingParentInvalidate: Boolean;
   protected
      function GetTransparent: Boolean;
      procedure SetTransparent(Value: Boolean);
      procedure CNCtlColorStatic(var aMessage: TWMCtlColor); message CN_CTLCOLORstatic;
      procedure CreateParams(var Params: TCreateParams); override;
      procedure WMEraseBkgnd(var aMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
      procedure Paint; override;
   public
      constructor Create(AOwner: TComponent); override;
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   published
      property Transparent: Boolean read GetTransparent write SetTransparent default true;
   end;

   TPGPanel = class(TPanel)
   private
      FTransparent: Boolean;
      FCallingParentInvalidate: Boolean;
   protected
      constructor Create(AOwner: TComponent); override;
      function GetTransparent: Boolean;
      procedure SetTransparent(Value: Boolean);
      procedure CNCtlColorStatic(var aMessage: TWMCtlColor); message CN_CTLCOLORstatic;
      procedure CreateParams(var Params: TCreateParams); override;
      procedure WMEraseBkgnd(var aMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
      procedure Paint; override;
   public
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   published
      property Transparent: Boolean read GetTransparent write SetTransparent default true;
   end;

   TPGBevel = class(TBevel)
   private
      FCallingParentInvalidate: Boolean;
   public
      constructor Create(AOwner: TComponent); override;
      procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
      procedure Invalidate; override;
   end;

function GetFileFormatReaderStream(Stream: TStream; Extension: string): TFileFormatReader;

function GetFileFormatReader(FileName: string): TFileFormatReader;

function PGStreamInfo(Stream: TStream; Extension: string; Index: Integer; var iType, iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer): Boolean;

function PGFileInfo(FileName: string; Index: Integer; var iType, iSubType, iOptions: string; var iWidth, iHeight: Integer; var iColors: string; var iBitsPerPixel, iGraphicCount: Integer): Boolean;

function MixRGB(RGB1, RGB2: TRGB): TRGB;

function BitCountNumToBitCount(BitCountNum: Integer): TBitCount;

const HUndefined = 1e10;

procedure RGB2HSV(r, g, b: Extended; var h, s, v: Extended);

procedure HSV2RGB(h, s, v: Extended; var r, g, b: Extended);

procedure RGB2HLS(r, g, b: Extended; var h, l, s: Extended);

procedure HLS2RGB(h, l, s: Extended; var r, g, b: Extended);

procedure RGB2CMY(r, g, b: Byte; var C, M, Y: Byte);

procedure CMY2RGB(C, M, Y: Byte; var r, g, b: Byte);

procedure RGB2YCbCr(r, g, b: Extended; var Y, cb, cr: Extended);

procedure YCbCr2RGB(Y, cb, cr: Extended; var r, g, b: Extended);

procedure FreePGMemoryContexts;

var
   PGSharewareRegistrationName: string;
   PGSharewareRegistered: Boolean;
   {only PNG can store Gamma at the moment}
   WriteGamma: Boolean; {Default: true}
   ScreenGamma: Extended; {Default: 1.8}
   GammaCorrectionOnRead: Boolean; {Default: true}
   FileFormatReaders: TList;
   FileFormatWriters: TList;
   {Options for BMP}
   BMPSpecialRound16To24: Boolean;
   {Options for JPEG}
   JPEGDecompMethod: TJPEGMethod; {Default: jmIntPrecise}
   JPEGCompMethod: TJPEGMethod; {Default: jmFloat}
   JPEGCompQuality: TJPEGCompQuality; {Default: 80}
   JPEGCompProgressive: Boolean; {Default: false}
   {Options for PNG}
   PNGUseFileBackground: Boolean; {Default: true}
   {Write Options for PBM, PGM and PPM}
   PxMWriteBinary: Boolean; {Default: false}
   {Read Option for TIFF}
   TIFFReadMaxMultipleImages: Integer; {Default=1000}
   TIFFReadMultipleImagesEnabled: Boolean; {Default=false}
   {Write Options for TIFF}
   TIFFWriteCompression: TTIFFCompression; {Default: twcUncompressed}
   TIFFWriteTrueColorPhotInterpret: TTIFFTrueColorPhotInterpret; {Default: twtcpiRGB}
   TIFFWriteGrayScalePhotInterpret: TTIFFGrayScalePhotInterpret; {Default: twtcpiBlackIsZero}
   TIFFWriteByteOrder: TTIFFByteOrder; {Default: twboI}
   TIFFWriteResolutionUnit: TTIFFResolutionUnit; {Default: twruInch}
   TIFFWriteXResolutionNumerator: Integer; {Default: 300}
   TIFFWriteXResolutionDenominator: Integer; {Default: 1}
   TIFFWriteYResolutionNumerator: Integer; {Default: 300}
   TIFFWriteYResolutionDenominator: Integer; {Default: 1}
   {Cursor handles created by the library}
   OpenHandCursor: HCursor;
   ClosedHandCursor: HCursor;
   FineCrossCursor: HCursor;
   MoveSelCursor: HCursor;

{ ===== Language support ======================================================
  The PixelGraphicLibary supports English, German, French and Dutch language at
  the moment. Set the variable PGLanguage according to the language you want to
  use.

  If you want to use another language you will have to set PGLanguage to
  pglOther and fill the Other fields of the PGLangStrEntries array with the
  translations.

  If you use a language that's uses a different character set the variables
  PGFilterDialogFont and PGOpenSaveDialogInfoLogFont might be usefull.

  Note: JPG and PNG error meassages and warnings cannot be translated. The
        infos in PGFilterDialogFont and PGOpenSaveDialogInfoLogFont cannot be
        translated.
  =============================================================================}

type
   TPixelGraphicLanguage=(pglEnglish, pglGerman, pglFrench, pglDutch, pglSpanish, {other languages might be added here in future} pglOther);

var
   PGLanguage: TPixelGraphicLanguage;
   PGFilterDialogFont: TFont;
   { Font used in the filter dialogs. You might want to change it under D3 if
     you use a language which uses a different font. By default
     PGFilterDialogFont is nil. Setting PGFilterDialogFont to a value <> nil
     will cause the PixelGraphicLibrary to use the font in the filter dialogs.
     Note: The PixelGraphicLibrary does not free the font in the finalization
     section. }
   PGOpenSaveDialogInfoLogFont: TLogFont;
   { PGOpenSaveDialogInfoLogFont is use to create a font handle for the info
     in TPGOpenDialog and TPGSaveDialog. You can change fields if you want to
     use different font chracteristics. }

type
   TPGStrID = (
      pgsiFirst,
      pgsiEPGXYIndexOutOfRange,
      pgsiEPGNoPalette,
      pgsiEPGInvalidPaletteIndex,
      pgsiEPGUnknownClipboardFormat,
      pgsiEPGInvalidTempFile,
      pgsiEPGUnknownFileFormat,
      pgsiEPGInvalid,
      pgsicwrBlackWhite,
      pgsicwrPalette1Bit,
      pgsicwrGray4Bit,
      pgsicwrSystem4Bit,
      pgsicwrPalette4Bit,
      pgsicwrGray8Bit,
      pgsicwrPalette8Bit,
      pgsicwrTrueColor,
      pgsiEPGEmpty,
      pgsiWriteDifferentColorRes,
      pgsiEPGCannotWriteColorRes,
      pgsiEPGUnknownExtension,
      pgsiEPGInvalidValue,
      pgsiEPGNegativeHeight,
      pgsiEPGNegativeWidth,
      pgsiEPGFilter,
      pgsiBit,
      pgsiImageFiles,
      pgsiAllFiles,
      pgsiEPGInvalidSize,
      pgsiWarning,
      pgsiOperationAborted,
      pgsiEPGNotSupportedSubFormat,
      pgsiFailed,
      pgsiUnexpectedEndOfFile,
      pgsiEPGUnknownSubFormat,
      pgsiEPGNotA_File,
      pgsiEPGWidthOrHeight0,
      pgsiEPGInvalidColorRes,
      pgsiEPGUnsupportedFieldType,
      pgsiEPGInvalidCountOfBytesInRow,
      pgsiUnsupportedCompression,
      pgsiEPGS0HDef,
      pgsiEPGOutOfRange,
      pgsiOKButton,
      pgsiCancelButton,
      pgsiRGBFilter,
      pgsiRLabel,
      pgsiGLabel,
      pgsiBLabel,
      pgsiCMYFilter,
      pgsiCLabel,
      pgsiMLabel,
      pgsiYLabel,
      pgsiYCbCrFilter,
      pgsiY_Label,
      pgsiCbLabel,
      pgsiCrLabel,
      pgsiHLSFilter,
      pgsiHLabel,
      pgsiLLabel,
      pgsiSLabel,
      pgsiHSVFilter,
      pgsiVLabel,
      pgsiNegFilter,
      pgsiGammaLabel,
      pgsiRGBLabel,
      pgsiY__Label,
      pgsiBrightness,
      pgsiContrast,
      pgsiApplyOn,
      pgsiBCGFilter,
      pgsiGrayScaleFilter,
      pgsiRGBWeighting,
      pgsiStdDeviation,
      pgsiStrength,
      pgsiSharpen,
      pgsiDetail,
      pgsiSmooth,
      pgsiRadius,
      pgsiBlur,
      pgsiContour,
      pgsiWhite,
      pgsiBlack,
      pgsiPlusMinus,
      pgsiDegree,
      pgsiLast);

type
   TPGLangStrEntry = record
      ID: TPGStrID;
      English: string;
      German: string;
      French: string;
      Dutch: string;
      Spanish: string;
      { other language might be added here in future }
      Other: string;
   end;

const
   PGLangStrEntries: array[pgsiFirst..pgsiLast] of TPGLangStrEntry =
   { If you want to use another language you will have to fill the Other fields
     with the translations. Please contact me before you begin the translation
     if you want to make your translations available to other users...

     Example: Include calls like
     PGLangStrEntries[pgsiEPGNoPalette].Other:= 'Text in your language';
     in your code.

     Note: %S1, %S2 and %S3 are parameters. So you should put them into
     your translations. }
      (
      (
      ID: pgsiFirst;
      English: '';
      German: '';
      French: '';
      Dutch: '';
      Spanish: '';
      Other: ''
      ),
      (
      ID: pgsiEPGXYIndexOutOfRange;
      English: 'X, Y index out of range';
      German: 'X, Y Index außerhalb des zulässigen Bereiches';
      French: 'Valeurs de X, Y hors bornes';
      Dutch: 'X, Y index buiten het toegestane bereik';
      Spanish: 'Valores de x e y fuera de rango';
      Other: ''
      ),
      (
      ID: pgsiEPGNoPalette;
      English: 'No palette';
      German: 'Keine Palette';
      French: 'Pas de palette';
      Dutch: 'Geen palet';
      Spanish: 'No paleta';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidPaletteIndex;
      English: 'Invalid palette index';
      German: 'Ungültiger Palettenindex';
      French: 'Indice de palette invalide';
      Dutch: 'Ongeldige palet index';
      Spanish: 'Indice de paleta inválido';
      Other: ''
      ),
      (
      ID: pgsiEPGUnknownClipboardFormat;
      English: 'Unknown clipboard format';
      German: 'Unbekanntes Zwischenablageformat';
      French: 'Format de Presse-papiers inconnu';
      Dutch: 'Onbekend klembord formaat';
      Spanish: 'Formato de portapapeles inválido';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidTempFile;
      English: 'Invalid temporary file';
      German: 'Ungültige temporäre Datei';
      French: 'Fichier temporaire invalide';
      Dutch: 'Ongeldig tijdelijk bestand';
      Spanish: 'Fichero temporal inválido';
      Other: ''
      ),
      (
      ID: pgsiEPGUnknownFileFormat;
      English: 'Unknown file format';
      German: 'Unbekanntes Dateiformat';
      French: 'Format de fichier inconnu';
      Dutch: 'Onbekend bestand formaat';
      Spanish: 'Formato de fichero desconocido';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalid;
      English: '%S1 invalid';
      German: '%S1 ungültig';
      French: '%S1 invalide';
      Dutch: '%S1 ongeldig';
      Spanish: '%S1 inválido';
      Other: ''
      ),
      (
      ID: pgsicwrBlackWhite;
      English: 'black and white';
      German: 'schwarz-weiß';
      French: 'noir et blanc';
      Dutch: 'zwart-wit';
      Spanish: 'blanco y negro';
      Other: ''
      ),
      (
      ID: pgsicwrPalette1Bit;
      English: '2 colors';
      German: '2 Farben';
      French: '2 couleurs';
      Dutch: '2 kleuren';
      Spanish: '2 colores';
      Other: ''
      ),
      (
      ID: pgsicwrGray4Bit;
      English: '16 shades of gray';
      German: '16 Graustufen';
      French: '16 niveaux de gris';
      Dutch: '16 grijstrappen';
      Spanish: '16 tonos de gris';
      Other: ''
      ),
      (
      ID: pgsicwrSystem4Bit;
      English: '16 system colors';
      German: '16 Systemfarben';
      French: '16 couleurs système';
      Dutch: '16 systeemkleuren';
      Spanish: '16 colores de sistema';
      Other: ''
      ),
      (
      ID: pgsicwrPalette4Bit;
      English: '16 colors';
      German: '16 Farben';
      French: '16 couleurs';
      Dutch: '16 kleuren';
      Spanish: '16 colores';
      Other: ''
      ),
      (
      ID: pgsicwrGray8Bit;
      English: '256 shades of gray';
      German: '256 Graustufen';
      French: '256 niveaux de gris';
      Dutch: '256 grijstrappen';
      Spanish: '256 tonos de gris';
      Other: ''
      ),
      (
      ID: pgsicwrPalette8Bit;
      English: '256 colors';
      German: '256 Farben';
      French: '256 couleurs';
      Dutch: '256 kleuren';
      Spanish: '256 colores';
      Other: ''
      ),
      (
      ID: pgsicwrTrueColor;
      English: '16.7 million colors';
      German: '16.7 Millionen Farben';
      French: '16.7 millions de couleurs';
      Dutch: '16,7 miljoen kleuren';
      Spanish: '16,7 millones de colores';
      Other: ''
      ),
      (
      ID: pgsiEPGEmpty;
      English: '%S1 is empty';
      German: '%S1 ist leer';
      French: '%S1 est vide';
      Dutch: '%S1 is leeg';
      Spanish: '%S1 está vacío';
      Other: ''
      ),
      (
      ID: pgsiWriteDifferentColorRes;
      English: 'The graphic cannot be saved to a %S1 file with the current color resolution (%S2).'#13#13'The graphic will be saved with a different color resolution (%S3).';
      German: 'Die Grafik kann nicht mit der augenblicklichen Farbauflösung (%S2) in eine %S1 Datei gespeichert werden.'#13#13'Die Grafik wird mit einer anderen Auflösung (%S3) gespeichert.';
      French: 'L'#39'image ne peut être enregistrée dans un fichier %S1 avec l'#39'actuelle profondeur de couleur (%S2).'#13#13'L'#39'image sera enregistrée avec une profondeur de couleur différente (%S3).';
      Dutch: 'De afbeelding kan niet met de huidige kleuren resolutie (%S2) opgeslagen worden in een %S1 bestand.'#13#13'De afbeelding zal met een andere resolutie (%S3) opgeslagen worden.';
      Spanish: 'El gráfico no puede ser grabado en el fichero %S1 con la resolución de color actual (%S2)'#13#13'El gráfico sera grabado con una resolución de color diferente (%S3).';
      Other: ''
      ),
      (
      ID: pgsiEPGCannotWriteColorRes;
      English: 'The graphic cannot be saved with to a %S1 file with the current color resolution (%S2)';
      German: 'Die Grafik kann nicht mit der augenblicklichen Farbauflösung (%S2) in eine %S1 Datei gespeichert werden';
      French: 'L'#39'image ne peut être enregistrée dans un fichier %S1 avec l'#39'actuelle profondeur de couleur (%S2).';
      Dutch: 'De afbeelding kan niet met de huidige kleuren resolutie (%S2) opgeslagen worden in een %S1 bestand.';
      Spanish: 'El gráfico no puede ser grabado en el fichero %S1 con la resolución de color actual (%S2)';
      Other: ''
      ),
      (
      ID: pgsiEPGUnknownExtension;
      English: 'Unknown file extension "%S1"';
      German: 'Unbekannte Dateinamenerweiterung "%S1"';
      French: 'Extension de fichier inconnue "%S1".';
      Dutch: 'Onbekende bestand extensie';
      Spanish: 'Extensión de fichero desconocida "%S1"';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidValue;
      English: 'Invalid value for %S1';
      German: 'Ungültiger Wert für %S1';
      French: 'Valeur incorrecte pour %S1';
      Dutch: 'Ongeldige waarde voor %S1';
      Spanish: 'Valor inválido para %S1';
      Other: ''
      ),
      (
      ID: pgsiEPGNegativeHeight;
      English: 'Negative height';
      German: 'Nagative Höhe';
      French: 'Hauteur négative';
      Dutch: 'Negatieve hoogte';
      Spanish: 'Altura negativa';
      Other: ''
      ),
      (
      ID: pgsiEPGNegativeWidth;
      English: 'Negative width';
      German: 'Negative Breite';
      French: 'Largeur négative';
      Dutch: 'Negatieve breedte';
      Spanish: 'Anchura negativa';
      Other: ''
      ),
      (
      ID: pgsiEPGFilter;
      English: 'Cannot apply this filter to a source that is identical to the target';
      German: 'Dieser Filter kann nicht auf eine zum Ziel identische Quelle angewendet werden';
      French: 'Il est impossible d'#39'appliquer ce filtre car la source est confondue avec la cible.';
      Dutch: 'Kan dit filter niet toepassen op een bron dat dezelfde is als het doel';
      Spanish: 'No puedo aplicar este filtro a un origen igual que el destino';
      Other: ''
      ),
      (
      ID: pgsiBit;
      English: 'bit';
      German: 'Bit';
      French: 'bit';
      Dutch: 'bit';
      Spanish: 'bit';
      Other: ''
      ),
      (
      ID: pgsiImageFiles;
      English: 'Image files';
      German: 'Grafikdateien';
      French: 'Images';
      Dutch: 'Grafische bestanden';
      Spanish: 'Ficheros gráficos';
      Other: 'Image files' { must not be empty }
      ),
      (
      ID: pgsiAllFiles;
      English: 'All files';
      German: 'Alle Dateien';
      French: 'Tous les fichiers';
      Dutch: 'Alle bestanden';
      Spanish: 'Todos los ficheros';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidSize;
      English: 'Invalid size of %S1';
      German: 'Ungültige Größe von %S1';
      French: 'Taille incorrecte de %S1';
      Dutch: 'Ongeldige grootte voor %S1';
      Spanish: 'Tamaño inválido de %S1';
      Other: ''
      ),
      (
      ID: pgsiWarning;
      English: 'Warning';
      German: 'Warnung';
      French: 'Avertissement';
      Dutch: 'Waarschuwing';
      Spanish: 'Atención';
      Other: ''
      ),
      (
      ID: pgsiOperationAborted;
      English: 'Operation aborted on user request';
      German: 'Vorgang auf Anwender-Wunsch abgebrochen';
      French: 'Opération abandonnée par l'#39'utilisateur.';
      Dutch: 'Voortgang door de gebruiker onderbroken';
      Spanish: 'Operación interrumpida por el usuario';
      Other: ''
      ),
      (
      ID: pgsiEPGNotSupportedSubFormat;
      English: 'Not supported subformat';
      German: 'Nicht unterstütztes Unterformat';
      French: 'Sous-format non supporté.';
      Dutch: 'Niet ondersteund subformaat';
      Spanish: 'Subformato no soportado';
      Other: ''
      ),
      (
      ID: pgsiFailed;
      English: '%S1 failed';
      German: '%S1 fehlgeschlagen';
      French: '%S1 a échoué';
      Dutch: '%S1 mislukt';
      Spanish: '%S1 ha fallado';
      Other: ''
      ),
      (
      ID: pgsiUnexpectedEndOfFile;
      English: 'Unexpected end of file';
      German: 'Unerwartetes Dateiende';
      French: 'Fin de fichier inattendue.';
      Dutch: 'Onverwacht einde van bestand';
      Spanish: 'Final de fichero inesperado';
      Other: ''
      ),
      (
      ID: pgsiEPGUnknownSubFormat;
      English: 'Unknown subformat';
      German: 'Unbekanntes Unterformat';
      French: 'Sous-format inconnu';
      Dutch: 'Onbekend subformaat';
      Spanish: 'Subformato desconocido';
      Other: ''
      ),
      (
      ID: pgsiEPGNotA_File;
      English: 'Not a %S1 file';
      German: 'Keine %S1 Datei';
      French: 'Ce n'#39'est pas un fichier %S1';
      Dutch: 'Geen %S1 bestand';
      Spanish: 'No es un fichero %S1';
      Other: ''
      ),
      (
      ID: pgsiEPGWidthOrHeight0;
      English: 'Width = 0 or Height = 0';
      German: 'Breite oder Höhe gleich 0';
      French: 'La hauteur ou la largeur est nulle';
      Dutch: 'Breedte of hoogte gelijk aan 0';
      Spanish: 'Altura o anchura nulas';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidColorRes;
      English: 'Invalid color resolution';
      German: 'Ungültige Farbauflösung';
      French: 'Profondeur de couleur invalide';
      Dutch: 'Ongeldige kleur resolutie';
      Spanish: 'Resolución de color inválida';
      Other: ''
      ),
      (
      ID: pgsiEPGUnsupportedFieldType;
      English: 'Unsupported field type %S1';
      German: 'Nicht unterstützer Feld-Typ %S1';
      French: 'Type de champ (%S1) non supporté';
      Dutch: 'Niet ondersteund veld type %S1';
      Spanish: 'Tipo de campo inválido %S1';
      Other: ''
      ),
      (
      ID: pgsiEPGInvalidCountOfBytesInRow;
      English: 'Invalid count of bytes in row %S1';
      German: 'Ungültige Anzahl von Bytes in Reihe %S1';
      French: 'Nombre d'#39'octets incorrect à la ligne %S1';
      Dutch: 'Ongeldig aantal bytes in rij %S1';
      Spanish: 'Cuenta de bytes en fila %S1 inválida';
      Other: ''
      ),
      (
      ID: pgsiUnsupportedCompression;
      English: 'Unsupported Compression';
      German: 'Unsupported Compression';
      French: 'Compression inconnue';
      Dutch: 'Unsupported Compression';
      Spanish: 'Compresión no soportada';
      Other: ''
      ),
      (
      ID: pgsiEPGS0HDef;
      English: 'Saturation=0 and Hue defined';
      German: 'Sättigung=0 and Farbton definiert';
      French: 'Saturation nulle alors que la teinte a été définie';
      Dutch: 'Verzadiging=0 en kleurtoon gedefinieerd';
      Spanish: 'Saturación nula y tinta definida';
      Other: ''
      ),
      (
      ID: pgsiEPGOutOfRange;
      English: '%S1 out of range';
      German: '%S1 außerhalb des zulässigen Bereiches';
      French: '%S1 hors bornes';
      Dutch: '%S1 buiten het toegestane bereik';
      Spanish: '%S1 fuera de rango';
      Other: ''
      ),
      (
      ID: pgsiOKButton;
      English: 'OK';
      German: 'OK';
      French: 'OK';
      Dutch: 'OK';
      Spanish: 'OK';
      Other: ''
      ),
      (
      ID: pgsiCancelButton;
      English: 'Cancel';
      German: 'Abbruch';
      French: 'Annuler';
      Dutch: 'Annuleren';
      Spanish: 'Cancelar';
      Other: ''
      ),
      (
      ID: pgsiRGBFilter;
      English: 'RGB Filter';
      German: 'RGB-Filter';
      French: 'Filtre RVB';
      Dutch: 'RGB-Filter';
      Spanish: 'Filtro RGB';
      Other: ''
      ),
      (
      ID: pgsiRLabel;
      English: 'R';
      German: 'R';
      French: 'R';
      Dutch: 'R';
      Spanish: 'R';
      Other: ''
      ),
      (
      ID: pgsiGLabel;
      English: 'G';
      German: 'G';
      French: 'V';
      Dutch: 'G';
      Spanish: 'G';
      Other: ''
      ),
      (
      ID: pgsiBLabel;
      English: 'B';
      German: 'B';
      French: 'B';
      Dutch: 'B';
      Spanish: 'B';
      Other: ''
      ),
      (
      ID: pgsiCMYFilter;
      English: 'CMY Filter';
      German: 'CMY-Filter';
      French: 'Filtre CMJ';
      Dutch: 'CMY-Filter';
      Spanish: 'Filtro CMY';
      Other: ''
      ),
      (
      ID: pgsiCLabel;
      English: 'C';
      German: 'C';
      French: 'C';
      Dutch: 'C';
      Spanish: 'C';
      Other: ''
      ),
      (
      ID: pgsiMLabel;
      English: 'M';
      German: 'M';
      French: 'M';
      Dutch: 'M';
      Spanish: 'M';
      Other: ''
      ),
      (
      ID: pgsiYLabel;
      English: 'Y';
      German: 'Y';
      French: 'J';
      Dutch: 'Y';
      Spanish: 'Y';
      Other: ''
      ),
      (
      ID: pgsiYCbCrFilter;
      English: 'YCbCr Filter';
      German: 'YCbCr-Filter';
      French: 'Filtre YCbCr';
      Dutch: 'YCbCr-Filter';
      Spanish: 'Filtro YCbCr';
      Other: ''
      ),
      (
      ID: pgsiY_Label;
      English: 'Y';
      German: 'Y';
      French: 'Y';
      Dutch: 'Y';
      Spanish: 'Y';
      Other: ''
      ),
      (
      ID: pgsiCbLabel;
      English: 'Cb';
      German: 'Cb';
      French: 'Cb';
      Dutch: 'Cb';
      Spanish: 'Cb';
      Other: ''
      ),
      (
      ID: pgsiCrLabel;
      English: 'Cr';
      German: 'Cr';
      French: 'Cr';
      Dutch: 'Cr';
      Spanish: 'Cr';
      Other: ''
      ),
      (
      ID: pgsiHLSFilter;
      English: 'HLS Filter';
      German: 'HLS-Filter';
      French: 'Filtre TSL';
      Dutch: 'HLS-Filter';
      Spanish: 'Filtro HLS';
      Other: ''
      ),
      (
      ID: pgsiHLabel;
      English: 'H';
      German: 'H';
      French: 'T';
      Dutch: 'H';
      Spanish: 'H';
      Other: ''
      ),
      (
      ID: pgsiLLabel;
      English: 'L';
      German: 'L';
      French: 'L';
      Dutch: 'L';
      Spanish: 'L';
      Other: ''
      ),
      (
      ID: pgsiSLabel;
      English: 'S';
      German: 'S';
      French: 'S';
      Dutch: 'S';
      Spanish: 'S';
      Other: ''
      ),
      (
      ID: pgsiHSVFilter;
      English: 'HSV Filter';
      German: 'HSV-Filter';
      French: 'Filtre TSV';
      Dutch: 'HSV-Filter';
      Spanish: 'Filtro HSV';
      Other: ''
      ),
      (
      ID: pgsiVLabel;
      English: 'V';
      German: 'V';
      French: 'V';
      Dutch: 'V';
      Spanish: 'V';
      Other: ''
      ),
      (
      ID: pgsiNegFilter;
      English: 'Negative Filter';
      German: 'Negativ-Filter';
      French: 'Filtre négatif';
      Dutch: 'Negatief-Filter';
      Spanish: 'Filtro negativo';
      Other: ''
      ),
      (
      ID: pgsiGammaLabel;
      English: 'Gamma';
      German: 'Gamma';
      French: 'Gamma';
      Dutch: 'Gamma';
      Spanish: 'Gamma';
      Other: ''
      ),
      (
      ID: pgsiRGBLabel;
      English: 'RGB';
      German: 'RGB';
      French: 'RVB';
      Dutch: 'RGB';
      Spanish: 'RGB';
      Other: ''
      ),
      (
      ID: pgsiY__Label;
      English: 'Y';
      German: 'Y';
      French: 'Y';
      Dutch: 'Y';
      Spanish: 'Y';
      Other: ''
      ),
      (
      ID: pgsiBrightness;
      English: 'Brightness';
      German: 'Helligkeit';
      French: 'Luminosité';
      Dutch: 'Helderheid';
      Spanish: 'Luminosidad';
      Other: ''
      ),
      (
      ID: pgsiContrast;
      English: 'Contrast';
      German: 'Kontrast';
      French: 'Contraste';
      Dutch: 'Contrast';
      Spanish: 'Contraste';
      Other: ''
      ),
      (
      ID: pgsiApplyOn;
      English: 'Apply on';
      German: 'Anw. auf';
      French: 'Appl.';
      Dutch: 'Toep. op';
      Spanish: 'Aplicar';
      Other: ''
      ),
      (
      ID: pgsiBCGFilter;
      English: 'Brightness, Contrast, Gamma Filter';
      German: 'Helligkeit-, Kontrast-, Gamma-Filter';
      French: 'Luminosité, Contraste, Filtre Gamma';
      Dutch: 'Helderheid-, Contrast-, Gamma-Filter';
      Spanish: 'Luminosidad, Contraste, Filtro Gamma';
      Other: ''
      ),
      (
      ID: pgsiGrayScaleFilter;
      English: 'Grayscale Filter';
      German: 'Graustufen-Filter';
      French: 'Filtre niveaux de gris';
      Dutch: 'Grijstrappen-Filter';
      Spanish: 'Filtro niveles de gris';
      Other: ''
      ),
      (
      ID: pgsiRGBWeighting;
      English: 'RGB weighting';
      German: 'RGB-Wichtung';
      French: 'Dosage RVB';
      Dutch: 'RGB weging';
      Spanish: 'Ponderación RGB';
      Other: ''
      ),
      (
      ID: pgsiStdDeviation;
      English: 'Std. deviation';
      German: 'Standardabw.';
      French: 'Ecart-type';
      Dutch: 'Std. afwijking';
      Spanish: 'Desviación Est.';
      Other: ''
      ),
      (
      ID: pgsiStrength;
      English: 'Strength';
      German: 'Stärke';
      French: 'Intensité';
      Dutch: 'Sterkte';
      Spanish: 'Intensidad';
      Other: ''
      ),
      (
      ID: pgsiSharpen;
      English: 'Sharpen';
      German: 'Schärfen';
      French: 'Durcir';
      Dutch: 'Verscherpen';
      Spanish: 'Aumentar nitidez';
      Other: ''
      ),
      (
      ID: pgsiDetail;
      English: 'Detail';
      German: 'Detail';
      French: 'Détail';
      Dutch: 'Detail';
      Spanish: 'Detalle';
      Other: ''
      ),
      (
      ID: pgsiSmooth;
      English: 'Smooth';
      German: 'Weichzeichnen';
      French: 'Adoucir';
      Dutch: 'Verzachten';
      Spanish: 'Suavizar';
      Other: ''
      ),
      (
      ID: pgsiRadius;
      English: 'Radius';
      German: 'Radius';
      French: 'Rayon';
      Dutch: 'Radius';
      Spanish: 'Radio';
      Other: ''
      ),
      (
      ID: pgsiBlur;
      English: 'Blur';
      German: 'Blur';
      French: 'Flou';
      Dutch: 'Blur';
      Spanish: 'Enturbiar';
      Other: ''
      ),
      (
      ID: pgsiContour;
      English: 'Contour';
      German: 'Kontur';
      French: 'Contour';
      Dutch: 'Omtrek';
      Spanish: 'Contorno';
      Other: ''
      ),
      (
      ID: pgsiWhite;
      English: 'White';
      German: 'Weiß';
      French: 'Blanc';
      Dutch: 'Wit';
      Spanish: 'Blanco';
      Other: ''
      ),
      (
      ID: pgsiBlack;
      English: 'Black';
      German: 'Schwarz';
      French: 'Noir';
      Dutch: 'Zwart';
      Spanish: 'Negro';
      Other: ''
      ),
      (
      ID: pgsiPlusMinus;
      English: '±';
      German: '±';
      French: '±';
      Dutch: '±';
      Spanish: '±';
      Other: ''
      ),
      (
      ID: pgsiDegree;
      English: '°';
      German: '°';
      French: '°';
      Dutch: '°';
      Spanish: '°';
      Other: ''
      ),
      (
      ID: pgsiLast;
      English: '';
      German: '';
      French: '';
      Dutch: '';
      Spanish: '';
      Other: ''
      )
      );

procedure Register;

implementation
