timsara@net - AltPE code library 2
    These libraries are free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation.

    These libraries are distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

AltPE code library 2 for Delphi / Graphics32
modulecontent
gr32_vbclipbrd
Clipboard Library
const
  CF_BM32ALPHA_FORMATNAME = 'CFBitmap32Alpha';

function RegisterBitmap32Alpha: Word;
function ClipboardHasBitmap: Boolean;
function ClipboardHasAlpha: Boolean;
function ClipboardHasBitmapWithAlpha: Boolean;
function CopyBitmap32(bm32: TBitmap32): Boolean;
function PasteBitmap32(bm32: TBitmap32): Boolean;
gr32_vbcommon
Common Library
type
  TARGB = record
  PARGB = ^TARGB;
  TArrayARGB = array[0..0] of TARGB;
  PArrayARGB = ^TArrayARGB;
  TRGB = record
  PRGB = ^TRGB;
  PLUT8 = ^TLUT8;
  TByteArray = array[0..0] of Byte;
  PByteArray = ^TByteArray;
  TPolarPoint = record
function NormalizeCoord(p: TFloatPoint; w, h: Integer): TFloatPoint;
function UnNormalizeCoord(p: TFloatPoint; w, h: Integer): TFloatPoint;
function RectToPolar(rp: TFloatPoint): TPolarPoint;
function PolarToRect(pp: TPolarPoint): TFloatPoint;
function PolarPoint(R, A: Extended): TPolarPoint;
function ByteConstrain(i: Integer): Integer;
procedure Bitmap32SetAs(bmDst, bmSrc: TBitmap32);
procedure Bitmap32Copy(bmDst, bmSrc: TBitmap32; complete: Boolean = False);
procedure Bitmap32StretchCopy(bmDst, bmSrc: TBitmap32; complete: Boolean = False);
procedure Bitmap32Exchange(bm1, bm2: TBitmap32);
procedure MergeBitmap32(bmDst, bmSrc: TBitmap32; alpha: Integer);
procedure MergeBitmap32At(bmDst: TBitmap32; xOffset, yOffset: Integer; bmSrc: TBitmap32; alpha: Integer);
procedure DistanceBitmap32(bmDst, bmSrc: TBitmap32; alpha: Integer);
procedure AddBitmap32(bmDst, bmSrc: TBitmap32; alpha: Integer);
procedure ModulateBitmap32(bmDst, bmSrc: TBitmap32; alpha: Integer);
function BitmapRect(bm: TBitmap32): TRect;
function BitmapFloatRect(bm: TBitmap32): TFloatRect;
function RectRound(frc: TFloatRect): TRect;
function ConstrainRectInRect(rcIn, rcOut: TFloatRect): TFloatRect;
function GetBitmapUsedRect(bm: Tbitmap32; bx, by: Integer): TRect;
gr32_vbconv
Convolution Library
type
 TOperatePixel32 = procedure(pix: PColor32);
