Exact resolution

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
ctn
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Exact resolution

Post by ctn » Tue May 19, 2009 4:12 pm

Dear all

Why don't I get the exact resolution of the a pic which I have scanned?

E.g.
Set resolution to 50

ScanningPrinting.scanningScanPreview():
byte[76430]{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x32, 0x00, 0x32, 0x00, 0x00, ...}
sizePixels=416,585
sizeInches=8.48979591836735,11.9387755102041
DPI=(49, 49)

--> the image resolution is 49
--------------------------------------

Set resolution to 75:

ScanningPrinting.scanningScanPreview():
byte[148288]{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x4b, 0x00, 0x4b, 0x00, 0x00, ...}
sizePixels=640,876
sizeInches=8.64864864864865,11.8378378378378
DPI=(74, 74)

--> the image resolution is 74
--------------------------------------
Set resolution to 100:

ScanningPrinting.scanningScanPreview():
byte[230357]{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x64, 0x00, 0x64, 0x00, 0x00, ...}
sizePixels=832,1169
sizeInches=8.32,11.69
DPI=(100, 100)

--> the image resolution is 100 (correct)
--------------------------------------
Set the resolution to 150

ScanningPrinting.scanningScanPreview():
byte[430889]{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x96, 0x00, 0x96, 0x00, 0x00, ...}
sizePixels=1248,1753
sizeInches=8.3758389261745,11.7651006711409
DPI=(149, 149)

--> the image resolution is 149
--------------------------------------
Set the resolution to 200

ScanningPrinting.scanningScanPreview():
byte[658736]{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0xc8, 0x00, 0xc8, 0x00, 0x00, ...}
sizePixels=1664,2338
sizeInches=8.32,11.69
DPI=(200, 200)

--> the image resolution is 200 (correct)
--------------------------------------

I think it is a rounding issue. Can this be solved?
As you also can see if the scan resolution is small it also affect to the sizeInches of the image.

Could you please check?
Thank you, ctn

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Exact resolution

Post by Loïc » Tue May 19, 2009 5:42 pm

Hi,

Could you tell me the way you are using to retrieve the DPI from the scanned images ?

Kind regards,

Loïc

ctn
Posts: 57
Joined: Thu Dec 04, 2008 6:20 pm

Re: Exact resolution

Post by ctn » Wed May 20, 2009 9:32 am

Hi,
Please find the code snippet below:

Code: Select all

		public string setImage(byte[] image)
		{
			MemoryStream ms = new MemoryStream(image, false);

			BitmapImage bi = new BitmapImage();
			bi.BeginInit();
			bi.StreamSource = ms;
			bi.EndInit();

			string result = "";
			result += "  sizePixels=" + TypeUtil.objectToString(new Size(bi.PixelWidth, bi.PixelHeight)) + "\r\n";
			result += "  sizeInches=" + TypeUtil.objectToString(new Size(bi.PixelWidth / bi.DpiX, bi.PixelHeight / bi.DpiY)) + "\r\n";
			result += "  DPI=(" + bi.DpiX + ", " + bi.DpiY + ")\r\n";

			image1.Source = bi;

			return result;
		}
Thanks
ctn

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Exact resolution

Post by Loïc » Thu May 21, 2009 7:58 pm

Hi,

I can check your code.

At the line:

Code: Select all

bi.StreamSource = ms;
I can determine what is ms.

Please, scan an image in 75 DPI, use the GetVerticalResolution() & GetHorizontalResolution() methods of GdPicture. I don't think the result will be 74 but something such as 74.98 (the value provided by the TWAIN device.

For the next release I will add a feature to automatically round DPI provided by a TWAIN device to the near integer value.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest