mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-03 17:02:16 +01:00
added BitOrder for RawImages
git-svn-id: trunk@4855 -
This commit is contained in:
parent
63551218b1
commit
c4676060c1
@ -57,6 +57,11 @@ type
|
||||
riboMSBFirst // most significant byte first
|
||||
);
|
||||
|
||||
TRawImageBitOrder = (
|
||||
riboBitsInOrder, // Bit 0 is pixel 0
|
||||
riboReversedBits // Bit 0 is pixel 7 (Bit 1 is pixel 6, ...)
|
||||
);
|
||||
|
||||
TRawImageLineEnd = (
|
||||
rileTight, // no gap at end of lines
|
||||
rileByteBoundary, // each line starts at byte boundary. For example:
|
||||
@ -79,6 +84,7 @@ type
|
||||
Width: cardinal;
|
||||
Height: cardinal;
|
||||
PaletteColorCount: integer;
|
||||
BitOrder: TRawImageBitOrder;
|
||||
ByteOrder: TRawImageByteOrder;
|
||||
LineOrder: TRawImageLineOrder;
|
||||
ColorCount: cardinal; // entries in color palette. Ignore when no palette.
|
||||
@ -96,6 +102,8 @@ type
|
||||
// The next values are only valid, if there is a separate alpha mask
|
||||
AlphaBitsPerPixel: cardinal; // bits per alpha mask pixel.
|
||||
AlphaLineEnd: TRawImageLineEnd;
|
||||
AlphaBitOrder: TRawImageBitOrder;
|
||||
AlphaByteOrder: TRawImageByteOrder;
|
||||
// ToDo: add attributes for palette
|
||||
end;
|
||||
PRawImageDescription = ^TRawImageDescription;
|
||||
@ -119,6 +127,36 @@ type
|
||||
end;
|
||||
PRawImagePosition = ^TRawImagePosition;
|
||||
|
||||
const
|
||||
RawImageColorFormatNames: array[TRawImageColorFormat] of string = (
|
||||
'ricfRGBA',
|
||||
'ricfGray'
|
||||
);
|
||||
|
||||
RawImageByteOrderNames: array[TRawImageByteOrder] of string = (
|
||||
'riboLSBFirst',
|
||||
'riboMSBFirst'
|
||||
);
|
||||
|
||||
RawImageBitOrderNames: array[TRawImageBitOrder] of string = (
|
||||
'riboBitsInOrder',
|
||||
'riboReversedBits'
|
||||
);
|
||||
|
||||
RawImageLineEndNames: array[TRawImageLineEnd] of string = (
|
||||
'rileTight',
|
||||
'rileByteBoundary',
|
||||
'rileWordBoundary',
|
||||
'rileDWordBoundary',
|
||||
'rileQWordBoundary'
|
||||
);
|
||||
|
||||
RawImageLineOrderNames: array[TRawImageLineOrder] of string = (
|
||||
'riloTopToBottom',
|
||||
'riloBottomToTop'
|
||||
);
|
||||
|
||||
|
||||
function RawImageDescriptionAsString(Desc: PRawImageDescription): string;
|
||||
|
||||
implementation
|
||||
@ -136,17 +174,19 @@ function RawImageDescriptionAsString(Desc: PRawImageDescription): string;
|
||||
begin
|
||||
Result:='';
|
||||
with Desc^ do begin
|
||||
Result:=' Format='+IntToStr(ord(Format))
|
||||
Result:=
|
||||
' Format='+RawImageColorFormatNames[Format]
|
||||
+' HasPalette='+BoolStr(HasPalette)
|
||||
+' Depth='+IntToStr(Depth)
|
||||
+' Width='+IntToStr(Width)
|
||||
+' Height='+IntToStr(Height)
|
||||
+' PaletteEntries='+IntToStr(PaletteColorCount)
|
||||
+' ByteOrder='+IntToStr(ord(ByteOrder))
|
||||
+' LineOrder='+IntToStr(ord(LineOrder))
|
||||
+' PaletteColorCount='+IntToStr(PaletteColorCount)
|
||||
+' BitOrder='+RawImageBitOrderNames[BitOrder]
|
||||
+' ByteOrder='+RawImageByteOrderNames[ByteOrder]
|
||||
+' LineOrder='+RawImageLineOrderNames[LineOrder]
|
||||
+' ColorCount='+IntToStr(ColorCount)
|
||||
+' BitsPerPixel='+IntToStr(BitsPerPixel)
|
||||
+' LineEnd='+IntToStr(ord(LineEnd))
|
||||
+' LineEnd='+RawImageLineEndNames[LineEnd]
|
||||
+' RedPrec='+IntToStr(RedPrec)
|
||||
+' RedShift='+IntToStr(RedShift)
|
||||
+' GreenPrec='+IntToStr(GreenPrec)
|
||||
@ -157,7 +197,10 @@ begin
|
||||
+' AlphaPrec='+IntToStr(AlphaPrec)
|
||||
+' AlphaShift='+IntToStr(AlphaShift)
|
||||
+' AlphaBitsPerPixel='+IntToStr(AlphaBitsPerPixel)
|
||||
+' AlphaLineEnd='+IntToStr(ord(AlphaLineEnd));
|
||||
+' AlphaLineEnd='+RawImageLineEndNames[AlphaLineEnd]
|
||||
+' AlphaBitOrder='+RawImageBitOrderNames[AlphaBitOrder]
|
||||
+' AlphaByteOrder='+RawImageByteOrderNames[AlphaByteOrder]
|
||||
+'';
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -166,6 +209,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.22 2003/11/28 11:25:49 mattias
|
||||
added BitOrder for RawImages
|
||||
|
||||
Revision 1.21 2003/11/26 21:30:19 mattias
|
||||
reduced unit circles, fixed fpImage streaming
|
||||
|
||||
|
||||
@ -2051,6 +2051,8 @@ begin
|
||||
Desc^.PaletteColorCount:=0;
|
||||
end else
|
||||
Desc^.PaletteColorCount:=0;
|
||||
// BitOrder
|
||||
Desc^.BitOrder:=riboBitsInOrder;
|
||||
// ByteOrder
|
||||
if Visual^.byte_order=GDK_MSB_FIRST then
|
||||
Desc^.ByteOrder:=riboMSBFirst
|
||||
@ -2086,6 +2088,8 @@ begin
|
||||
// AlphaBitsPerPixel and AlphaLineEnd
|
||||
Desc^.AlphaBitsPerPixel:=Desc^.AlphaPrec;
|
||||
Desc^.AlphaLineEnd:=rileByteBoundary;
|
||||
Desc^.AlphaBitOrder:=riboBitsInOrder;
|
||||
Desc^.AlphaByteOrder:=riboLSBFirst;
|
||||
|
||||
{$IFDEF VerboseRawImage}
|
||||
writeln('TgtkObject.GetDeviceRawImageDescription A ',RawImageDescriptionAsString(Desc));
|
||||
@ -8461,6 +8465,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.438 2003/11/28 11:25:49 mattias
|
||||
added BitOrder for RawImages
|
||||
|
||||
Revision 1.437 2003/11/26 21:30:19 mattias
|
||||
reduced unit circles, fixed fpImage streaming
|
||||
|
||||
|
||||
@ -1443,6 +1443,7 @@ begin
|
||||
Desc^.Width := BitmapInfo.bmWidth;
|
||||
Desc^.Height := BitmapInfo.bmHeight;
|
||||
Desc^.PaletteColorCount := 0; // TODO, also `ColorCount'
|
||||
Desc^.BitOrder := riboReversedBits;
|
||||
Desc^.ByteOrder := riboLSBFirst;
|
||||
Desc^.LineOrder := riloTopToBottom;
|
||||
Desc^.ColorCount := 0; // entries in color palette. Ignore when no palette.
|
||||
@ -1455,6 +1456,8 @@ begin
|
||||
Desc^.AlphaBitsPerPixel := Desc^.BitsPerPixel; // bits per alpha mask pixel.
|
||||
Desc^.AlphaPrec := Desc^.AlphaBitsPerPixel;
|
||||
Desc^.AlphaLineEnd := rileWordBoundary;
|
||||
Desc^.AlphaBitOrder := riboReversedBits;
|
||||
Desc^.AlphaByteOrder := riboLSBFirst;
|
||||
end;
|
||||
|
||||
function TWin32Object.GetBitmapRawImageDescription(Bitmap: HBITMAP;
|
||||
@ -2844,6 +2847,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.78 2003/11/28 11:25:49 mattias
|
||||
added BitOrder for RawImages
|
||||
|
||||
Revision 1.77 2003/11/26 00:23:47 marc
|
||||
* implemented new LCL(check|enable)Menuitem functions
|
||||
* introduced the lclintf inc files to win32
|
||||
|
||||
@ -269,9 +269,11 @@ function ReadCompleteStreamToString(Str: TStream; StartSize: integer): string;
|
||||
procedure ReadCompleteStreamToStream(SrcStream, DestStream: TStream;
|
||||
StartSize: integer);
|
||||
procedure ReadRawImageBits(TheData: PByte; const Position: TRawImagePosition;
|
||||
BitsPerPixel, Prec, Shift: cardinal; var Bits: word);
|
||||
BitsPerPixel, Prec, Shift: cardinal;
|
||||
BitOrder: TRawImageBitOrder; var Bits: word);
|
||||
procedure WriteRawImageBits(TheData: PByte; const Position: TRawImagePosition;
|
||||
BitsPerPixel, Prec, Shift: cardinal; Bits: word);
|
||||
BitsPerPixel, Prec, Shift: cardinal;
|
||||
BitOrder: TRawImageBitOrder; Bits: word);
|
||||
|
||||
implementation
|
||||
|
||||
@ -403,7 +405,8 @@ end;
|
||||
|
||||
procedure ReadRawImageBits(TheData: PByte;
|
||||
const Position: TRawImagePosition;
|
||||
BitsPerPixel, Prec, Shift: cardinal; var Bits: word);
|
||||
BitsPerPixel, Prec, Shift: cardinal; BitOrder: TRawImageBitOrder;
|
||||
var Bits: word);
|
||||
var
|
||||
P: PByte;
|
||||
PrecMask: Cardinal;
|
||||
@ -417,11 +420,10 @@ begin
|
||||
1,2,4:
|
||||
begin
|
||||
OneByte:=P^;
|
||||
{$ifdef WIN32}
|
||||
Bits:=Word(cardinal(OneByte shr (Shift+7-Position.Bit)) and PrecMask);
|
||||
{$else}
|
||||
Bits:=Word(cardinal(OneByte shr (Shift+Position.Bit)) and PrecMask);
|
||||
{$endif}
|
||||
if BitOrder=riboBitsInOrder then
|
||||
Bits:=Word(cardinal(OneByte shr (Shift+Position.Bit)) and PrecMask)
|
||||
else
|
||||
Bits:=Word(cardinal(OneByte shr (Shift+7-Position.Bit)) and PrecMask);
|
||||
end;
|
||||
8: begin
|
||||
OneByte:=P^;
|
||||
@ -447,7 +449,7 @@ end;
|
||||
|
||||
procedure WriteRawImageBits(TheData: PByte;
|
||||
const Position: TRawImagePosition;
|
||||
BitsPerPixel, Prec, Shift: cardinal; Bits: word);
|
||||
BitsPerPixel, Prec, Shift: cardinal; BitOrder: TRawImageBitOrder; Bits: word);
|
||||
var
|
||||
P: PByte;
|
||||
PrecMask: Cardinal;
|
||||
@ -468,11 +470,10 @@ begin
|
||||
1,2,4:
|
||||
begin
|
||||
OneByte:=P^;
|
||||
{$ifdef WIN32}
|
||||
ShiftLeft:=Shift+7-Position.Bit;
|
||||
{$else}
|
||||
ShiftLeft:=Shift+Position.Bit;
|
||||
{$endif}
|
||||
if BitOrder=riboBitsInOrder then
|
||||
ShiftLeft:=Shift+Position.Bit
|
||||
else
|
||||
ShiftLeft:=Shift+7-Position.Bit;
|
||||
PrecMask:=not (PrecMask shl ShiftLeft);
|
||||
OneByte:=OneByte and PrecMask; // clear old
|
||||
OneByte:=OneByte or (Bits shl ShiftLeft); // set new
|
||||
@ -548,13 +549,13 @@ begin
|
||||
begin
|
||||
WriteRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.RedPrec,FDataDescription.RedShift,
|
||||
Value.Red);
|
||||
FDataDescription.BitOrder,Value.Red);
|
||||
WriteRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.GreenPrec,FDataDescription.GreenShift,
|
||||
Value.Green);
|
||||
FDataDescription.BitOrder,Value.Green);
|
||||
WriteRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.BluePrec,FDataDescription.BlueShift,
|
||||
Value.Blue);
|
||||
FDataDescription.BitOrder,Value.Blue);
|
||||
if FDataDescription.AlphaPrec>0 then begin
|
||||
if FDataDescription.AlphaSeparate then begin
|
||||
if (FMaskData<>nil) then begin
|
||||
@ -563,7 +564,7 @@ begin
|
||||
FDataDescription.AlphaBitsPerPixel,
|
||||
FDataDescription.AlphaPrec,
|
||||
FDataDescription.AlphaShift,
|
||||
Value.Alpha);
|
||||
FDataDescription.AlphaBitOrder,Value.Alpha);
|
||||
end else begin
|
||||
// no alpha mask
|
||||
end;
|
||||
@ -571,7 +572,7 @@ begin
|
||||
WriteRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.AlphaPrec,
|
||||
FDataDescription.AlphaShift,
|
||||
Value.Alpha)
|
||||
FDataDescription.AlphaBitOrder,Value.Alpha)
|
||||
end else begin
|
||||
// no alpha
|
||||
end;
|
||||
@ -581,7 +582,7 @@ begin
|
||||
begin
|
||||
WriteRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.RedPrec,FDataDescription.RedShift,
|
||||
Value.Red);
|
||||
FDataDescription.BitOrder,Value.Red);
|
||||
end;
|
||||
|
||||
else
|
||||
@ -603,13 +604,13 @@ begin
|
||||
begin
|
||||
ReadRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.RedPrec,FDataDescription.RedShift,
|
||||
Result.Red);
|
||||
FDataDescription.BitOrder,Result.Red);
|
||||
ReadRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.GreenPrec,FDataDescription.GreenShift,
|
||||
Result.Green);
|
||||
FDataDescription.BitOrder,Result.Green);
|
||||
ReadRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.BluePrec,FDataDescription.BlueShift,
|
||||
Result.Blue);
|
||||
FDataDescription.BitOrder,Result.Blue);
|
||||
if FDataDescription.AlphaPrec>0 then begin
|
||||
if FDataDescription.AlphaSeparate then begin
|
||||
if (FMaskData<>nil) then begin
|
||||
@ -618,7 +619,7 @@ begin
|
||||
FDataDescription.AlphaBitsPerPixel,
|
||||
FDataDescription.AlphaPrec,
|
||||
FDataDescription.AlphaShift,
|
||||
Result.Alpha);
|
||||
FDataDescription.AlphaBitOrder,Result.Alpha);
|
||||
end else begin
|
||||
// no alpha mask -> set opaque
|
||||
Result.Alpha:=high(Result.Alpha);
|
||||
@ -626,7 +627,7 @@ begin
|
||||
end else
|
||||
ReadRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.AlphaPrec,FDataDescription.AlphaShift,
|
||||
Result.Alpha)
|
||||
FDataDescription.AlphaBitOrder,Result.Alpha)
|
||||
end else begin
|
||||
// no alpha -> set opaque
|
||||
Result.Alpha:=high(Result.Alpha);
|
||||
@ -637,7 +638,7 @@ begin
|
||||
begin
|
||||
ReadRawImageBits(FPixelData,Position,FDataDescription.BitsPerPixel,
|
||||
FDataDescription.RedPrec,FDataDescription.RedShift,
|
||||
Result.Red);
|
||||
FDataDescription.BitOrder,Result.Red);
|
||||
Result.Green:=Result.Red;
|
||||
Result.Blue:=Result.Blue;
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user