Unit rpictool

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

rpictool is set of graphic functions working with BMP, JPG, PNG and color + gradients.

Updated version compatible with Delphi2010+.

Overview

Classes, Interfaces, Objects and Records

Name Description
record TColorDefMap  

Functions and Procedures

function GetColorList(L: TStrings; AddExtendedColor, AddCustomColor, LocalizedName: boolean): integer;
function GetColorValue(idx: integer): TColor;
function GetColorName(idx: integer; LocalizedName: boolean): string;
function GetColorIdx(Color: TColor): integer; overload;
function GetColorIdx(const ColorName: string): integer; overload;
function ColorToString(Color: TColor; LocalizedName: boolean): string;
function StringToColor(const ColorStr: string): TColor;
procedure DrawGradientV(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor);
procedure DrawGradientH(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor);
procedure DrawGradient(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor; Vertical: boolean; MaxSteps: integer);
procedure AnimateResize(W: TControl; NewRect: TRect);
procedure DrawPictureCenter(Canvas: TCanvas; R: TRect; P: TPicture); overload;
procedure DrawPictureCenter(Canvas: TCanvas; R: TRect; P: TPicture; Stretch, Transparent: boolean); overload;
procedure DrawBmpCenter(Canvas: TCanvas; R: TRect; Bmp: TBitmap); overload;
procedure DrawBmpCenter(Canvas: TCanvas; R: TRect; Bmp: TBitmap; Stretch: boolean); overload;
procedure DrawPictureTiles(Canvas: TCanvas; R: TRect; P: TPicture; Transparent: boolean);
procedure DrawBmpTiles(Canvas: TCanvas; R: TRect; Bmp: TBitmap);
procedure SmoothResizeBitmap(Bmp: TBitmap; MaxW, MaxH: integer; SmallEnlarge: boolean);
procedure SmoothResizeToBitmap(Src, Dst: TBitmap);
procedure SmoothResizePicture(P: TPicture; MaxW, MaxH: integer; SmallEnlarge: boolean);
procedure RotateBitmap(Bmp: TBitmap; Angle: Double);
procedure RotateToBitmap(SrcBmp: TBitmap; DestBmp: TBitmap; Angle: Double);
procedure RotatePicture(P: TPicture; Angle: Double);
procedure ConvertBmpToIco(Bmp: TBitmap; Icon: TIcon; IconSize: integer);
function IsJPGSupported: boolean;
function IsPNGSupported: boolean;
function ReadPictureFromField(F: TField; P: TPicture): TrGraphicType;
function ReadBitmapFromField(F: TField; Bmp: TBitmap): TrGraphicType;
function WritePictureToField(F: TField; P: TPicture; FieldType: TrGraphicType): boolean;
function WriteBitmapToField(F: TField; Bmp: TBitmap; FieldType: TrGraphicType): boolean;
function LoadPictureFromFile(P: TPicture; const FileName: string; ShowErrorMessage: boolean = true): TrGraphicType;
function LoadBitmapFromFile(Bmp: TBitmap; const FileName: string; ShowErrorMessage: boolean = true): TrGraphicType;
function SavePictureToStream(P: TPicture; Stream: TStream; FileType: TrGraphicType): TrGraphicType;
function SaveBitmapToStream(Bmp: TBitmap; Stream: TStream; FileType: TrGraphicType): TrGraphicType;
function SavePictureToFile(P: TPicture; const FileName: string; FileType: TrGraphicType): TrGraphicType;
function SaveBitmapToFile(Bmp: TBitmap; const FileName: string; FileType: TrGraphicType): TrGraphicType;
function GetFileTypeFilterList(UseAllFormats: boolean): string;
function GetFileTypeExtension(GraphicType: TrGraphicType): string;
function GetFileTypeFromFileName(const FileName: string): TrGraphicType;
function OpenDlg_PictureFromFile(P: TPicture; const DefaultDir: string; DefaultGrType: TrGraphicType): TrGraphicType;
function SaveDlg_PictureToFile(P: TPicture; const DefaultDir: string; DefaultGrType: TrGraphicType): TrGraphicType;
function OpenDlg_GraphicFiles(D: TOpenDialog; MultiSelect, Execute: boolean; const DefaultDir: string; DefaultGrType: TrGraphicType): boolean;
function GetJPEGDimensions(const FileName: string; var X, Y: Word): boolean;
function WritePictureToJPGField(F: TField; P: TPicture; Quality: integer): boolean;
function WriteBitmapToJPGField(F: TField; Bmp: TBitmap; Quality: integer): boolean;
function SavePictureToJPGFile(P: TPicture; const FileName: string; Quality: integer): boolean;
function SaveBitmapToJPGFile(Bmp: TBitmap; const FileName: string; Quality: integer): boolean;

Types

TrGraphicType = (...);

Constants

