// - 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!
end;
TglBitmapFormatDescriptor = class(TObject)
- strict private
+ private
// cached properties
fBytesPerPixel: Single;
fChannelCount: Integer;
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;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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;
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;
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;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TBitfieldFormat/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-procedure TbmpBitfieldFormat.SetValues(const aBPP: Integer; aMask: TglBitmapRec4ul);
+procedure TbmpBitfieldFormat.SetCustomValues(const aBPP: Integer; aMask: TglBitmapRec4ul);
var
i: Integer;
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;
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;
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;
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);
aFormat := TFormatDescriptor.Get(aFormat).WithAlpha;
result := TbmpBitfieldFormat.Create;
- result.SetValues(aInfo.biBitCount, aMask);
+ result.SetCustomValues(aInfo.biBitCount, aMask);
end;
end;
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;
end;
Converter := TbmpBitfieldFormat.Create;
- Converter.SetValues(dwRGBBitCount, glBitmapRec4ul(dwRBitMask, dwGBitMask, dwBBitMask, dwABitMask));
+ Converter.SetCustomValues(dwRGBBitCount, glBitmapRec4ul(dwRBitMask, dwGBitMask, dwBBitMask, dwABitMask));
end;
end;
end;
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;