Display last scanned image in tab of libksane's KSaneWidget
Needs ReviewPublic

Authored by trufanov on Sat, Jan 5, 11:56 PM.

Details

Reviewers
sars
Summary

That's a new feature for KSaneWidget, that is turned off by default and should be enabled via UI (SkanLite).
It addresses the following problem.

Currently KSaneWidget has preview and scan buttons.
If you click on preview - whole scanning area will be scanned with small dpi (usually 50dpi). And then displayed in GUI. The displayed scanner area could be used to select actual page in it and perform a real scan of selected subarea with a good dpi (300+ dpi). Selection of the subareas is a great option that allows to minimize page scanning time.

If you click scan - you'll just subsequently scan all subareas, or whole scanning area if no subareas were selected. But you'll not see the results. Result can't be displayed in preview window instead of preview as one of it's main functions is to let user select subareas and result may be subarea by itself. There is an option that shows you a result in pop up dialog just before saving, but this interrupts the scanning process and waits for user response.

My scanning process is usually like that: Put a book in scanner, align it to one of scanner's corners. Do preview, select scanning area, scan. Turn the page, align book to the same corner, scan. Etc. I don't see the resulting images. Otherwise I would need to open last saved file every time or enable "preview before save" option and get interrupted after each scan. I rely on fact that book pages are all of the same size and all content will be scanned if I place book in the same position. So I'm scanning in "blind" mode without actually seeing results.

But there are cases when I want to fast check last scanning result even if i'm sure all content is inside subarea:

  1. I forgot if I already turned the pages or accidentally closed the book and want to recall last scanned page no.
  2. I've changed some scanning settings (color/grayscale or dpi) and want to check if I managed to achieve expected quality.
  3. I want to check if there aren't any hairs, dirt, small piece of paper on scanner's glass that could get there after pages turn.
  4. I want to check how curvy is text that is closer to the book's spine. It depends on strength of pressure on the book and could change in case of page is in a middle of the book or at beginning.

etc.

So I need at least a button "Show me last scan" that I can click when I want to check last result.
But I decide to make a bit better function - display last scan automatically in widget's UI. First idea was to copy last scanned image to respecting area of displayed preview image. But it's inconsistent as UI will display some chimera made of old image and new images. And as preview is 50 dpi and actual scans of subareas are mostly 300+ dpi this will require some scaling that require noticeable cpu time. Thus I end up with following solution:

If function is enabled widget will display a vertical tab near preview image with tabs: "Preview" and "Current Scan". In case second is clicker KSaneImageViewer is switched to display another QImage. It's area selection functionality is disabled as there is no sense to select subareas in subarea. And this QImage isn't just loaded from latest saved scan file but builded dynamically chunk by chunk during scanning in progress as preview image is build. So user'll see the result even before scanning ends.

After turning on this function user experience will be following:
Put a book on scanner, click preview, select pages area in preview image, switch to Current Scan tab, click Scan button - look on actual scanning results at real time. Turn the page, click on scan button again. etc. Need to change selection? Go to preview tab, change selection in it (or even update preview) and get back to Current scan Tab for actual scanning.

This review contains most of the code, but to test it you'll need to enable it via GUI (as it's disabled by default). Thus another patch will be send to Skanlite repository to add required setting in its GUI.

P.S. Feature is switched off by default bcs it requires more RAM than usual. High dpi quality A4 scans may be too big to keep another copy in RAM of old <=1Gb RAM machine without system performance decrease.

Test Plan

Apply patch, apply Skanlite's patch. build both. Launch Skanlite, Switch on "Display last image in separate tab" in its settings.

Diff Detail

Repository
R382 KSane Library
Lint
Lint Skipped
Unit
Unit Tests Skipped
trufanov requested review of this revision.Sat, Jan 5, 11:56 PM
trufanov created this revision.
yurchor added a subscriber: yurchor.Sun, Jan 6, 7:20 AM

Thanks for fixing these minor typos.

src/ksanepreviewimagebuilder.cpp
88–99

Typo: reqired -> required

src/ksaneviewer.cpp
358

Typo: is whole -> if whole

372

Typo: it always display -> it always displays

395

Typo: opertions -> operations

450–451

Typo: selections opertions -> selection operations

610

Typo: peritted -> permitted

672

Typo: peritted -> permitted

src/ksanewidget_p.h
77

Typo: scn -> scan

80

Typo: regardles -> regardless

trufanov updated this revision to Diff 48806.Sun, Jan 6, 4:29 PM

Typos are fixed. Thanks!

sars added a comment.Mon, Jan 7, 10:30 AM

I have not had the time to review this properly sorry :(

I have long been thinking that the current monolithic widget design is a bit broken. It does not provide the flexibility to give you just the scan-options or just the preview or build your own rearranged UI.

This feature should IMO be in the application and not in the library, but the current design makes it hard to do that way :(

I'll have a look again when I get the time.