cGradientStandardSteps = 100;
JPEGDefaultQuality = 100;
GraphicTypeLabel: array [0 .. 4] of string = ('None', 'Error', 'BMP', 'JPG', 'PNG');
ColorsDefArr: array [0 .. 20] of TColorDefMap = ((Value: clBlack; Name: sColorBlack; LocalizedName: sColorBlackLoc), (Value: clMaroon; Name: sColorMaroon; LocalizedName: sColorMaroonLoc), (Value: clGreen; Name: sColorGreen; LocalizedName: sColorGreenLoc), (Value: clOlive; Name: sColorOlive; LocalizedName: sColorOliveLoc), (Value: clNavy; Name: sColorNavy; LocalizedName: sColorNavyLoc), (Value: clPurple; Name: sColorPurple; LocalizedName: sColorPurpleLoc), (Value: clTeal; Name: sColorTeal; LocalizedName: sColorTealLoc), (Value: clGray; Name: sColorGray; LocalizedName: sColorGrayLoc), (Value: clSilver; Name: sColorSilver; LocalizedName: sColorSilverLoc), (Value: clRed; Name: sColorRed; LocalizedName: sColorRedLoc), (Value: clLime; Name: sColorLime; LocalizedName: sColorLimeLoc), (Value: clYellow; Name: sColorYellow; LocalizedName: sColorYellowLoc), (Value: clBlue; Name: sColorBlue; LocalizedName: sColorBlueLoc), (Value: clFuchsia; Name: sColorFuchsia; LocalizedName: sColorFuchsiaLoc), (Value: clAqua; Name: sColorAqua; LocalizedName: sColorAquaLoc), (Value: clWhite; Name: sColorWhite; LocalizedName: sColorWhiteLoc), (Value: clMoneyGreen; Name: sColorMoneyGreen; LocalizedName: sColorMoneyGreenLoc), (Value: clSkyBlue; Name: sColorSkyBlue; LocalizedName: sColorSkyBlueLoc) , (Value: clCream; Name: sColorCream; LocalizedName: sColorCreamLoc), (Value: clMedGray; Name: sColorMedGray; LocalizedName: sColorMedGrayLoc), (Value: clNone; Name: sColorCustom; LocalizedName: sColorCustomLoc));
ColorDefStandardCount = 16;
ColorDefExtendedCount = 4;
ColorDefCustomIdx = 20;

Description

Functions and Procedures

function GetColorList(L: TStrings; AddExtendedColor, AddCustomColor, LocalizedName: boolean): integer;

color functions

function GetColorValue(idx: integer): TColor;
 
function GetColorName(idx: integer; LocalizedName: boolean): string;
 
function GetColorIdx(Color: TColor): integer; overload;
 
function GetColorIdx(const ColorName: string): integer; overload;
 
function ColorToString(Color: TColor; LocalizedName: boolean): string;
 
function StringToColor(const ColorStr: string): TColor;
 
procedure DrawGradientV(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor);

draw gradient

procedure DrawGradientH(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor);
 
procedure DrawGradient(Canvas: TCanvas; ARect: TRect; FromColor, ToColor: TColor; Vertical: boolean; MaxSteps: integer);
 
procedure AnimateResize(W: TControl; NewRect: TRect);

animated resize of Control

procedure DrawPictureCenter(Canvas: TCanvas; R: TRect; P: TPicture); overload;

draw picture or bmp

procedure DrawPictureCenter(Canvas: TCanvas; R: TRect; P: TPicture; Stretch, Transparent: boolean); overload;
 
procedure DrawBmpCenter(Canvas: TCanvas; R: TRect; Bmp: TBitmap); overload;
 
procedure DrawBmpCenter(Canvas: TCanvas; R: TRect; Bmp: TBitmap; Stretch: boolean); overload;
 
procedure DrawPictureTiles(Canvas: TCanvas; R: TRect; P: TPicture; Transparent: boolean);
 
procedure DrawBmpTiles(Canvas: TCanvas; R: TRect; Bmp: TBitmap);
 
procedure SmoothResizeBitmap(Bmp: TBitmap; MaxW, MaxH: integer; SmallEnlarge: boolean);

resize BMP

procedure SmoothResizeToBitmap(Src, Dst: TBitmap);
 
procedure SmoothResizePicture(P: TPicture; MaxW, MaxH: integer; SmallEnlarge: boolean);
 
procedure RotateBitmap(Bmp: TBitmap; Angle: Double);

rotate bitmap

procedure RotateToBitmap(SrcBmp: TBitmap; DestBmp: TBitmap; Angle: Double);
 
procedure RotatePicture(P: TPicture; Angle: Double);
 
procedure ConvertBmpToIco(Bmp: TBitmap; Icon: TIcon; IconSize: integer);
 
function IsJPGSupported: boolean;

returns state according conditional compilation

function IsPNGSupported: boolean;
 
function ReadPictureFromField(F: TField; P: TPicture): TrGraphicType;

read/write picture from/to db field

function ReadBitmapFromField(F: TField; Bmp: TBitmap): TrGraphicType;
 
function WritePictureToField(F: TField; P: TPicture; FieldType: TrGraphicType): boolean;
 
