LEADTOOLS Support
Imaging
Imaging SDK Questions
Converting RasterImage to System.Windows.Controls.Image, but both have different sizes
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, March 30, 2009 9:04:28 AM(UTC)
Groups: Registered
Posts: 4
I am doing a test with a jpeg2000 image (http://memory.loc.gov/gmd/gmd412/g4127/g4127l/ct001114.jp2), but am getting an odd result. Here is my code for loading the JPEG2000 and converting it to an ImageSource:
RasterImage rasterImg = codecs.Load(this.m_url);
ImageSource img = Leadtools.Windows.Media.RasterImageMediaConverter.ConvertFrom(rasterImg, RasterImageMediaConverterFromFlags.None));
But when I look at the sizes of the rasterImg and the img they are not the same The RasterImage is 6354 (width) by 3926 (height) and the ImageSource is 4066.56 (width) by 2512.64 (height). At a glance, I don't see any pixel loss. Is the image just being resized because the ImageSource can only hold a certain image size? Why are they different sizes?
#2
Posted
:
Tuesday, March 31, 2009 6:34:13 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
When you convert an image from a LEAD RasterImage to an ImageSource, the dimensions of the image are converted to the resolution units of the display, which are by default 96 dots per inch (DPI).
The image you tested does not have a DPI resolution value stored in it. When you load it into LEADTOOLS, it is given a default resolution value of 150 DPI.
This means its dimensions in inches are considered to be 42.36 x 26.17 inches.
These values correspond to the following dimensions at 96 DPI:
width = 6354/150.0*96 = 4066.56
height = 3926/150.0*96 = 2512.64
#3
Posted
:
Tuesday, March 31, 2009 6:40:33 AM(UTC)
Groups: Registered
Posts: 4
So when I do the conversion, can I specify the DPI? Thanks for your response. It definitely explains my results.
#4
Posted
:
Tuesday, March 31, 2009 11:03:02 PM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
After you load the image, you can set the rasterImg.XResolution and rasterImg.YResolution to the screen DPI (which is usually 96).
LEADTOOLS Support
Imaging
Imaging SDK Questions
Converting RasterImage to System.Windows.Controls.Image, but both have different sizes
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.