summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/gfx/imgtest/imgtest.pas1
-rw-r--r--gfx/gelimage.pas36
-rw-r--r--gfx/gfxbase.pas8
-rw-r--r--gfx/x11/gfx_x11.pas2
4 files changed, 47 insertions, 0 deletions
diff --git a/examples/gfx/imgtest/imgtest.pas b/examples/gfx/imgtest/imgtest.pas
index ad6d4f5f..329f9cbf 100644
--- a/examples/gfx/imgtest/imgtest.pas
+++ b/examples/gfx/imgtest/imgtest.pas
@@ -17,6 +17,7 @@
program ImgTest;
uses
+ cmem,
Classes,
GFXBase,
fpGFX;
diff --git a/gfx/gelimage.pas b/gfx/gelimage.pas
index ca3d68c6..0003d62b 100644
--- a/gfx/gelimage.pas
+++ b/gfx/gelimage.pas
@@ -112,6 +112,26 @@ begin
end;
end;
+procedure ConvertRGB16ToInternal(Params: TConvertParams; Data: Pointer;
+ StartX, EndX: Integer; Dest: Pointer);
+var
+ PixelIn: LongWord;
+begin
+ Inc(Data, StartX * 2);
+ while StartX < EndX do
+ begin
+ PixelIn := 0;
+ Move(Data^, PixelIn, 2);
+ PLongWord(Dest)^ :=
+ (((PixelIn shr Params.RedShiftR) and $ff) shl Params.RedShiftL) or
+ (((PixelIn shr Params.GreenShiftR) and $ff) shl Params.GreenShiftL) or
+ (((PixelIn shr Params.BlueShiftR) and $ff) shl Params.BlueShiftL);
+ Inc(StartX);
+ Inc(Data, 2);
+ Inc(Dest, 2);
+ end;
+end;
+
procedure ConvertRGB24ToInternal(Params: TConvertParams; Data: Pointer;
StartX, EndX: Integer; Dest: Pointer);
var
@@ -276,6 +296,12 @@ begin
ParamsI2D.BlueShiftL := 0;
ParamsS2I.BlueShiftL := 0;
+ if ASourceFormat.FormatType = ADestFormat.FormatType then
+ begin
+ Move( ASourceData^, ADestData^, ADestStride * (ASourceRect.Top - ASourceRect.Bottom) );
+ Exit;
+ end;
+
case ASourceFormat.FormatType of
ftMono:
begin
@@ -302,6 +328,16 @@ begin
for i := max + 1 to 255 do
ParamsS2I.Palette[i] := i or (i shl 8) or (i shl 16);
end;
+ ftRGB16:
+ begin
+ ConvertToInternal := @ConvertRGB16ToInternal;
+ ParamsS2I.RedShiftR := 5 -
+ GetBitShiftAndCount(ASourceFormat.RedMask, ParamsS2I.RedShiftL);
+ ParamsS2I.GreenShiftR := 11 -
+ GetBitShiftAndCount(ASourceFormat.GreenMask, ParamsS2I.GreenShiftL);
+ ParamsS2I.BlueShiftR := 16 -
+ GetBitShiftAndCount(ASourceFormat.BlueMask, ParamsS2I.BlueShiftL);
+ end;
ftRGB24:
begin
ConvertToInternal := @ConvertRGB24ToInternal;
diff --git a/gfx/gfxbase.pas b/gfx/gfxbase.pas
index d772566f..08bc6d43 100644
--- a/gfx/gfxbase.pas
+++ b/gfx/gfxbase.pas
@@ -180,6 +180,14 @@ const
BlueMask: 0;
AlphaMask: 0);
+ { 5-6-5 storage }
+ PixelFormatRGB16: TGfxPixelFormat = (
+ FormatType: ftRGB16;
+ RedMask: $001F;
+ GreenMask: $07E0;
+ BlueMask: $F800;
+ AlphaMask: 0);
+
PixelFormatRGB24: TGfxPixelFormat = (
FormatType: ftRGB24;
RedMask: $0000ff;
diff --git a/gfx/x11/gfx_x11.pas b/gfx/x11/gfx_x11.pas
index 0f2f69e6..1c405b49 100644
--- a/gfx/x11/gfx_x11.pas
+++ b/gfx/x11/gfx_x11.pas
@@ -762,6 +762,8 @@ begin
ASourceRect.Right - ASourceRect.Left,
ASourceRect.Bottom - ASourceRect.Top, 8, 0);
+ WriteLn('Size allocated: ', Image^.bytes_per_line * (ASourceRect.Bottom - ASourceRect.Top) + 1);
+
{ Here its necessary to alloc an extra byte, otherwise it will fail on 32-bits
machines, but still work on 64-bits machines. The cause of this is unknown. }
Image^.data := GetMem(Image^.bytes_per_line * (ASourceRect.Bottom - ASourceRect.Top) + 1);