function WriteBitmapToField(F: TField; Bmp: TBitmap; FieldType: TrGraphicType): boolean;
 
function LoadPictureFromFile(P: TPicture; const FileName: string; ShowErrorMessage: boolean = true): TrGraphicType;

load/save picture from/to file

function LoadBitmapFromFile(Bmp: TBitmap; const FileName: string; ShowErrorMessage: boolean = true): TrGraphicType;
 
function SavePictureToStream(P: TPicture; Stream: TStream; FileType: TrGraphicType): TrGraphicType;
 
function SaveBitmapToStream(Bmp: TBitmap; Stream: TStream; FileType: TrGraphicType): TrGraphicType;
 
function SavePictureToFile(P: TPicture; const FileName: string; FileType: TrGraphicType): TrGraphicType;
 
function SaveBitmapToFile(Bmp: TBitmap; const FileName: string; FileType: TrGraphicType): TrGraphicType;
 
function GetFileTypeFilterList(UseAllFormats: boolean): string;

open/save dialog function

function GetFileTypeExtension(GraphicType: TrGraphicType): string;
 
function GetFileTypeFromFileName(const FileName: string): TrGraphicType;
 
function OpenDlg_PictureFromFile(P: TPicture; const DefaultDir: string; DefaultGrType: TrGraphicType): TrGraphicType;
 
function SaveDlg_PictureToFile(P: TPicture; const DefaultDir: string; DefaultGrType: TrGraphicType): TrGraphicType;
 
function OpenDlg_GraphicFiles(D: TOpenDialog; MultiSelect, Execute: boolean; const DefaultDir: string; DefaultGrType: TrGraphicType): boolean;
 
function GetJPEGDimensions(const FileName: string; var X, Y: Word): boolean;

JPEG specific function

function WritePictureToJPGField(F: TField; P: TPicture; Quality: integer): boolean;
 
function WriteBitmapToJPGField(F: TField; Bmp: TBitmap; Quality: integer): boolean;
 
function SavePictureToJPGFile(P: TPicture; const FileName: string; Quality: integer): boolean;
 
function SaveBitmapToJPGFile(Bmp: TBitmap; const FileName: string; Quality: integer): boolean;
 

Types

TrGraphicType = (...);
 
Values
  • gtNone:  
  • gtError:  
  • gtBMP:  
  • gtJPG:  
  • gtPNG:  

Constants

cGradientStandardSteps = 100;
 
JPEGDefaultQuality = 100;

set jpeg quality for rDBGrid and RTFReport 0..100 100=best quality but large file

GraphicTypeLabel: array [0 .. 4] of string = ('None', 'Error', 'BMP', 'JPG', 'PNG');
 
ColorsDefArr: array [0 .. 20] of TColorDefMap = ((Value: clBlack; Name: sColorBlack; LocalizedName: sColorBlackLoc), (Value: clMaroon; Name: sColorMaroon; LocalizedName: sColorMaroonLoc), (Value: clGreen; Name: sColorGreen; LocalizedName: sColorGreenLoc), (Value: clOlive; Name: sColorOlive; LocalizedName: sColorOliveLoc), (Value: clNavy; Name: sColorNavy; LocalizedName: sColorNavyLoc), (Value: clPurple; Name: sColorPurple; LocalizedName: sColorPurpleLoc), (Value: clTeal; Name: sColorTeal; LocalizedName: sColorTealLoc), (Value: clGray; Name: sColorGray; LocalizedName: sColorGrayLoc), (Value: clSilver; Name: sColorSilver; LocalizedName: sColorSilverLoc), (Value: clRed; Name: sColorRed; LocalizedName: sColorRedLoc), (Value: clLime; Name: sColorLime; LocalizedName: sColorLimeLoc), (Value: clYellow; Name: sColorYellow; LocalizedName: sColorYellowLoc), (Value: clBlue; Name: sColorBlue; LocalizedName: sColorBlueLoc), (Value: clFuchsia; Name: sColorFuchsia; LocalizedName: sColorFuchsiaLoc), (Value: clAqua; Name: sColorAqua; LocalizedName: sColorAquaLoc), (Value: clWhite; Name: sColorWhite; LocalizedName: sColorWhiteLoc), (Value: clMoneyGreen; Name: sColorMoneyGreen; LocalizedName: sColorMoneyGreenLoc), (Value: clSkyBlue; Name: sColorSkyBlue; LocalizedName: sColorSkyBlueLoc) , (Value: clCream; Name: sColorCream; LocalizedName: sColorCreamLoc), (Value: clMedGray; Name: sColorMedGray; LocalizedName: sColorMedGrayLoc), (Value: clNone; Name: sColorCustom; LocalizedName: sColorCustomLoc));
 
ColorDefStandardCount = 16;
 
ColorDefExtendedCount = 4;
 
ColorDefCustomIdx = 20;
 

Author

Created

Nov 2010

Last Modified

Oct 2014


Generated by PasDoc 0.13.0 on 2016-02-19 08:14:10