ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How to get scanner DPI capability
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Homer

USA
70 Posts

Posted - Dec 07 2021 :  20:47:27  Show Profile  Reply
I would like to populate a combobox list with the DPI values the scanner is capable of. In a very old version I used to use the following in a procedure that could compute the resolutions available. In D2007, code completion says this is legal, but it creates an error. Can someone show me the way?

MyDouble := ImageEnMView1.MIO.TwainParams.XResolution.RangeMax

xequte

38180 Posts

Posted - Dec 08 2021 :  00:30:50  Show Profile  Reply
What is the error that you get?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Homer

USA
70 Posts

Posted - Dec 08 2021 :  11:34:03  Show Profile  Reply
There is no error message. When that statement executes, the program crashes and the IDE displays the CPU page. The code that is causing this problem worked fine when I was running ImageEn 2.1. I'll include the actual code below:

I don't know if this matters, but the old "unregistered" banner still appears in the IDE, but not at runtime.


procedure TfrmABSinterface.GetAvailableDPI;
var
  i, iMaxX, IMaxY, Imax : integer;
begin

     try
           {----- Get Maximum Available Resolution (DPI) from the device. }
        iMaxX := Trunc(frmMain.ImageEnMView1.MIO.TwainParams.XResolution.RangeMax);
        iMaxY := Trunc(frmMain.ImageEnMView1.Mio.TWainParams.YResolution.RangeMax);
           {----- Pick the lowest between X and Y because we only display one value.}
        if iMaxX > iMaxY then
          iMax := iMaxY
        else
          iMax := iMaxX;
           {----- The array max is 10 so don't go beyond.}
        if iMax > 10 then
          iMax := 10;
           {----- We can't read DPI. ASSUME scanner can 300 DPI.}
        if iMax = 0 then
          iMax := 4;
           {----- Populate the combobox items}
        For i := 0 to iMax do
        begin
          if DPI[i] > DPI[iMax] then
            Break;
          cboResolution.Items.Add( IntToStr(DPI[i]) + ' Dots per inch.');
        end;
           {----- Set the cbo text value to match one in the list.}
        if iMax >= 2 then
          cboResolution.ItemIndex := 2
        else
          cboResolution.ItemIndex := iMax;
     except
        on E: Exception do
        begin
          ShowMessage(E.Message);
        end;
     end;
end;
Go to Top of Page

xequte

38180 Posts

Posted - Dec 08 2021 :  15:02:01  Show Profile  Reply
That code looks good. Are you able to reproduce the error in any of our demos?

I'm a little concerned that you are still seeing the "unregistered" warning, which does not happen with the new components.

You might want to try resetting your ImageEn state:
Search your system for any PKIE*.* and DPKIE*.* files and remove them (it might help to review the library paths under Tools > Options, Library). Then reinstall ImageEn.


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Homer

USA
70 Posts

Posted - Dec 09 2021 :  11:07:13  Show Profile  Reply
I've removed the old ImageEn entries. Now when I open Delphi I get the following message (and many like it):

The procedure entry point @Iexlayerprops@TIELayerProps@ could not be located in the dynamic link library C:\ProgramData\ImageEn\Delphi2007\DPKIECTRL11.BPL.

I have started a new thread with a more meaningful subject line:

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=5179
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 04 2022 :  13:31:08  Show Profile  Reply
Now that I have a work-around for the error originally reported, the sample code always returns 0 (zero/zed). However,
FloatToStr(frmMain.ImageEnMView1.MIO.AcquireParams.XResolution));
returns the scanner's current setting. Also,
frmMain.ImageEnMView1.MIO.AcquireParams.XResolution := 2400.0;
sets the scanner's DPI to 2400. At least that's what is returned with the above code example.
So, I know how to set and get the DPI, but I don't know how to get the DPI range the scanner is able to support. What am I doing wrong in the procedure originally posted? I would to use that to populate the list of my DPI combo box.
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 04 2022 :  14:11:13  Show Profile  Reply
For now, I'm just going to assume that all modern scanners can handle resolution from 100 to 1200, and trap errors that might occur. If there's a better way, I'd love to know.
Go to Top of Page

xequte

38180 Posts

Posted - Jan 07 2022 :  00:39:16  Show Profile  Reply
Hi

This is only valid for Twain devices:

ImageEnMView1.MIO.TwainParams.XResolution.RangeMax

What is the API of the selected source?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 09 2022 :  04:09:57  Show Profile  Reply
I don't think I'll ever need WIA so Twain should be fine. Also things seem a little faster when I "ignore" WIA. I've never promised anything other than Twain compliance to my users anyway.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: