Hi,

Carlo Scarfoglio wrote:
Hi all,
I started with fixing a problem with my HP OfficeJet scanner and now I'm having a look at several issues that I found checking the code of the scanner dialog used in writer and draw. The functionality is there, but it looks like old, unmantained code.

not exactly unmaintained, but I haven't touched the functional part in five years ...

Bugs fixed so far:
1) The dialog offered two resolution selections for the OfficeJet: 75 and 1200 DPI, the minimum and maximum. The OfficeJet can scan at any DPI value between 75 and 1200, but the edit box was not editable. I inserted some additional DPI values in the listbox and made the edit box editable. This should work for any scanner that can scan at any DPI value between min and max.

The resolution box (maReslBox) is a NumericBox, so you should be able to enter any value between min and max there. It is disabled only if the sane driver does fail to provide the range for the resolution. Aside from that there is a modify handler for that box (see line 597 of sanedlg.cxx) that might do something unwise.

2) Tested with a Canon Lide scanner, the listbox offered several DPI values, but again only the min and max values were selectable, The code wrongly set the min and max listbox range: the min DPI value as max and viceversa. This happened because the Lide can scan at fixed DPI values, but the driver returns the values in the opposite order to what the code expected it to be. The resolution edit box is not editable.

Oops. Well sorting the values should fix that.

I reworked the user interface. The changes so far.
3) Moved controls around to make the dialog more compact.
4) Added a listbox to choose the scan mode (Color, Grey and Lineart) directly, without accessing the advanced options treebox. Several mouse clicks saved. And 5) removed the Advanced options checkbox. The treebox is always in advanced mode.
6) Increased the size of the preview rectangle.

Sounds ok to me.

The preview rectangle poses a problem. The X and Y sizes are constants set in the .hrc file. I can turn them into variables, and set them at runtime according to the width and height of the scan area (the OfficeJet has 220x381 mm, the Lide 215x300 mm, for instance) and within the bounds of the dialog box. But the preview image is always vertically squashed because the screen aspect ratio is not taken into account. Aspect ratio is usually 1,25 (for 1280x1024) or 1,33 (for 1024z768), but new LCD screens can have other ratios.

Just for understanding: you don't really mean the screen aspect but the ratio width/height of individual pixels, that is the ratio between DPIx and DPIy, not between absolute screen width and height.

I couldn't find a way to determine this ratio. There are private variables in the Window class that (my guess) should hold these values. I think that some functions, such as PixelToLogic, etc should provide help, but I couldn't find any documentation.

Can anybody provide help or a hint?

PixelToLogic and vice versa converts between the current map mode and pixels. Since the current map mode is most likely MAP_PIXEL in the dialog, you're kind of stuck. For such conversions (assuming you are in a memeber function of that dialo) you can code like this.

Push( PUSH_MAPMODE );                   // save mapmode
SetMapMode( MapMode( MAP_POINT ) );     // set mapmode for points

Size aSize( 100, 100 );                 // size in pixel
Size aPtSize( PixelToLogic( aSize ) );  // converted size in points

Pop();                                  // restore mapmode

However you will find that this does not work either since the DPI in x and y are often the same, even if on the real screen they are not. Actually since these are so often wrong they are forced to be equal in vcl's system dependent X11 code.

Kind regards, pl

--
If you give someone a program, you will frustrate them for a day;
if you teach them how to program, you will frustrate them for a lifetime.
     -- Author unknown

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to