JPeg2000 Fiile Format DPI Info

34 views
Skip to first unread message

Bill Miller

unread,
Oct 2, 2003, 4:08:11 PM10/2/03
to
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?

--
Regards

Bill Miller
_______________________
w2matfrontiernetdotnet
http://www.frontiernet.net/~w2m/index.html


Ive

unread,
Oct 3, 2003, 1:22:31 PM10/3/03
to

Hi Bill,

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.

const
jp2_resc = $72657363; // 'resc'
InchPerMeter = 39.37007874016;

type
TJp2_resc = packed record
hNum: word;
hDen: word;
vNum: word;
vDen: word;
hExp: ShortInt;
vExp: ShortInt;
end;

var
FhDpi, FvDpi: integer; // horizontal and vertical dpi setting

procedure Jp2ReadDpi;
var
resc: TJp2_resc;
begin
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);
end;
end;


Hope this helps

-Ive


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?

Roberto Nicchi

unread,
Oct 16, 2003, 12:05:32 PM10/16/03
to
"Bill Miller" <w2matnetheavendotcom> wrote in
news:3f7c...@newsgroups.borland.com:

> 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.
www.hicomponents.com
It's not free but very good and not expensive

Roberto

Reply all
Reply to author
Forward
0 new messages