|
|
@@ -780,6 +780,13 @@ type |
|
|
|
// - data type (e.g. ub, us, ui) |
|
|
|
// - number of data types |
|
|
|
|
|
|
|
{$IFNDEF fpc} |
|
|
|
QWord = System.UInt64; |
|
|
|
PQWord = ^QWord; |
|
|
|
|
|
|
|
PtrInt = Longint; |
|
|
|
PtrUInt = DWord; |
|
|
|
{$ENDIF} |
|
|
|
|
|
|
|
TglBitmapFormat = ( |
|
|
|
tfEmpty = 0, //must be smallest value! |
|
|
@@ -905,7 +912,7 @@ type |
|
|
|
end; |
|
|
|
|
|
|
|
TglBitmapFormatDescriptor = class(TObject) |
|
|
|
strict private |
|
|
|
private |
|
|
|
// cached properties |
|
|
|
fBytesPerPixel: Single; |
|
|
|
fChannelCount: Integer; |
|
|
@@ -1324,16 +1331,8 @@ uses |
|
|
|
Math, syncobjs, typinfo |
|
|
|
{$IF DEFINED(GLB_SUPPORT_JPEG_READ) AND DEFINED(GLB_LAZ_JPEG)}, FPReadJPEG{$IFEND}; |
|
|
|
|
|
|
|
type |
|
|
|
{$IFNDEF fpc} |
|
|
|
QWord = System.UInt64; |
|
|
|
PQWord = ^QWord; |
|
|
|
|
|
|
|
PtrInt = Longint; |
|
|
|
PtrUInt = DWord; |
|
|
|
{$ENDIF} |
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
type |
|
|
|
TFormatDescriptor = class(TglBitmapFormatDescriptor) |
|
|
|
public |
|
|
|
procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); virtual; abstract; |
|
|
@@ -1724,8 +1723,8 @@ type |
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
TbmpBitfieldFormat = class(TFormatDescriptor) |
|
|
|
public |
|
|
|
procedure SetValues(const aBPP: Integer; aMask: TglBitmapRec4ul); overload; |
|
|
|
procedure SetValues(const aBBP: Integer; const aPrec, aShift: TglBitmapRec4ub); overload; |
|
|
|
procedure SetCustomValues(const aBPP: Integer; aMask: TglBitmapRec4ul); overload; |
|
|
|
procedure SetCustomValues(const aBBP: Integer; const aPrec, aShift: TglBitmapRec4ub); overload; |
|
|
|
procedure Map(const aPixel: TglBitmapPixelData; var aData: PByte; var aMapData: Pointer); override; |
|
|
|
procedure Unmap(var aData: PByte; out aPixel: TglBitmapPixelData; var aMapData: Pointer); override; |
|
|
|
end; |
|
|
@@ -1740,12 +1739,12 @@ type |
|
|
|
fBitsPerPixel: Integer; |
|
|
|
fColorTable: TbmpColorTable; |
|
|
|
protected |
|
|
|
procedure SetValues; override; overload; |
|
|
|
procedure SetValues; override; |
|
|
|
public |
|
|
|
property ColorTable: TbmpColorTable read fColorTable write fColorTable; |
|
|
|
property BitsPerPixel: Integer read fBitsPerPixel write fBitsPerPixel; |
|
|
|
|
|
|
|
procedure SetValues(const aFormat: TglBitmapFormat; const aBPP: Integer; const aPrec, aShift: TglBitmapRec4ub); overload; |
|
|
|
procedure SetCustomValues(const aFormat: TglBitmapFormat; const aBPP: Integer; const aPrec, aShift: TglBitmapRec4ub); overload; |
|
|
|
procedure CalcValues; |
|
|
|
procedure CreateColorTable; |
|
|
|
|
|
|
@@ -1935,7 +1934,7 @@ begin |
|
|
|
if (desc.IsCompressed) or (desc.glFormat = 0) then |
|
|
|
exit; |
|
|
|
|
|
|
|
p := GetMem(ceil(25 * desc.BytesPerPixel)); // 5 x 5 pixel |
|
|
|
p := GetMemory(ceil(25 * desc.BytesPerPixel)); // 5 x 5 pixel |
|
|
|
md := desc.CreateMappingData; |
|
|
|
try |
|
|
|
tmp := p; |
|
|
@@ -4104,7 +4103,7 @@ end; |
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
//TBitfieldFormat///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
procedure TbmpBitfieldFormat.SetValues(const aBPP: Integer; aMask: TglBitmapRec4ul); |
|
|
|
procedure TbmpBitfieldFormat.SetCustomValues(const aBPP: Integer; aMask: TglBitmapRec4ul); |
|
|
|
var |
|
|
|
i: Integer; |
|
|
|
begin |
|
|
@@ -4120,7 +4119,7 @@ begin |
|
|
|
end; |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
procedure TbmpBitfieldFormat.SetValues(const aBBP: Integer; const aPrec, aShift: TglBitmapRec4ub); |
|
|
|
procedure TbmpBitfieldFormat.SetCustomValues(const aBBP: Integer; const aPrec, aShift: TglBitmapRec4ub); |
|
|
|
begin |
|
|
|
fBitsPerPixel := aBBP; |
|
|
|
fPrecision := aPrec; |
|
|
@@ -4178,7 +4177,7 @@ begin |
|
|
|
end; |
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
|
|
|
procedure TbmpColorTableFormat.SetValues(const aFormat: TglBitmapFormat; const aBPP: Integer; const aPrec, aShift: TglBitmapRec4ub); |
|
|
|
procedure TbmpColorTableFormat.SetCustomValues(const aFormat: TglBitmapFormat; const aBPP: Integer; const aPrec, aShift: TglBitmapRec4ub); |
|
|
|
begin |
|
|
|
fFormat := aFormat; |
|
|
|
fBitsPerPixel := aBPP; |
|
|
@@ -5294,7 +5293,7 @@ var |
|
|
|
Shift.g := GreenShift; |
|
|
|
Shift.b := BlueShift; |
|
|
|
Shift.a := AlphaShift; |
|
|
|
bfFormat.SetValues(BitsPerPixel, Prec, Shift); |
|
|
|
bfFormat.SetCustomValues(BitsPerPixel, Prec, Shift); |
|
|
|
end; |
|
|
|
pSourceMD := bfFormat.CreateMappingData; |
|
|
|
pDestMD := FormatDesc.CreateMappingData; |
|
|
@@ -7068,7 +7067,7 @@ begin |
|
|
|
if (fd.Format = tfEmpty) then |
|
|
|
raise EglBitmapUnsupportedFormat.Create('no supported format found'); |
|
|
|
|
|
|
|
buf := GetMem(header.DataSize); |
|
|
|
buf := GetMemory(header.DataSize); |
|
|
|
aStream.Read(buf^, header.DataSize); |
|
|
|
SetDataPointer(buf, fd.Format, header.Width, header.Height); |
|
|
|
|
|
|
@@ -7205,7 +7204,7 @@ function TglBitmap.LoadBMP(const aStream: TStream): Boolean; |
|
|
|
aFormat := TFormatDescriptor.Get(aFormat).WithAlpha; |
|
|
|
|
|
|
|
result := TbmpBitfieldFormat.Create; |
|
|
|
result.SetValues(aInfo.biBitCount, aMask); |
|
|
|
result.SetCustomValues(aInfo.biBitCount, aMask); |
|
|
|
end; |
|
|
|
end; |
|
|
|
|
|
|
@@ -7374,7 +7373,7 @@ begin |
|
|
|
Header.bfOffBits := Header.bfOffBits + 256 * SizeOf(Cardinal); //256 ColorTable entries |
|
|
|
Converter := TbmpColorTableFormat.Create; |
|
|
|
with (Converter as TbmpColorTableFormat) do begin |
|
|
|
SetValues(fFormat, 1, FormatDesc.Precision, FormatDesc.Shift); |
|
|
|
SetCustomValues(fFormat, 1, FormatDesc.Precision, FormatDesc.Shift); |
|
|
|
CreateColorTable; |
|
|
|
end; |
|
|
|
end; |
|
|
@@ -7955,7 +7954,7 @@ var |
|
|
|
end; |
|
|
|
|
|
|
|
Converter := TbmpBitfieldFormat.Create; |
|
|
|
Converter.SetValues(dwRGBBitCount, glBitmapRec4ul(dwRBitMask, dwGBitMask, dwBBitMask, dwABitMask)); |
|
|
|
Converter.SetCustomValues(dwRGBBitCount, glBitmapRec4ul(dwRBitMask, dwGBitMask, dwBBitMask, dwABitMask)); |
|
|
|
end; |
|
|
|
end; |
|
|
|
end; |
|
|
@@ -8337,7 +8336,6 @@ begin |
|
|
|
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_HEIGHT, @TempHeight); |
|
|
|
glGetTexLevelParameteriv(Target, 0, GL_TEXTURE_INTERNAL_FORMAT, @TempIntFormat); |
|
|
|
|
|
|
|
IntFormat := tfEmpty; |
|
|
|
FormatDesc := (TglBitmapFormatDescriptor.GetByFormat(TempIntFormat) as TFormatDescriptor); |
|
|
|
IntFormat := FormatDesc.Format; |
|
|
|
|
|
|
|