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