files with a simple jpeg2000 code stream (usually the file has the extension .j2k) do not
define any information about dpi settings, but the jpeg2000 file format (with the extension .jp2)
does define so called "jp2 boxes" and supports any kind of additional information. But most of
them are only optional and not present within every jp2 file. Anyway, if the DPI info is present
it is defined by the "resc"-box, and as you are using a 3rd party library and do not need to mess
around with all the header stuff, I think a simple way would be just to search the file for the
"resc" string (thats what I mean with the IsBoxPresent function) and if the string is present you
can use the following code to get the DPI for both x and y resolution.
jp2_resc = $72657363; // 'resc'
InchPerMeter = 39.37007874016;
TJp2_resc = packed record
FhDpi, FvDpi: integer; // horizontal and vertical dpi setting
if IsBoxPresent(jp2_resc) then begin
FStream.Read(resc, SizeOf(TJp2_resc)); // FStream is the jp2 file
FhDpi := round((resc.hNum/resc.hDen)*power(10,resc.hExp)/InchPerMeter);
FvDpi := round((resc.vNum/resc.vDen)*power(10,resc.vExp)/InchPerMeter);
Hope this helps
P.S: I'm currently working on a native Delphi implementation for Jpeg2000, because
I was quite unhappy with Jasper. It was only able to read five out of the nine jp2
reference files from http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
and it did fail on most code stream variations from a set of reference files where, for
the moment, I do not find a working link...
Maybe I was just using an older version, so what is your experience with Jasper?
> When using the Jasper library to load/save jpeg2000 files, the dpi
> info is not loaded. Does anyone know where dpi info is stored in the
> jpeg2000 file format?
I don't know but you could try the ImageEn graphic library.
It's not free but very good and not expensive