procedure BlurMap(pix: PColor32);
procedure OperatePixels32(bm: TBitmap32; proc: TOperatePixel32);
procedure ConvolveSmall32(v: array of integer; d: Integer; bm: TBitmap32; a: Integer = 0);
procedure ConvolveBig32(v: array of integer; d: Integer; bm: TBitmap32; a: Integer = 0);
procedure ApplyUnsharpMask(bmDst, bmSrc: TBitmap32; Q: Single; typ: Integer = UNSHARP_MASK_GAUSS);
procedure ApplyContour(bmDst, bmSrc: TBitmap32; mh, mv: array of Integer; dh, dv: Integer; Q: Single);
procedure ApplySobel(bmDst, bmSrc: TBitmap32; Q: Single);
procedure ApplyPrewitt(bmDst, bmSrc: TBitmap32; Q: Single);
// BLUR, BLURMORE, BLURGAUSSIAN, MOTIONBLUR, SOFTEN, SOFTENMORE
// SHARPEN, SHARPENMORE, ENHANCE, ENHANCEMORE
// LAPLACE1, LAPLACE2, GLOW, PATTERN, FIND-V, FIND-H, 
// V-SOBEL, H-SOBEL, V-PREWITT, H-PREWITT, EMBOSS, EMBOSSMORE
gr32_vbeffects
Effects Library
procedure ApplyMosaic(bmDst, bmSrc: TBitmap32; d: Integer; bc: TColor32; pow: Single);
procedure ApplyQuantize(bmDst, bmSrc: TBitmap32; d: Integer; fc, bc: TColor32; use_r, use_g, use_b: Boolean);
procedure ApplySpray(bm: TBitmap32; radius: Integer); overload;
procedure ApplySpray(bmDst, bmSrc: TBitmap32; radius: Integer); overload;
procedure ApplyHole(bm: TBitmap32; t: TColor32; pow: Single); overload;
procedure ApplyHole(bmDst, bmSrc: TBitmap32; t: TColor32; pow: Single); overload;
procedure ApplyTwirl(bmDst, bmSrc: TBitmap32; typ: Integer; pow: Single); // interpolated
procedure Bitmap32Round(bm: TBitmap32); // interpolated
procedure Bitmap32Distortion(bm: TBitmap32; hp, vp: Extended); // interpolated
gr32_vbfsdither
Floyd-Steinberg Dithering Library
function ColorAddKeepAlpha(C1, C2: TColor32): TColor32;
procedure Bitmap32FloydSteinbergDither(bm32: TBitmap32; shift: Integer);
procedure Bitmap32FloydSteinbergDitherBW(bm32: TBitmap32);
function CountColors32(const bm32: TBitmap32): Integer;
gr32_vbgif
GIF Load/save Library
procedure LoadBitmap32FromGIF(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToGIF(fname: string; bm32: TBitmap32; dither: Boolean);
gr32_vbimage
TImage Library
function ControlToBitmapFloatRect(ci: TCustomImage32; frc: TFloatRect): TFloatRect;
function BitmapToControlFloatRect(ci: TCustomImage32; frc: TFloatRect): TFloatRect;
function BitmapControlRect(ci: TCustomImage32): TFloatRect;
procedure ZoomOutToViewPort(im: TCustomImage32; bw, bh: Integer);
gr32_vbj2k
JPEG2000 Load/Save Library
type
  TJ2KObject = class(TBitmap)
    procedure LoadFromFile(const fname: string); override;
    procedure SaveToFile(const fname: string); override;
  end;
procedure LoadBitmap32FromJ2K(fname: string; bm32: TBitmap32);
procedure LoadBitmapFromJ2K(fname: string; bm: Graphics.TBitmap);
procedure SaveBitmap32ToJ2K(fname: string; bm32: TBitmap32; percent: Integer = 0; format: Integer = 3);
procedure SaveBitmapToJ2K(fname: string; bm: Graphics.TBitmap);
gr32_vblut
LUT Library
procedure ApplyLUTRGB(bm: TBitmap32; const LUTR, LUTG, LUTB: TLUT8; alpha: Integer = 255);
procedure ApplyLUTX(bm: TBitmap32; const LUT: TLUT8; alpha: Integer = 255);
procedure ApplyRGBDelta(bm: TBitmap32; r, g, b: Integer; alpha: Integer = 255); overload;
procedure ApplyRGBDelta(bmDst, bmSrc: TBitmap32; r, g, b: Integer; alpha: Integer = 255); overload;
procedure ApplyRGBFactor(bm: TBitmap32; r, g, b: Single; alpha: Integer = 255);
procedure ApplyBrightnessContrastDelta(bm: TBitmap32; db, dc: Integer; r, g, b: Boolean; alpha: Integer = 255); overload;
procedure ApplyBrightnessContrastDelta(bmDst, bmSrc: TBitmap32; db, dc: Integer; r, g, b: Boolean; alpha: Integer = 255); overload;
procedure ApplyBrightnessContrastDelta(bmDst, bmSrc: TBitmap32; db, dc: Integer; alpha: Integer = 255); overload;
procedure LightImage(bm: TBitmap32; d, alpha: Integer);
procedure ContrastImage(bm: TBitmap32; d, alpha: Integer);
procedure TintImage(bm: TBitmap32; c: TColor32; alpha: Integer);
procedure ApplyGamma(bm: TBitmap32; g: Double; alpha: Integer = 255); overload;
procedure ApplyGamma(bmDst, bmSrc: TBitmap32; g: Double; alpha: Integer = 255); overload;
gr32_vbminmax
MinMax Colors/Luminance Library
procedure GetMinMaxLuminanceSmart(bmSrc: TBitmap32; pmin, pmax: PInteger);
procedure GetMinMaxLuminance(bmSrc: TBitmap32; pmin, pmax: PInteger);
procedure GetMinMaxColors(bmSrc: TBitmap32; pmin, pmax: PInteger);
gr32_vbpng
PNG Load/Save Library
procedure LoadBitmap32FromPNG(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToPNG(fname: string; bm32: TBitmap32; paletted, transparent: Boolean; bgcolor: TColor; compression:Integer = 9);
gr32_vbundo
Undo Library
type
  TBitmap32Undo = class
  public
    constructor Create; overload;
    constructor Create(size: Integer); overload;
    destructor Destroy; override;
    procedure ClearUndos;
    procedure PushUndo(bm: TBitmap32);
    procedure PopUndo(bm: TBitmap32);
    function HasUndo: Boolean;
    procedure UndoUndo(bm: TBitmap32);
    function HasUndoUndo: Boolean;
    function HasChanges: Boolean;
    procedure Lock;
    procedure Unlock;
    function IsLocked: Boolean;
    function Bitmap: TBitmap32;
    function PreviousBitmap: TBitmap32;
    function HasCheckpoint: Boolean;
    function CanCommit: Boolean;
    procedure Commit(bm: TBitmap32);
    procedure Rollback(bm: TBitmap32);
  end;
gr32_vbwbmp
WBMP (WAP Bitmap) Load/Save Library
procedure LoadBitmap32FromWBMP(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToWBMP(fname: string; bm32: TBitmap32);
gr32_vbcomp
Components Library
procedure GrayBitmap(bm: TBitmap32; alpha: Integer = 255);
procedure ApplyHSLFactor(bmDst, bmSrc: TBitmap32; dh, ds, dl: Integer; r, g, b: Boolean);
procedure BitmapChannelAsGray(bm: TBitmap32; shift: Integer);
procedure BitmapChannelAsColor(bm: TBitmap32; shift: Integer);
procedure BitmapRGBToHSL(bm: TBitmap32);
procedure BitmapHSLToRGB(bm: TBitmap32);
gr32_vbfrac
Fractals Library
procedure MandelBrot(bm: TBitmap32; m: Extended);
gr32_vbinterpol
Interpolated Library
function Bitmap32FloatingPixel(bm: TBitmap32; x, y: Single): TColor32; // interpolator
gr32_vbpxm
Pixel Map Image (PPM/PGM/PNM) Load/Save Library
procedure LoadBitmap32FromPXM(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToPGM(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToPPM(fname: string; bm32: TBitmap32);
gr32_vbraw
RAW Image Load Library
procedure LoadBitmap32FromRAWThumb(fname: string; bm32: TBitmap32);
procedure LoadBitmap32FromRAWImage(fname: string; bm32: TBitmap32);
gr32_vbtif
TIF Image Load/Save Library
procedure LoadBitmap32FromTIF(fname: string; bm32: TBitmap32);
procedure SaveBitmap32ToTIF(fname: string; bm32: TBitmap32);
gr32_vbrotate
Rotations Library
procedure Bitmap32Flip(bm: TBitmap32); // substituted by TBitmap32.FlipVert();
procedure Bitmap32Mirror(bm: TBitmap32); // substituted by TBitmap32.FlipHorz();
procedure Bitmap32RotateQ(bm: TBitmap32; q: Integer);
procedure IsoRotation(bmDest: TBitmap32; Alpha: Single);
gr32_vbsort
Sort Library
procedure ARGBSort(var vec: TArrayARGB; n: Integer; c: Integer = 0);
gr32_vbrank
Rank Filter Library
procedure ApplyMin(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyMax(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyMean(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyMedian(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyVariance(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyStdDev(bm: TBitmap32; d: Integer; alpha: Integer = 255);
procedure ApplyKuwahara(bm: TBitmap32; l: Integer; alpha: Integer = 255);

AltPE TBitmap extension / Image format registration library
modulecontent
pxmimage
Pixel Map Image (PPM/PGM/PNM) - TPXMImage
registers .ppm, .pgm and .pnm
type
 TPXMImage = class(TBitmap)
 private
 protected
 public
  procedure LoadFromFile(const Filename: string); override;
  procedure SaveToFile(const Filename: string); override;
 end;
pxmimage
RAW Image - TRAWImage
registers .dng, .crw, .cr2, .raf, .kdc, .nef,
.mrw, .orf, .ptx, .pef, .arw, .x3f and .raw
type
 TRAWImage = class(TBitmap)
 private
  loadmode: Integer;
 protected
 public
  function GetLoadMode: Integer;
  procedure SetLoadMode(mode: Integer);
  procedure LoadFromFile(const Filename: string); override;
 end;
pxmimage
TIF Image - TTIFImage
registers .tif and .tiff
type
 TTIFImage = class(TBitmap)
 private
 protected
 public
  procedure LoadFromFile(const Filename: string); override;
  procedure SaveToFile(const Filename: string); override;
 end;

AltPE plugins library
modulecontent
RedEye AltPE red-eyes plugin

Developed using Delphi,
 
  Graphics32 Library by Alex A. Denisov - http://g32.org/ and
 
  TPNGImage 1.4 by Gustavo Daud - http://pngdelphi.sourceforge.net/.
  ImageFileLib 1.14 for Delphi by Michael Vinther - http://logicnet.dk/lib.
  TGIFImage 2.2 by Anders Melander - http://www.melander.dk/delphi/gifimage/


Valentim Batista 2004 - timsara at softhome dot net