Bug 160148 - scan size incorrect if no preview done first (overallHeight and overallWidth hardcoded in class Previewer)
Summary: scan size incorrect if no preview done first (overallHeight and overallWidth ...
Status: RESOLVED WORKSFORME
Alias: None
Product: kooka
Classification: Applications
Component: libkscan (show other bugs)
Version: unspecified
Platform: Slackware Linux
: NOR normal
Target Milestone: ---
Assignee: Jonathan Marten
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-31 10:30 UTC by Alex Kempshall
Modified: 2008-05-28 14:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Kempshall 2008-03-31 10:30:06 UTC
Version:            (using KDE 3.5.9)
Installed from:    Slackware Packages
OS:                Linux

overallHeight and overallWidth are hardcoded in previewer.cpp. I believe that these are the maximum scan area for the scanner and therefore should be configurable. Currently the code is -

    overallHeight = 295;  /* Default DIN A4 */
    overallWidth = 210;

which is not A4. This setting reduces the width and height of any scan I do by a factor of
295/297 and 210/215.

I believe - 
the comment should be removed as it is irrelevant
the values should be configurable somehow.


The Maximum Document Size specification for my scanner is  Letter ( 8.5" x 11.7") which equates to 215.9 and 297.18. If I change the overallHeight and overallWidth, in previewer.cpp, to 297 and 215 respectively an A4 scan gives me a scan that matches my original in size.

I can appreciate that not everyone's scanner will have a maximum document size of Letter.
Comment 1 Jonathan Marten 2008-04-26 21:26:42 UTC
The comment may be misleading, but I'm not sure that the hardcoded values are a problem regardless of the scanner bed size.

The preview scan is always done at the maximum scan area (ScanParams::slAcquirePreview() calling ScanParams::slMaximalScanSize()).  When the preview scan completes, 
Previewer::newImage() calls Previewer::setScanSize() which sets overallHeight/overallWidth to the size of the preview result image - i.e. the scanner bed size.  These values are then used in all subsequent size calculations.

So if a preview scan is done first, the scaling should be correct.  This may possibly not happen, though, if a final scan is started immediately without a preview scan first.  Leaving this bug open for further investigation.
Comment 2 Jonathan Marten 2008-04-26 21:45:16 UTC
Confirmed.  If no preview scan is done, Previewer::setScanSize() is never called so the values stay as their hardcoded default.  (Which, to add insult to injury, are wrong - A4 is 297mm high not 295).

Letter paper, BTW, is 216mm x 279mm.  Did you mean to write '279' instead of '297', or is your scanner bed a very odd size?
Comment 3 Alex Kempshall 2008-05-01 00:06:10 UTC
Must have had a funny five minutes. The Maximum Supported Media Size of my Canon n670u is 216 x 297 mm. Probably got confused with the imperial measurements! I normally go straight, or like to, a final scan. If the settings are remain the same from previous scans I see little point in doing a preview first when starting kooka.

So. If the hardcoded values were correctly set to A4 those users with an A4 scanner can go straight to a final scan assuming they've changed the dropdown menu, under Preview, from Custom to A4.

For those users with say an A3 scanner, are there any, would have to do a preview first. Noticed that the before mentioned dropdown menu doesn't contain a setting for A3.

Getting back to the initial point the hardcoded values should therefore be 297 x 216 reflecting maximum height A4 and maximum width - Letter.

1. A preview using an A4 scanner will change them to A4 values.
2. A preview using a Letter scanner would change them to Letter values.
3. No preview would leave them as hardcoded.

Comment 4 Jonathan Marten 2008-05-12 16:28:08 UTC
SVN commit 806900 by marten:

Scan size selection control moved from the previewer to the
scan parameters.  A more logical place for it, and makes it
possible to scan a preset area without having to do a preview first.

Much simplified the signal/slot communications between the scan
parameters, previewer and preview image.

Kooka:

"About" shows new home page at http://techbase.kde.org/Projects/Kooka

libkscan:

Show previewer file size in the standard localised format, using KIO::convertSize()
Take account of colour mode and bit depth when calculating that size
Properly handle scanner bed size, bug 160148
Show selection area in pixels as well as millimetres
Fix occasional crash when using KScanOption::get() on a SANE_TYPE_STRING value

CCBUG:160148



 M  +2 -0      kooka/kookagallery.cpp  
 M  +37 -68    kooka/kookaview.cpp  
 M  +1 -1      kooka/kookaview.h  
 M  +1 -1      kooka/main.cpp  
 M  +5 -6      kooka/scanpackager.cpp  
 M  +2 -2      libkscan/Makefile.am  
 M  +201 -255  libkscan/img_canvas.cpp  
 M  +15 -31    libkscan/img_canvas.h  
 M  +1 -0      libkscan/kscancontrols.cpp  
 M  +19 -7     libkscan/kscandevice.cpp  
 M  +2 -0      libkscan/kscandevice.h  
 M  +18 -9     libkscan/kscanoption.cpp  
 M  +2 -2      libkscan/kscanoption.h  
 M  +189 -335  libkscan/previewer.cpp  
 M  +31 -46    libkscan/previewer.h  
 M  +2 -1      libkscan/scandialog.cpp  
 M  +200 -94   libkscan/scanparams.cpp  
 M  +17 -12    libkscan/scanparams.h  
 A             libkscan/scansizeselector.cpp   [License: LGPL (v2+)]
 A             libkscan/scansizeselector.h   [License: LGPL (v2+)]
 M  +14 -30    libkscan/sizeindicator.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=806900
Comment 5 Jonathan Marten 2008-05-12 16:30:54 UTC
Fixed by that commit - area is properly initialised to scanner bed size as reported by SANE.
Comment 6 Alex Kempshall 2008-05-28 14:25:26 UTC
That's fixed the problem whereby I was seeing a slightly different size of image when I went straight to a final scan.