Хочу перевести данный кусок из Дельфи в FPC 1.9.6
Есть ли аналоги у типов TJPEGImage, TBitmap ?
function LoadJPGTexture(Filename: String; var Texture: GLuint; LoadFromResource : Boolean): Boolean;
var
Data : Array of LongWord;
W, Width : Integer;
H, Height : Integer;
BMP : TBitmap;
JPG : TJPEGImage;
C : LongWord;
Line : ^LongWord;
ResStream : TResourceStream;
begin
result :=FALSE;
JPG:=TJPEGImage.Create;
if LoadFromResource then
begin
try
ResStream := TResourceStream.Create(hInstance, PChar(copy(Filename, 1, Pos('.', Filename)-1)), 'JPEG');
JPG.LoadFromStream(ResStream);
ResStream.Free;
except on
EResNotFound do
begin
MessageBox(0, PChar('File not found in resource - ' + Filename), PChar('JPG Texture'), MB_OK);
Exit;
end
else
begin
MessageBox(0, PChar('Couldn''t load JPG Resource - \"'+ Filename +'\"'), PChar('BMP Unit'), MB_OK);
Exit;
end;
end;
end
else
begin
try
JPG.LoadFromFile(Filename);
except
MessageBox(0, PChar('Couldn''t load JPG - \"'+ Filename +'\"'), PChar('BMP Unit'), MB_OK);
Exit;
end;
end;
BMP:=TBitmap.Create;
BMP.pixelformat:=pf32bit;
BMP.width:=JPG.width;
BMP.height:=JPG.height;
BMP.canvas.draw(0,0,JPG);
Width :=BMP.Width;
Height :=BMP.Height;
SetLength(Data, Width*Height);
For H:=0 to Height-1 do
Begin
Line :=BMP.scanline[Height-H-1];
For W:=0 to Width-1 do
Begin
c:=Line^ and $FFFFFF;
Data[W+(H*Width)] :=(((c and $FF) shl 16)+(c shr 16)+(c and $FF00)) or $FF000000;
inc(Line);
End;
End;
BMP.free;
JPG.free;
Texture :=CreateTexture(Width, Height, GL_RGBA, addr(Data[0]));
result :=TRUE;
end;