You've already forked lazarus-ccr
jvcllaz: Remove JvGif unit, not working on Linux.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8072 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
<Description Value="JVCL Multimedia and image components (Run-time package): bmp animator, id3v1 and id3v2 tags, full color components and dialogs, gradient, gradient header, special progress bar, animated image"/>
|
<Description Value="JVCL Multimedia and image components (Run-time package): bmp animator, id3v1 and id3v2 tags, full color components and dialogs, gradient, gradient header, special progress bar, animated image"/>
|
||||||
<License Value="The JVCL is released in accordance with the MPL 1.1 license. To get your own copy or read it, go to http://www.mozilla.org/MPL/MPL-1.1.html. "/>
|
<License Value="The JVCL is released in accordance with the MPL 1.1 license. To get your own copy or read it, go to http://www.mozilla.org/MPL/MPL-1.1.html. "/>
|
||||||
<Version Major="1" Release="7"/>
|
<Version Major="1" Release="7"/>
|
||||||
<Files Count="20">
|
<Files Count="19">
|
||||||
<Item1>
|
<Item1>
|
||||||
<Filename Value="..\run\JvMM\jvspecialprogress.pas"/>
|
<Filename Value="..\run\JvMM\jvspecialprogress.pas"/>
|
||||||
<UnitName Value="JvSpecialProgress"/>
|
<UnitName Value="JvSpecialProgress"/>
|
||||||
@@ -93,10 +93,6 @@
|
|||||||
<Filename Value="..\run\JvMM\jvimagetransform.pas"/>
|
<Filename Value="..\run\JvMM\jvimagetransform.pas"/>
|
||||||
<UnitName Value="JvImageTransform"/>
|
<UnitName Value="JvImageTransform"/>
|
||||||
</Item19>
|
</Item19>
|
||||||
<Item20>
|
|
||||||
<Filename Value="..\run\JvMM\jvgif.pas"/>
|
|
||||||
<UnitName Value="JvGIF"/>
|
|
||||||
</Item20>
|
|
||||||
</Files>
|
</Files>
|
||||||
<CompatibilityMode Value="True"/>
|
<CompatibilityMode Value="True"/>
|
||||||
<RequiredPkgs Count="2">
|
<RequiredPkgs Count="2">
|
||||||
|
@@ -38,7 +38,7 @@ uses
|
|||||||
Windows, // before Types!
|
Windows, // before Types!
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, Graphics, Controls, ImgList,
|
Classes, Graphics, Controls, ImgList,
|
||||||
LCLType, LCLProc, LCLVersion, LMessages, Types, Forms,
|
LCLType, LCLProc, LCLVersion, LMessages, Types,
|
||||||
JvTypes;
|
JvTypes;
|
||||||
|
|
||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
@@ -128,7 +128,6 @@ function ChangeBitmapColor(Bitmap: TBitmap; Color, NewColor: TColor): TBitmap;
|
|||||||
procedure ImageListDrawDisabled(Images: TCustomImageList; Canvas: TCanvas;
|
procedure ImageListDrawDisabled(Images: TCustomImageList; Canvas: TCanvas;
|
||||||
X, Y, Index: Integer; HighLightColor, GrayColor: TColor;
|
X, Y, Index: Integer; HighLightColor, GrayColor: TColor;
|
||||||
DrawHighlight: Boolean);
|
DrawHighlight: Boolean);
|
||||||
|
|
||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
|
|
||||||
{$IFNDEF CLR}
|
{$IFNDEF CLR}
|
||||||
@@ -184,7 +183,6 @@ function PointInPolyRgn(const P: TPoint; const Points: array of TPoint): Boolean
|
|||||||
******************** NOT CONVERTED *)
|
******************** NOT CONVERTED *)
|
||||||
|
|
||||||
function PaletteColor(Color: TColor): Longint;
|
function PaletteColor(Color: TColor): Longint;
|
||||||
function GetNearestColor(hdc: THandle; AColor: TColor): TColor;
|
|
||||||
|
|
||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
procedure PaintInverseRect(const RectOrg, RectEnd: TPoint);
|
procedure PaintInverseRect(const RectOrg, RectEnd: TPoint);
|
||||||
@@ -240,9 +238,7 @@ procedure StretchBltTransparent(DstDC: HDC; DstX, DstY, DstW, DstH: Integer;
|
|||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
procedure DrawTransparentBitmap(DC: HDC; Bitmap: HBITMAP;
|
procedure DrawTransparentBitmap(DC: HDC; Bitmap: HBITMAP;
|
||||||
DstX, DstY: Integer; TransparentColor: TColorRef);
|
DstX, DstY: Integer; TransparentColor: TColorRef);
|
||||||
*)
|
|
||||||
function PaletteEntries(Palette: HPALETTE): Integer;
|
function PaletteEntries(Palette: HPALETTE): Integer;
|
||||||
(******************** NOT CONVERTED
|
|
||||||
procedure ShadeRect(DC: HDC; const Rect: TRect);
|
procedure ShadeRect(DC: HDC; const Rect: TRect);
|
||||||
|
|
||||||
function ScreenWorkArea: TRect;
|
function ScreenWorkArea: TRect;
|
||||||
@@ -472,19 +468,17 @@ procedure InternalSaveMDIChildren(MainForm: TForm; const AppStorage: TJvCustomAp
|
|||||||
procedure InternalRestoreMDIChildren(MainForm: TForm; const AppStorage: TJvCustomAppStorage; const StorePath: string);
|
procedure InternalRestoreMDIChildren(MainForm: TForm; const AppStorage: TJvCustomAppStorage; const StorePath: string);
|
||||||
|
|
||||||
{ end JvAppUtils }
|
{ end JvAppUtils }
|
||||||
************)
|
|
||||||
|
|
||||||
{ begin JvGraph }
|
{ begin JvGraph }
|
||||||
type
|
type
|
||||||
TMappingMethod = (mmHistogram, mmQuantize, mmTrunc784, mmTrunc666,
|
TMappingMethod = (mmHistogram, mmQuantize, mmTrunc784, mmTrunc666,
|
||||||
mmTripel, mmGrayscale);
|
mmTripel, mmGrayscale);
|
||||||
|
|
||||||
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
(*
|
|
||||||
function GetPaletteBitmapFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetPaletteBitmapFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
|
{$IFNDEF CLR}
|
||||||
procedure SetBitmapPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
procedure SetBitmapPixelFormat(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
||||||
Method: TMappingMethod);
|
Method: TMappingMethod);
|
||||||
*)
|
|
||||||
function BitmapToMemoryStream(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
function BitmapToMemoryStream(Bitmap: TBitmap; PixelFormat: TPixelFormat;
|
||||||
Method: TMappingMethod): TMemoryStream;
|
Method: TMappingMethod): TMemoryStream;
|
||||||
procedure GrayscaleBitmap(Bitmap: TBitmap);
|
procedure GrayscaleBitmap(Bitmap: TBitmap);
|
||||||
@@ -492,14 +486,14 @@ procedure GrayscaleBitmap(Bitmap: TBitmap);
|
|||||||
function BitmapToMemory(Bitmap: TBitmap; Colors: Integer): TStream;
|
function BitmapToMemory(Bitmap: TBitmap; Colors: Integer): TStream;
|
||||||
procedure SaveBitmapToFile(const FileName: string; Bitmap: TBitmap;
|
procedure SaveBitmapToFile(const FileName: string; Bitmap: TBitmap;
|
||||||
Colors: Integer);
|
Colors: Integer);
|
||||||
(*
|
{$ENDIF !CLR}
|
||||||
|
|
||||||
function ScreenPixelFormat: TPixelFormat;
|
function ScreenPixelFormat: TPixelFormat;
|
||||||
function ScreenColorCount: Integer;
|
function ScreenColorCount: Integer;
|
||||||
*)
|
|
||||||
var
|
var
|
||||||
DefaultMappingMethod: TMappingMethod = mmHistogram;
|
DefaultMappingMethod: TMappingMethod = mmHistogram;
|
||||||
(******************
|
|
||||||
function GetWorkareaRect(Monitor: TMonitor): TRect;
|
function GetWorkareaRect(Monitor: TMonitor): TRect;
|
||||||
function FindMonitor(Handle: HMONITOR): TMonitor;
|
function FindMonitor(Handle: HMONITOR): TMonitor;
|
||||||
|
|
||||||
@@ -870,12 +864,11 @@ function Scale96ToForm(ASize: Integer): Integer;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
sysutils, LCLIntf, GraphType, Math,
|
sysutils, LCLIntf, GraphType, Math, Forms,
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
CommCtrl,
|
CommCtrl,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
JvConsts, JvJCLUtils,
|
JvConsts, JvJCLUtils;
|
||||||
JvResources;
|
|
||||||
(********************
|
(********************
|
||||||
SysConst,
|
SysConst,
|
||||||
Consts,
|
Consts,
|
||||||
@@ -896,12 +889,7 @@ const
|
|||||||
RC_TileWallpaper = 'TileWallpaper';
|
RC_TileWallpaper = 'TileWallpaper';
|
||||||
RC_RunCpl = 'rundll32.exe shell32,Control_RunDLL ';
|
RC_RunCpl = 'rundll32.exe shell32,Control_RunDLL ';
|
||||||
{$ENDIF MSWINDOWS}
|
{$ENDIF MSWINDOWS}
|
||||||
*)
|
|
||||||
|
|
||||||
const
|
|
||||||
SInvalidBitmap = 'Invalid bitmap';
|
|
||||||
|
|
||||||
(*
|
|
||||||
function GetAppHandle: THandle;
|
function GetAppHandle: THandle;
|
||||||
begin
|
begin
|
||||||
Result := Application.Handle;
|
Result := Application.Handle;
|
||||||
@@ -2296,16 +2284,6 @@ begin
|
|||||||
Result := ColorToRGB(Color) or PaletteMask;
|
Result := ColorToRGB(Color) or PaletteMask;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Added for LCL. Note: NOT CORRECT ON NON-WINDOWS }
|
|
||||||
function GetNearestColor(hdc: THandle; AColor: TColor): TColor;
|
|
||||||
begin
|
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
Result := Windows.GetNearestColor(hdc, AColor);
|
|
||||||
{$ELSE}
|
|
||||||
Result := AColor;
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
(******************** NOT CONVERTED
|
(******************** NOT CONVERTED
|
||||||
function CreateRotatedFont(Font: TFont; Angle: Integer): HFONT;
|
function CreateRotatedFont(Font: TFont; Angle: Integer): HFONT;
|
||||||
@@ -2354,13 +2332,17 @@ begin
|
|||||||
end;
|
end;
|
||||||
Result := CreateFontIndirect(LogFont);
|
Result := CreateFontIndirect(LogFont);
|
||||||
end;
|
end;
|
||||||
*)
|
|
||||||
function PaletteEntries(Palette: HPALETTE): Integer;
|
function PaletteEntries(Palette: HPALETTE): Integer;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF CLR}
|
||||||
|
GetObject(Palette, 4, Result);
|
||||||
|
{$ELSE}
|
||||||
GetObject(Palette, SizeOf(Integer), @Result);
|
GetObject(Palette, SizeOf(Integer), @Result);
|
||||||
|
{$ENDIF CLR}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(******************
|
|
||||||
procedure Delay(MSecs: Int64);
|
procedure Delay(MSecs: Int64);
|
||||||
var
|
var
|
||||||
FirstTickCount, Now: Int64;
|
FirstTickCount, Now: Int64;
|
||||||
@@ -4471,10 +4453,9 @@ begin
|
|||||||
SwitchToWindow(Application.Handle, False);
|
SwitchToWindow(Application.Handle, False);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ end JvAppUtils }
|
{ end JvAppUtils }
|
||||||
*)
|
|
||||||
|
|
||||||
|
|
||||||
{ begin JvGraph }
|
{ begin JvGraph }
|
||||||
// (rom) moved here to make JvMaxMin obsolete
|
// (rom) moved here to make JvMaxMin obsolete
|
||||||
|
|
||||||
@@ -4490,7 +4471,11 @@ end;
|
|||||||
|
|
||||||
procedure InvalidBitmap;
|
procedure InvalidBitmap;
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF CLR}
|
||||||
raise EInvalidGraphic.Create(SInvalidBitmap);
|
raise EInvalidGraphic.Create(SInvalidBitmap);
|
||||||
|
{$ELSE}
|
||||||
|
raise EInvalidGraphic.CreateRes(@SInvalidBitmap);
|
||||||
|
{$ENDIF CLR}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function WidthBytes(I: Longint): Longint;
|
function WidthBytes(I: Longint): Longint;
|
||||||
@@ -4513,7 +4498,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
(*****************
|
|
||||||
|
|
||||||
function ScreenPixelFormat: TPixelFormat;
|
function ScreenPixelFormat: TPixelFormat;
|
||||||
var
|
var
|
||||||
@@ -4572,9 +4556,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFNDEF CLR}
|
|
||||||
*)
|
|
||||||
|
|
||||||
{ Quantizing }
|
{ Quantizing }
|
||||||
{ Quantizing procedures based on free C source code written by
|
{ Quantizing procedures based on free C source code written by
|
||||||
Joe C. Oliphant, CompuServe 71742, 1451, joe_oliphant att csufresno dott edu }
|
Joe C. Oliphant, CompuServe 71742, 1451, joe_oliphant att csufresno dott edu }
|
||||||
@@ -4585,6 +4566,34 @@ const
|
|||||||
type
|
type
|
||||||
TTriple = array [0..2] of Byte;
|
TTriple = array [0..2] of Byte;
|
||||||
|
|
||||||
|
{$IFDEF CLR}
|
||||||
|
TQColor = class;
|
||||||
|
PQColor = TQColor;
|
||||||
|
TQColor = class
|
||||||
|
RGB: TTriple;
|
||||||
|
NewColorIndex: Byte;
|
||||||
|
Count: Longint;
|
||||||
|
PNext: PQColor;
|
||||||
|
end;
|
||||||
|
|
||||||
|
PQColorArray = array of TQColor;
|
||||||
|
TQColorArray = array [0..MAX_COLORS - 1] of TQColor;
|
||||||
|
|
||||||
|
PQColorList = array of PQColor;
|
||||||
|
TQColorList = array [0..MaxListSize - 1] of PQColor;
|
||||||
|
|
||||||
|
TNewColor = record
|
||||||
|
RGBMin: TTriple;
|
||||||
|
RGBWidth: TTriple;
|
||||||
|
NumEntries: Longint;
|
||||||
|
Count: Longint;
|
||||||
|
QuantizedColors: PQColor;
|
||||||
|
end;
|
||||||
|
PNewColor = TNewColor;
|
||||||
|
|
||||||
|
PNewColorArray = array of TNewColor;
|
||||||
|
TNewColorArray = array [Byte] of TNewColor;
|
||||||
|
{$ELSE}
|
||||||
PQColor = ^TQColor;
|
PQColor = ^TQColor;
|
||||||
TQColor = record
|
TQColor = record
|
||||||
RGB: TTriple;
|
RGB: TTriple;
|
||||||
@@ -4597,9 +4606,9 @@ type
|
|||||||
TQColorArray = array [0..MAX_COLORS - 1] of TQColor;
|
TQColorArray = array [0..MAX_COLORS - 1] of TQColor;
|
||||||
|
|
||||||
PQColorList = ^TQColorList;
|
PQColorList = ^TQColorList;
|
||||||
TQColorList = array [0..{$IFDEF RTL230_UP}MaxInt div 16{$ELSE}MaxListSize{$ENDIF RTL230_UP} - 1] of PQColor;
|
TQColorList = array [0..MaxListSize - 1] of PQColor;
|
||||||
|
|
||||||
PNewColor = {%H-}^TNewColor;
|
PNewColor = ^TNewColor;
|
||||||
TNewColor = record
|
TNewColor = record
|
||||||
RGBMin: TTriple;
|
RGBMin: TTriple;
|
||||||
RGBWidth: TTriple;
|
RGBWidth: TTriple;
|
||||||
@@ -4610,8 +4619,9 @@ type
|
|||||||
|
|
||||||
PNewColorArray = ^TNewColorArray;
|
PNewColorArray = ^TNewColorArray;
|
||||||
TNewColorArray = array [Byte] of TNewColor;
|
TNewColorArray = array [Byte] of TNewColor;
|
||||||
|
{$ENDIF CLR}
|
||||||
|
|
||||||
procedure PInsert(ColorList: PQColorList;
|
procedure PInsert(ColorList: PQColorList; {$IFDEF CLR}Offset: Integer;{$ENDIF}
|
||||||
Number: Integer; SortRGBAxis: Integer);
|
Number: Integer; SortRGBAxis: Integer);
|
||||||
var
|
var
|
||||||
Q1, Q2: PQColor;
|
Q1, Q2: PQColor;
|
||||||
@@ -4620,22 +4630,22 @@ var
|
|||||||
begin
|
begin
|
||||||
for I := 1 to Number - 1 do
|
for I := 1 to Number - 1 do
|
||||||
begin
|
begin
|
||||||
Temp := ColorList[I];
|
Temp := ColorList[{$IFDEF CLR}Offset +{$ENDIF}I];
|
||||||
J := I - 1;
|
J := I - 1;
|
||||||
while J >= 0 do
|
while J >= 0 do
|
||||||
begin
|
begin
|
||||||
Q1 := Temp;
|
Q1 := Temp;
|
||||||
Q2 := ColorList[J];
|
Q2 := ColorList[{$IFDEF CLR}Offset +{$ENDIF}J];
|
||||||
if Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis] > 0 then
|
if Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis] > 0 then
|
||||||
Break;
|
Break;
|
||||||
ColorList[J + 1] := ColorList[J];
|
ColorList[{$IFDEF CLR}Offset +{$ENDIF}J + 1] := ColorList[{$IFDEF CLR}Offset +{$ENDIF}J];
|
||||||
Dec(J);
|
Dec(J);
|
||||||
end;
|
end;
|
||||||
ColorList[J + 1] := Temp;
|
ColorList[{$IFDEF CLR}Offset +{$ENDIF}J + 1] := Temp;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure PSort(ColorList: PQColorList;
|
procedure PSort(ColorList: PQColorList; {$IFDEF CLR}Offset: Integer;{$ENDIF}
|
||||||
Number: Integer; SortRGBAxis: Integer);
|
Number: Integer; SortRGBAxis: Integer);
|
||||||
var
|
var
|
||||||
Q1, Q2: PQColor;
|
Q1, Q2: PQColor;
|
||||||
@@ -4644,46 +4654,61 @@ var
|
|||||||
begin
|
begin
|
||||||
if Number < 8 then
|
if Number < 8 then
|
||||||
begin
|
begin
|
||||||
PInsert(ColorList, Number, SortRGBAxis);
|
PInsert(ColorList, {$IFDEF CLR}Offset, {$ENDIF} Number, SortRGBAxis);
|
||||||
Exit;
|
Exit;
|
||||||
end;
|
end;
|
||||||
Part := ColorList[Number div 2];
|
Part := ColorList[{$IFDEF CLR}Offset +{$ENDIF} Number div 2];
|
||||||
I := -1;
|
I := -1;
|
||||||
J := Number;
|
J := Number;
|
||||||
repeat
|
repeat
|
||||||
repeat
|
repeat
|
||||||
Inc(I);
|
Inc(I);
|
||||||
Q1 := ColorList[I];
|
Q1 := ColorList[{$IFDEF CLR}Offset +{$ENDIF} I];
|
||||||
Q2 := Part;
|
Q2 := Part;
|
||||||
N := Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis];
|
N := Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis];
|
||||||
until N >= 0;
|
until N >= 0;
|
||||||
repeat
|
repeat
|
||||||
Dec(J);
|
Dec(J);
|
||||||
Q1 := ColorList[J];
|
Q1 := ColorList[{$IFDEF CLR}Offset +{$ENDIF} J];
|
||||||
Q2 := Part;
|
Q2 := Part;
|
||||||
N := Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis];
|
N := Q1.RGB[SortRGBAxis] - Q2.RGB[SortRGBAxis];
|
||||||
until N <= 0;
|
until N <= 0;
|
||||||
if I >= J then
|
if I >= J then
|
||||||
Break;
|
Break;
|
||||||
Temp := ColorList[I];
|
Temp := ColorList[{$IFDEF CLR}Offset +{$ENDIF} I];
|
||||||
ColorList[I] := ColorList[J];
|
ColorList[{$IFDEF CLR}Offset +{$ENDIF} I] := ColorList[{$IFDEF CLR}Offset +{$ENDIF} J];
|
||||||
ColorList[J] := Temp;
|
ColorList[{$IFDEF CLR}Offset +{$ENDIF} J] := Temp;
|
||||||
until False;
|
until False;
|
||||||
Nr := Number - I;
|
Nr := Number - I;
|
||||||
if I < Number div 2 then
|
if I < Number div 2 then
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF CLR}
|
||||||
|
PSort(ColorList, Offset, I, SortRGBAxis);
|
||||||
|
PSort(ColorList, Offset + I, Nr, SortRGBAxis);
|
||||||
|
{$ELSE}
|
||||||
PSort(ColorList, I, SortRGBAxis);
|
PSort(ColorList, I, SortRGBAxis);
|
||||||
PSort(PQColorList(@ColorList[I]), Nr, SortRGBAxis);
|
PSort(PQColorList(@ColorList[I]), Nr, SortRGBAxis);
|
||||||
|
{$ENDIF CLR}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF CLR}
|
||||||
|
PSort(ColorList, Offset + I, Nr, SortRGBAxis);
|
||||||
|
PSort(ColorList, Offset, I, SortRGBAxis);
|
||||||
|
{$ELSE}
|
||||||
PSort(PQColorList(@ColorList[I]), Nr, SortRGBAxis);
|
PSort(PQColorList(@ColorList[I]), Nr, SortRGBAxis);
|
||||||
PSort(ColorList, I, SortRGBAxis);
|
PSort(ColorList, I, SortRGBAxis);
|
||||||
|
{$ENDIF CLR}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFDEF CLR}
|
||||||
|
function DivideMap(var NewColorSubdiv: PNewColorArray; ColorMapSize: Integer;
|
||||||
|
var NewColormapSize: Integer; var LPSTR: PQColorArray; Offset: Integer): Integer;
|
||||||
|
{$ELSE}
|
||||||
function DivideMap(NewColorSubdiv: PNewColorArray; ColorMapSize: Integer;
|
function DivideMap(NewColorSubdiv: PNewColorArray; ColorMapSize: Integer;
|
||||||
var NewColormapSize: Integer; LPSTR: Pointer): Integer;
|
var NewColormapSize: Integer; LPSTR: Pointer): Integer;
|
||||||
|
{$ENDIF CLR}
|
||||||
var
|
var
|
||||||
I, J: Integer;
|
I, J: Integer;
|
||||||
MaxSize, Index: Integer;
|
MaxSize, Index: Integer;
|
||||||
@@ -4722,16 +4747,16 @@ begin
|
|||||||
while (J < NewColorSubdiv[Index].NumEntries) and
|
while (J < NewColorSubdiv[Index].NumEntries) and
|
||||||
(QuantizedColor <> nil) do
|
(QuantizedColor <> nil) do
|
||||||
begin
|
begin
|
||||||
SortArray[J] := QuantizedColor;
|
SortArray[{$IFDEF CLR}Offset +{$ENDIF} J] := QuantizedColor;
|
||||||
Inc(J);
|
Inc(J);
|
||||||
QuantizedColor := QuantizedColor.PNext;
|
QuantizedColor := QuantizedColor.PNext;
|
||||||
end;
|
end;
|
||||||
PSort(SortArray, NewColorSubdiv[Index].NumEntries, SortRGBAxis);
|
PSort(SortArray, {$IFDEF CLR}Offset,{$ENDIF} NewColorSubdiv[Index].NumEntries, SortRGBAxis);
|
||||||
for J := 0 to NewColorSubdiv[Index].NumEntries - 2 do
|
for J := 0 to NewColorSubdiv[Index].NumEntries - 2 do
|
||||||
SortArray[J].PNext := SortArray[J + 1];
|
SortArray[{$IFDEF CLR}Offset +{$ENDIF} J].PNext := SortArray[{$IFDEF CLR}Offset +{$ENDIF} J + 1];
|
||||||
SortArray[NewColorSubdiv[Index].NumEntries - 1].PNext := nil;
|
SortArray[{$IFDEF CLR}Offset +{$ENDIF} NewColorSubdiv[Index].NumEntries - 1].PNext := nil;
|
||||||
NewColorSubdiv[Index].QuantizedColors := SortArray[0];
|
NewColorSubdiv[Index].QuantizedColors := SortArray[{$IFDEF CLR}Offset +{$ENDIF} 0];
|
||||||
QuantizedColor := SortArray[0];
|
QuantizedColor := SortArray[{$IFDEF CLR}Offset +{$ENDIF} 0];
|
||||||
Sum := NewColorSubdiv[Index].Count div 2 - QuantizedColor.Count;
|
Sum := NewColorSubdiv[Index].Count div 2 - QuantizedColor.Count;
|
||||||
NumEntries := 1;
|
NumEntries := 1;
|
||||||
Count := QuantizedColor.Count;
|
Count := QuantizedColor.Count;
|
||||||
@@ -4770,13 +4795,14 @@ begin
|
|||||||
Result := 1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFNDEF CLR}
|
||||||
function Quantize(const Bmp: TBitmapInfoHeader; gptr, Data8: Pointer;
|
function Quantize(const Bmp: TBitmapInfoHeader; gptr, Data8: Pointer;
|
||||||
var ColorCount: Integer; var OutputColormap: TRGBPalette): Integer;
|
var ColorCount: Integer; var OutputColormap: TRGBPalette): Integer;
|
||||||
type
|
type
|
||||||
PWord = ^Word;
|
PWord = ^Word;
|
||||||
var
|
var
|
||||||
P: PByteArray;
|
P: PByteArray;
|
||||||
LineBuffer, Data: PAnsiChar;
|
LineBuffer, Data: Pointer;
|
||||||
LineWidth: Longint;
|
LineWidth: Longint;
|
||||||
TmpLineWidth, NewLineWidth: Longint;
|
TmpLineWidth, NewLineWidth: Longint;
|
||||||
I, J: Longint;
|
I, J: Longint;
|
||||||
@@ -4784,7 +4810,7 @@ var
|
|||||||
NewColormapSize, NumOfEntries: Integer;
|
NewColormapSize, NumOfEntries: Integer;
|
||||||
Mems: Longint;
|
Mems: Longint;
|
||||||
cRed, cGreen, cBlue: Longint;
|
cRed, cGreen, cBlue: Longint;
|
||||||
LPSTR, Temp, Tmp: PAnsiChar;
|
LPSTR, Temp, Tmp: Pointer;
|
||||||
NewColorSubdiv: PNewColorArray;
|
NewColorSubdiv: PNewColorArray;
|
||||||
ColorArrayEntries: PQColorArray;
|
ColorArrayEntries: PQColorArray;
|
||||||
QuantizedColor: PQColor;
|
QuantizedColor: PQColor;
|
||||||
@@ -4793,15 +4819,17 @@ begin
|
|||||||
Mems := (Longint(SizeOf(TQColor)) * (MAX_COLORS)) +
|
Mems := (Longint(SizeOf(TQColor)) * (MAX_COLORS)) +
|
||||||
(Longint(SizeOf(TNewColor)) * 256) + LineWidth +
|
(Longint(SizeOf(TNewColor)) * 256) + LineWidth +
|
||||||
(Longint(SizeOf(PQColor)) * (MAX_COLORS));
|
(Longint(SizeOf(PQColor)) * (MAX_COLORS));
|
||||||
LPSTR := AllocMem(Mems);
|
LPSTR := AllocMemo(Mems);
|
||||||
try
|
try
|
||||||
Temp := AllocMem(Longint(Bmp.biWidth) * Longint(Bmp.biHeight) * SizeOf(Word));
|
Temp := AllocMemo(Longint(Bmp.biWidth) * Longint(Bmp.biHeight) *
|
||||||
|
SizeOf(Word));
|
||||||
try
|
try
|
||||||
ColorArrayEntries := PQColorArray(LPSTR);
|
ColorArrayEntries := PQColorArray(LPSTR);
|
||||||
NewColorSubdiv := PNewColorArray(LPSTR + Longint(SizeOf(TQColor)) * (MAX_COLORS));
|
NewColorSubdiv := PNewColorArray(HugeOffset(LPSTR,
|
||||||
LineBuffer := LPSTR + (Longint(SizeOf(TQColor)) * (MAX_COLORS))
|
Longint(SizeOf(TQColor)) * (MAX_COLORS)));
|
||||||
|
LineBuffer := HugeOffset(LPSTR, (Longint(SizeOf(TQColor)) * (MAX_COLORS))
|
||||||
+
|
+
|
||||||
(Longint(SizeOf(TNewColor)) * 256);
|
(Longint(SizeOf(TNewColor)) * 256));
|
||||||
for I := 0 to MAX_COLORS - 1 do
|
for I := 0 to MAX_COLORS - 1 do
|
||||||
begin
|
begin
|
||||||
ColorArrayEntries^[I].RGB[0] := I shr 8;
|
ColorArrayEntries^[I].RGB[0] := I shr 8;
|
||||||
@@ -4812,16 +4840,17 @@ begin
|
|||||||
Tmp := Temp;
|
Tmp := Temp;
|
||||||
for I := 0 to Bmp.biHeight - 1 do
|
for I := 0 to Bmp.biHeight - 1 do
|
||||||
begin
|
begin
|
||||||
Move(Pointer(PAnsiChar(gptr) + (Bmp.biHeight - 1 - I) * LineWidth)^, LineBuffer^, LineWidth);
|
HMemCpy(LineBuffer, HugeOffset(gptr, (Bmp.biHeight - 1 - I) *
|
||||||
P := PByteArray(LineBuffer);
|
LineWidth), LineWidth);
|
||||||
|
P := LineBuffer;
|
||||||
for J := 0 to Bmp.biWidth - 1 do
|
for J := 0 to Bmp.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
Index := (Longint(P^[2] and $F0) shl 4) +
|
Index := (Longint(P^[2] and $F0) shl 4) +
|
||||||
Longint(P^[1] and $F0) + (Longint(P^[0] and $F0) shr 4);
|
Longint(P^[1] and $F0) + (Longint(P^[0] and $F0) shr 4);
|
||||||
Inc(ColorArrayEntries^[Index].Count);
|
Inc(ColorArrayEntries^[Index].Count);
|
||||||
Inc(PByte(P), 3);
|
P := HugeOffset(P, 3);
|
||||||
PWord(Tmp)^ := Index;
|
PWord(Tmp)^ := Index;
|
||||||
Inc(Tmp, 2);
|
Tmp := HugeOffset(Tmp, 2);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
for I := 0 to 255 do
|
for I := 0 to 255 do
|
||||||
@@ -4861,7 +4890,8 @@ begin
|
|||||||
NewColorSubdiv^[0].Count := Longint(Bmp.biWidth) * Longint(Bmp.biHeight);
|
NewColorSubdiv^[0].Count := Longint(Bmp.biWidth) * Longint(Bmp.biHeight);
|
||||||
NewColormapSize := 1;
|
NewColormapSize := 1;
|
||||||
DivideMap(NewColorSubdiv, ColorCount, NewColormapSize,
|
DivideMap(NewColorSubdiv, ColorCount, NewColormapSize,
|
||||||
LPSTR + Longint(SizeOf(TQColor)) * (MAX_COLORS) + Longint(SizeOf(TNewColor)) * 256 + LineWidth);
|
HugeOffset(LPSTR, Longint(SizeOf(TQColor)) * (MAX_COLORS) +
|
||||||
|
Longint(SizeOf(TNewColor)) * 256 + LineWidth));
|
||||||
if NewColormapSize < ColorCount then
|
if NewColormapSize < ColorCount then
|
||||||
begin
|
begin
|
||||||
for I := NewColormapSize to ColorCount - 1 do
|
for I := NewColormapSize to ColorCount - 1 do
|
||||||
@@ -4900,32 +4930,31 @@ begin
|
|||||||
FillChar(Data8^, NewLineWidth * Bmp.biHeight, #0);
|
FillChar(Data8^, NewLineWidth * Bmp.biHeight, #0);
|
||||||
for I := 0 to Bmp.biHeight - 1 do
|
for I := 0 to Bmp.biHeight - 1 do
|
||||||
begin
|
begin
|
||||||
LineBuffer := Temp + (Bmp.biHeight - 1 - I) * TmpLineWidth;
|
LineBuffer := HugeOffset(Temp, (Bmp.biHeight - 1 - I) * TmpLineWidth);
|
||||||
Data := PAnsiChar(Data8) + I * NewLineWidth;
|
Data := HugeOffset(Data8, I * NewLineWidth);
|
||||||
for J := 0 to Bmp.biWidth - 1 do
|
for J := 0 to Bmp.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
PByte(Data)^ := ColorArrayEntries^[PWord(LineBuffer)^].NewColorIndex;
|
PByte(Data)^ := ColorArrayEntries^[PWord(LineBuffer)^].NewColorIndex;
|
||||||
Inc(LineBuffer, 2);
|
LineBuffer := HugeOffset(LineBuffer, 2);
|
||||||
Inc(Data);
|
Data := HugeOffset(Data, 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(Temp);
|
FreeMemo(Temp);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(LPSTR);
|
FreeMemo(LPSTR);
|
||||||
end;
|
end;
|
||||||
ColorCount := NewColormapSize;
|
ColorCount := NewColormapSize;
|
||||||
Result := 0;
|
Result := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{
|
||||||
{ ------------------------------------------------------------------------------
|
|
||||||
Procedures to truncate to lower bits-per-pixel, grayscale, tripel and
|
Procedures to truncate to lower bits-per-pixel, grayscale, tripel and
|
||||||
histogram conversion based on freeware C source code of GBM package by
|
histogram conversion based on freeware C source code of GBM package by
|
||||||
Andy Key (nyangau att interalpha dott co dott uk). The home page of GBM
|
Andy Key (nyangau att interalpha dott co dott uk). The home page of GBM
|
||||||
author is at http://www.interalpha.net/customer/nyangau/.
|
author is at http://www.interalpha.net/customer/nyangau/.
|
||||||
-------------------------------------------------------------------------------}
|
}
|
||||||
|
|
||||||
{ Truncate to lower bits per pixel }
|
{ Truncate to lower bits per pixel }
|
||||||
|
|
||||||
@@ -5004,7 +5033,8 @@ begin
|
|||||||
SrcScanline := (Header.biWidth * 3 + 3) and not 3;
|
SrcScanline := (Header.biWidth * 3 + 3) and not 3;
|
||||||
DstScanline := ((Header.biWidth * DstBitsPerPixel + 31) div 32) * 4;
|
DstScanline := ((Header.biWidth * DstBitsPerPixel + 31) div 32) * 4;
|
||||||
for Y := 0 to Header.biHeight - 1 do
|
for Y := 0 to Header.biHeight - 1 do
|
||||||
TruncLineProc(PAnsiChar(Src) + Y * SrcScanline, PAnsiChar(Dest) + Y * DstScanline, Header.biWidth);
|
TruncLineProc(HugeOffset(Src, Y * SrcScanline),
|
||||||
|
HugeOffset(Dest, Y * DstScanline), Header.biWidth);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ return 6Rx6Gx6B palette
|
{ return 6Rx6Gx6B palette
|
||||||
@@ -5041,13 +5071,13 @@ begin
|
|||||||
for X := 0 to CX - 1 do
|
for X := 0 to CX - 1 do
|
||||||
begin
|
begin
|
||||||
B := TruncIndex06[Byte(Src^)];
|
B := TruncIndex06[Byte(Src^)];
|
||||||
Inc(PByte(Src));
|
Src := HugeOffset(Src, 1);
|
||||||
G := TruncIndex06[Byte(Src^)];
|
G := TruncIndex06[Byte(Src^)];
|
||||||
Inc(PByte(Src));
|
Src := HugeOffset(Src, 1);
|
||||||
R := TruncIndex06[Byte(Src^)];
|
R := TruncIndex06[Byte(Src^)];
|
||||||
Inc(PByte(Src), 1);
|
Src := HugeOffset(Src, 1);
|
||||||
PByte(Dest)^ := 6 * (6 * R + G) + B;
|
PByte(Dest)^ := 6 * (6 * R + G) + B;
|
||||||
Inc(PByte(Dest));
|
Dest := HugeOffset(Dest, 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -5094,13 +5124,13 @@ begin
|
|||||||
for X := 0 to CX - 1 do
|
for X := 0 to CX - 1 do
|
||||||
begin
|
begin
|
||||||
B := TruncIndex04[Byte(Src^)];
|
B := TruncIndex04[Byte(Src^)];
|
||||||
Inc(PByte(Src));
|
Src := HugeOffset(Src, 1);
|
||||||
G := TruncIndex08[Byte(Src^)];
|
G := TruncIndex08[Byte(Src^)];
|
||||||
Inc(PByte(Src));
|
Src := HugeOffset(Src, 1);
|
||||||
R := TruncIndex07[Byte(Src^)];
|
R := TruncIndex07[Byte(Src^)];
|
||||||
Inc(PByte(Src));
|
Src := HugeOffset(Src, 1);
|
||||||
PByte(Dest)^ := 4 * (8 * R + G) + B;
|
PByte(Dest)^ := 4 * (8 * R + G) + B;
|
||||||
Inc(PByte(Dest));
|
Dest := HugeOffset(Dest, 1);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -5139,20 +5169,19 @@ begin
|
|||||||
for X := 0 to Header.biWidth - 1 do
|
for X := 0 to Header.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
B := Src^;
|
B := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
G := Src^;
|
G := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
R := Src^;
|
R := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
Dest^ := Byte(Longint(Word(R) * 77 + Word(G) * 150 + Word(B) * 29) shr 8);
|
Dest^ := Byte(Longint(Word(R) * 77 + Word(G) * 150 + Word(B) * 29) shr 8);
|
||||||
Inc(Dest);
|
Dest := HugeOffset(Dest, 1);
|
||||||
end;
|
end;
|
||||||
Data24 := PAnsiChar(Data24) + SrcScanline;
|
Data24 := HugeOffset(Data24, SrcScanline);
|
||||||
Data8 := PAnsiChar(Data8) + DstScanline;
|
Data8 := HugeOffset(Data8, DstScanline);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Tripel conversion }
|
{ Tripel conversion }
|
||||||
|
|
||||||
procedure TripelPal(var Colors: TRGBPalette);
|
procedure TripelPal(var Colors: TRGBPalette);
|
||||||
@@ -5184,24 +5213,23 @@ begin
|
|||||||
for X := 0 to Header.biWidth - 1 do
|
for X := 0 to Header.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
B := Src^;
|
B := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
G := Src^;
|
G := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
R := Src^;
|
R := Src^;
|
||||||
Inc(Src);
|
Src := HugeOffset(Src, 1);
|
||||||
case ((X + Y) mod 3) of
|
case ((X + Y) mod 3) of
|
||||||
0: Dest^ := Byte(R shr 2);
|
0: Dest^ := Byte(R shr 2);
|
||||||
1: Dest^ := Byte($40 + (G shr 2));
|
1: Dest^ := Byte($40 + (G shr 2));
|
||||||
2: Dest^ := Byte($80 + (B shr 2));
|
2: Dest^ := Byte($80 + (B shr 2));
|
||||||
end;
|
end;
|
||||||
Inc(Dest);
|
Dest := HugeOffset(Dest, 1);
|
||||||
end;
|
end;
|
||||||
Data24 := PAnsiChar(Data24) + SrcScanline;
|
Data24 := HugeOffset(Data24, SrcScanline);
|
||||||
Data8 := PAnsiChar(Data8) + DstScanline;
|
Data8 := HugeOffset(Data8, DstScanline);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Histogram/Frequency-of-use method of color reduction }
|
{ Histogram/Frequency-of-use method of color reduction }
|
||||||
|
|
||||||
const
|
const
|
||||||
@@ -5214,7 +5242,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
type
|
type
|
||||||
PFreqRecord = {%H-}^TFreqRecord;
|
PFreqRecord = ^TFreqRecord;
|
||||||
TFreqRecord = record
|
TFreqRecord = record
|
||||||
B: Byte;
|
B: Byte;
|
||||||
G: Byte;
|
G: Byte;
|
||||||
@@ -5284,11 +5312,11 @@ begin
|
|||||||
for X := 0 to Header.biWidth - 1 do
|
for X := 0 to Header.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
B := Byte(Data24^) and BM;
|
B := Byte(Data24^) and BM;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
G := Byte(Data24^) and Gm;
|
G := Byte(Data24^) and Gm;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
R := Byte(Data24^) and Rm;
|
R := Byte(Data24^) and Rm;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
HashColor := Hash(R, G, B);
|
HashColor := Hash(R, G, B);
|
||||||
repeat
|
repeat
|
||||||
Index := Hist.HashTable[HashColor];
|
Index := Hist.HashTable[HashColor];
|
||||||
@@ -5322,7 +5350,7 @@ begin
|
|||||||
Inc(Hist.Freqs[Index].Frequency);
|
Inc(Hist.Freqs[Index].Frequency);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
Inc(PByte(Data24), Step24);
|
Data24 := HugeOffset(Data24, Step24);
|
||||||
end;
|
end;
|
||||||
Hist.ColCount := ColCount;
|
Hist.ColCount := ColCount;
|
||||||
Result := True;
|
Result := True;
|
||||||
@@ -5412,11 +5440,11 @@ begin
|
|||||||
for X := 0 to Header.biWidth - 1 do
|
for X := 0 to Header.biWidth - 1 do
|
||||||
begin
|
begin
|
||||||
B := Byte(Data24^) and BM;
|
B := Byte(Data24^) and BM;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
G := Byte(Data24^) and Gm;
|
G := Byte(Data24^) and Gm;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
R := Byte(Data24^) and Rm;
|
R := Byte(Data24^) and Rm;
|
||||||
Inc(PByte(Data24));
|
Data24 := HugeOffset(Data24, 1);
|
||||||
HashColor := Hash(R, G, B);
|
HashColor := Hash(R, G, B);
|
||||||
repeat
|
repeat
|
||||||
Index := Hist.HashTable[HashColor];
|
Index := Hist.HashTable[HashColor];
|
||||||
@@ -5428,10 +5456,10 @@ begin
|
|||||||
HashColor := 0;
|
HashColor := 0;
|
||||||
until False;
|
until False;
|
||||||
PByte(Data8)^ := Hist.Freqs[Index].Nearest;
|
PByte(Data8)^ := Hist.Freqs[Index].Nearest;
|
||||||
Inc(PByte(Data8));
|
Data8 := HugeOffset(Data8, 1);
|
||||||
end;
|
end;
|
||||||
Inc(PByte(Data24), Step24);
|
Data24 := HugeOffset(Data24, Step24);
|
||||||
Inc(PByte(Data8), Step8);
|
Data8 := HugeOffset(Data8, Step8);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -5467,7 +5495,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
|
||||||
{ expand to 24 bits-per-pixel }
|
{ expand to 24 bits-per-pixel }
|
||||||
|
|
||||||
(-*
|
(-*
|
||||||
@@ -5585,7 +5612,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
************)
|
|
||||||
|
|
||||||
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
function GetBitmapPixelFormat(Bitmap: TBitmap): TPixelFormat;
|
||||||
begin
|
begin
|
||||||
@@ -5600,6 +5627,9 @@ begin
|
|||||||
Result := Result div 8;
|
Result := Result div 8;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFNDEF CLR}
|
||||||
|
|
||||||
|
|
||||||
procedure InitializeBitmapInfoHeader(Bitmap: HBITMAP; var BI: TBitmapInfoHeader;
|
procedure InitializeBitmapInfoHeader(Bitmap: HBITMAP; var BI: TBitmapInfoHeader;
|
||||||
PixelFormat: TPixelFormat);
|
PixelFormat: TPixelFormat);
|
||||||
var
|
var
|
||||||
@@ -5652,7 +5682,6 @@ procedure InternalGetDIBSizes(Bitmap: HBITMAP; var InfoHeaderSize: Integer;
|
|||||||
var
|
var
|
||||||
BI: TBitmapInfoHeader;
|
BI: TBitmapInfoHeader;
|
||||||
begin
|
begin
|
||||||
BI := Default(TBitmapInfoHeader);
|
|
||||||
InitializeBitmapInfoHeader(Bitmap, BI, BitCount);
|
InitializeBitmapInfoHeader(Bitmap, BI, BitCount);
|
||||||
if BI.biBitCount > 8 then
|
if BI.biBitCount > 8 then
|
||||||
begin
|
begin
|
||||||
@@ -5704,8 +5733,8 @@ end;
|
|||||||
function DIBFromBit(Src: HBITMAP; Pal: HPALETTE; PixelFormat: TPixelFormat;
|
function DIBFromBit(Src: HBITMAP; Pal: HPALETTE; PixelFormat: TPixelFormat;
|
||||||
var Length: Longint): Pointer;
|
var Length: Longint): Pointer;
|
||||||
var
|
var
|
||||||
HeaderSize: Integer = 0;
|
HeaderSize: Integer;
|
||||||
ImageSize: Longint = 0;
|
ImageSize: Longint;
|
||||||
FileHeader: PBitmapFileHeader;
|
FileHeader: PBitmapFileHeader;
|
||||||
BI: PBitmapInfoHeader;
|
BI: PBitmapInfoHeader;
|
||||||
Bits: Pointer;
|
Bits: Pointer;
|
||||||
@@ -5714,7 +5743,7 @@ begin
|
|||||||
InvalidBitmap;
|
InvalidBitmap;
|
||||||
InternalGetDIBSizes(Src, HeaderSize, ImageSize, PixelFormat);
|
InternalGetDIBSizes(Src, HeaderSize, ImageSize, PixelFormat);
|
||||||
Length := SizeOf(TBitmapFileHeader) + HeaderSize + ImageSize;
|
Length := SizeOf(TBitmapFileHeader) + HeaderSize + ImageSize;
|
||||||
Result := AllocMem(Length);
|
Result := AllocMemo(Length);
|
||||||
try
|
try
|
||||||
FillChar(Result^, Length, 0);
|
FillChar(Result^, Length, 0);
|
||||||
FileHeader := Result;
|
FileHeader := Result;
|
||||||
@@ -5724,11 +5753,11 @@ begin
|
|||||||
bfSize := Length;
|
bfSize := Length;
|
||||||
bfOffBits := SizeOf(FileHeader^) + HeaderSize;
|
bfOffBits := SizeOf(FileHeader^) + HeaderSize;
|
||||||
end;
|
end;
|
||||||
BI := PBitmapInfoHeader(PtrInt(FileHeader) + SizeOf(FileHeader^));
|
BI := PBitmapInfoHeader(Longint(FileHeader) + SizeOf(FileHeader^));
|
||||||
Bits := Pointer(PtrInt(BI) + HeaderSize);
|
Bits := Pointer(Longint(BI) + HeaderSize);
|
||||||
InternalGetDIB(Src, Pal, BI^, Bits^, PixelFormat);
|
InternalGetDIB(Src, Pal, BI^, Bits^, PixelFormat);
|
||||||
except
|
except
|
||||||
FreeMem(Result);
|
FreeMemo(Result);
|
||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@@ -5742,10 +5771,8 @@ var
|
|||||||
BI, NewBI: PBitmapInfoHeader;
|
BI, NewBI: PBitmapInfoHeader;
|
||||||
Bits: Pointer;
|
Bits: Pointer;
|
||||||
NewPalette: PRGBPalette;
|
NewPalette: PRGBPalette;
|
||||||
NewHeaderSize: Integer = 0;
|
NewHeaderSize: Integer;
|
||||||
ImageSize: LongInt = 0;
|
ImageSize, Length, Len: Longint;
|
||||||
Length: LongInt = 0;
|
|
||||||
Len: Longint = 0;
|
|
||||||
P, InitData: Pointer;
|
P, InitData: Pointer;
|
||||||
ColorCount: Integer;
|
ColorCount: Integer;
|
||||||
SourceBitmapFormat: TPixelFormat;
|
SourceBitmapFormat: TPixelFormat;
|
||||||
@@ -5781,7 +5808,7 @@ begin
|
|||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(P);
|
FreeMemo(P);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
pf8bit:
|
pf8bit:
|
||||||
@@ -5789,20 +5816,20 @@ begin
|
|||||||
{ pf8bit - expand to 24bit first }
|
{ pf8bit - expand to 24bit first }
|
||||||
InitData := DIBFromBit(Bitmap.Handle, Bitmap.Palette, pf24bit, Len);
|
InitData := DIBFromBit(Bitmap.Handle, Bitmap.Palette, pf24bit, Len);
|
||||||
try
|
try
|
||||||
BI := PBitmapInfoHeader(PtrInt(InitData) + SizeOf(TBitmapFileHeader));
|
BI := PBitmapInfoHeader(Longint(InitData) + SizeOf(TBitmapFileHeader));
|
||||||
if BI^.biBitCount <> 24 then
|
if BI^.biBitCount <> 24 then
|
||||||
raise EJVCLException.CreateRes(@RsEBitCountNotImplemented);
|
raise EJVCLException.CreateRes(@RsEBitCountNotImplemented);
|
||||||
Bits := Pointer(PtrInt(BI) + SizeOf(TBitmapInfoHeader));
|
Bits := Pointer(Longint(BI) + SizeOf(TBitmapInfoHeader));
|
||||||
InternalGetDIBSizes(Bitmap.Handle, NewHeaderSize, ImageSize, PixelFormat);
|
InternalGetDIBSizes(Bitmap.Handle, NewHeaderSize, ImageSize, PixelFormat);
|
||||||
Length := SizeOf(TBitmapFileHeader) + NewHeaderSize;
|
Length := SizeOf(TBitmapFileHeader) + NewHeaderSize;
|
||||||
P := AllocMem(Length);
|
P := AllocMemo(Length);
|
||||||
try
|
try
|
||||||
FillChar(P^, Length, #0);
|
FillChar(P^, Length, #0);
|
||||||
NewBI := PBitmapInfoHeader(PtrInt(P) + SizeOf(TBitmapFileHeader));
|
NewBI := PBitmapInfoHeader(Longint(P) + SizeOf(TBitmapFileHeader));
|
||||||
if NewHeaderSize <= SizeOf(TBitmapInfoHeader) then
|
if NewHeaderSize <= SizeOf(TBitmapInfoHeader) then
|
||||||
NewPalette := nil
|
NewPalette := nil
|
||||||
else
|
else
|
||||||
NewPalette := PRGBPalette(PtrInt(NewBI) + SizeOf(TBitmapInfoHeader));
|
NewPalette := PRGBPalette(Longint(NewBI) + SizeOf(TBitmapInfoHeader));
|
||||||
FileHeader := PBitmapFileHeader(P);
|
FileHeader := PBitmapFileHeader(P);
|
||||||
InitializeBitmapInfoHeader(Bitmap.Handle, NewBI^, PixelFormat);
|
InitializeBitmapInfoHeader(Bitmap.Handle, NewBI^, PixelFormat);
|
||||||
if Assigned(NewPalette) then
|
if Assigned(NewPalette) then
|
||||||
@@ -5857,10 +5884,10 @@ begin
|
|||||||
raise;
|
raise;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(P);
|
FreeMemo(P);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FreeMem(InitData);
|
FreeMemo(InitData);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -5920,6 +5947,9 @@ begin
|
|||||||
SetBitmapPixelFormat(Bitmap, pf8bit, mmGrayscale);
|
SetBitmapPixelFormat(Bitmap, pf8bit, mmGrayscale);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{$ENDIF CLR}
|
||||||
|
|
||||||
function ZoomImage(ImageW, ImageH, MaxW, MaxH: Integer; Stretch: Boolean):
|
function ZoomImage(ImageW, ImageH, MaxW, MaxH: Integer; Stretch: Boolean):
|
||||||
TPoint;
|
TPoint;
|
||||||
var
|
var
|
||||||
@@ -5970,8 +6000,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(***************
|
|
||||||
|
|
||||||
//=== { TJvGradientOptions } =================================================
|
//=== { TJvGradientOptions } =================================================
|
||||||
|
|
||||||
constructor TJvGradientOptions.Create;
|
constructor TJvGradientOptions.Create;
|
||||||
|
Reference in New Issue
Block a user