Hello!
I try to access the pixel data of jp2 file. The jp2 file has additional xml informations at the beginning of the file.
Is there any way to access only the RGBA values of the jp2 file without the xml informations at the beginning?
Here 2 attempt which didn't seem to work:
var
ABmp: TIEBitmap;
ABytes, CurrBytePos: PByte;
ARow: Integer;
ASize: Int64;
begin
ABmp := TIEBitmap.Create;
ABytes := nil;
try
ABmp.Read('T33UUS_20240303T100819_TCI_10m.jp2');
ASize := ABmp.Rowlen * ABmp.Height;
GetMem(ABytes, ASize);
CurrBytePos := ABytes;
for ARow := 0 to ABmp.Height - 1 do begin
Move(ABmp.ScanLine[0]^, CurrBytePos^, ABmp.Rowlen);
inc(CurrBytePos, ABmp.Rowlen);
end;
finally
ABmp.Free;
if (Assigned(ABytes)) then
FreeMem(ABytes);
end;
end;
var
ABmp: TIEBitmap;
ABytes, CurrBytePos: PByte;
ARow, ACol: Integer;
ASize: Int64;
ARGBA: TRGBA,
begin
ABmp := TIEBitmap.Create;
ABytes := nil;
try
ABmp.Read('T33UUS_20240303T100819_TCI_10m.jp2');
ASize := ABmp.Rowlen * ABmp.Height;
GetMem(ABytes, ASize);
CurrBytePos := ABytes;
for ARow := 0 to ABmp.Height - 1 do begin
for ACol := 0 to ABmp.Width - 1 do begin
ARGBA := AImage.IEBitmap.Pixels_ie32RGB[ACol, ARow];
PRGBA(CurrBytePos)^ := ARGBA;
inc(CurrBytePos, SizeOf(TRGBA));
end;
end;
finally
ABmp.Free;
if (Assigned(ABytes)) then
FreeMem(ABytes);
end;
end;
I checked out the EncapsulateFromMemory method as well, but it seems to behave as the written code above.
Example File (128MB) so I uploaded it somewhere else:
https://www.file-upload.net/download-15285284/T33UUS_20240303T100819_TCI_10m.jp2.html
In additional I have to work with the raw pixels to perform other calculation after reading the files and I try to keep it as fast as possible. So the pixel data has to stay as they are, no transformations, that might change these values.
How can I access the raw pixel data from jp2 file?
Regards
Jan