Results 1 to 20 of 28

Thread: Qt4 and TWAIN scanning

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    Hi,

    Yes, there are 6 files.

    I don't understand why you have to use a lot of tricks. Is there any other person that can try downloading the file and decompress it to check if there is any error on uncompress it?
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    the notice on the forum says that they have some problems into attachments before 1st sep 2010. may be that is the issue. the new file is good.

  3. #3
    Join Date
    Oct 2010
    Posts
    7
    Qt products
    Qt4

    Smile Re: Qt4 and TWAIN scanning

    I don´t Know but the newest file had the same problem that the first one to open. I don´t Know why but... I tried with diferents programs to deskompress the file . The same message..."end of file corrupt"... "the file can´t bee opened"....

    Finnally i got the file opened in an unusual way. I have the six files and must find time to study them.

    Thanks

    Jokinb

  4. #4
    Kata Guest

    Default Re: Qt4 and TWAIN scanning

    Hello all,

    Have you got any simple example to use this class ?
    I have try to acquire and save 1 A4 image :
    Qt Code:
    1. #include <iostream>
    2. #include "qtwain.h"
    3.  
    4. using namespace std;
    5.  
    6. int main(int agc, char **argv)
    7. {
    8. QTwain t;
    9. t.initTwain();
    10. if(t.isValidDriver() && t.selectSource())
    11. {
    12. t.setResolutionY(1654);
    13. t.setResolutionX(2339);
    14. t.setDepth(1);
    15. t.acquire(1);
    16. }
    17. return 0;
    18. }
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work; why ?

    For your help, by advance, thanks.

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    The 'example' in the code!
    Just look in there.
    Qt Code:
    1. void QtTwainScan::scan()
    2. {
    3. if (!m_pTwain->initTwain())
    4. qWarning("initTwain() call not successful!");
    5. else
    6. if (!m_pTwain->selectSource())
    7. qWarning("selectSource() call not successful!");
    8. else
    9. if (!m_pTwain->acquire())
    10. qWarning("acquire() call not successful!");
    11. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. The following user says thank you to high_flyer for this useful post:


  7. #6
    Kata Guest

    Default Re: Qt4 and TWAIN scanning

    Quote Originally Posted by high_flyer View Post
    The 'example' in the code!
    Just look in there.
    Qt Code:
    1. void QtTwainScan::scan()
    2. {
    3. if (!m_pTwain->initTwain())
    4. qWarning("initTwain() call not successful!");
    5. else
    6. if (!m_pTwain->selectSource())
    7. qWarning("selectSource() call not successful!");
    8. else
    9. if (!m_pTwain->acquire())
    10. qWarning("acquire() call not successful!");
    11. }
    To copy to clipboard, switch view to plain text mode 
    Happy new year.
    I have tried this (with QtCreator or the CLI) :
    Qt Code:
    1. #include <QApplication>
    2. #include "qtwain.h"
    3.  
    4. int main(int argc, char **argv)
    5. {
    6. QApplication app(argc, argv);
    7. QTwain m_pTwain;
    8. if (!m_pTwain.initTwain())
    9. qWarning("initTwain() call not successful!");
    10. else
    11. if (!m_pTwain.selectSource())
    12. qWarning("selectSource() call not successful!");
    13. else
    14. if (!m_pTwain.acquire())
    15. qWarning("acquire() call not successful!");
    16. return app.exec();
    17. }
    To copy to clipboard, switch view to plain text mode 

    But I still have a segmentation error,
    Have you ever have this bug ?

    By advance,
    Thanks

  8. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    Happy new year to you too!

    I just had a 2 seconds look - to see if I could help you getting started.
    I didn't look further.
    But you should.
    Maybe there are some initializations needed to be done, I don't know, stuff like that.
    Follow the application in the debugger, and see exactly where it crashes, it will tell you a lot about what the problem is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #8
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,233
    Thanks
    303
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt4 and TWAIN scanning

    It is probably because the QTwain class requires an event loop to be running, and until you call app.exec(), there is no event loop.

    Your code is fundamentally different from the example in the previous post in the thread. You need to move your twain code into a method that gets called after the event loop has started.

  10. The following user says thank you to d_stranz for this useful post:


  11. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    Good point.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. #10
    Kata Guest

    Default Re: Qt4 and TWAIN scanning

    Quote Originally Posted by d_stranz View Post
    It is probably because the QTwain class requires an event loop to be running, and until you call app.exec(), there is no event loop.

    Your code is fundamentally different from the example in the previous post in the thread. You need to move your twain code into a method that gets called after the event loop has started.
    Thank you very much,
    I create a Widget QTwain and used according to your examples, but I have not found a way to save the image acquired only by the interface.
    The only way, according to my investigations, would be to uncomment the lines 92 to 95 of qtwain.cpp, and yet I know not how to get the values to pass as an argument to CopyImage.

    For your help,
    By advance,
    Thanks

  13. #11
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    Hi,

    As I said, I only modify code snippets to get to do what I needed. Improvements that you can get will be welcome.
    I only tested on a Brother multifunction printer, so If anyone can test on othre devices and check if it works it will be great.
    Òscar Llarch i Galán

  14. #12
    Kata Guest

    Default Re: Qt4 and TWAIN scanning

    Hello,
    thank you for your answers
    I have cleaned the code and set more generical QtTwain and I have added a methode to save the scanned image.

    Enjoy
    Attached Files Attached Files

  15. #13
    Join Date
    Apr 2011
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Qt4 and TWAIN scanning

    Hi

    First thanks to kata for you help. Now the problem is that I can not see the image out.jpg. debido a esto:

    QPixmap::fromWinHBITMAP(), failed to get bitmap info ()

    I have windows 7, qt creator 2.01 based qt 4.7.0.

    this is what I do

    1)instal qt creator sdk
    2) open qt creator, open project, I look for. pro and open it.
    3) running

    What am I doing wrong? or I'm missing.
    -----------------------------------------------------
    In the .pro :
    TEMPLATE = app
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .
    LIBS += -lgdi32

    # Input
    HEADERS += qtwain.h stdafx.h twain.h twaincpp.h
    SOURCES += main.cpp qtwain.cpp twaincpp.cpp
    -------------------------------------------------------
    Qt displays the following messages:

    Application Output:
    Starting C:\Users\Elegido\Desktop\QtScanner5-build-desktop\debug\QtScanner5.exe...
    QPixmap::fromWinHBITMAP(), failed to get bitmap info ()

    Compile output:
    Running build steps for project QtScanner5...
    Configuration unchanged, skipping qmake step.
    Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `C:/Users/Elegido/Desktop/QtScanner5-build-desktop'

    C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug

    mingw32-make[1]: Entering directory `C:/Users/Elegido/Desktop/QtScanner5-build-desktop'

    mingw32-make[1]: Nothing to be done for `first'.

    mingw32-make[1]: Leaving directory `C:/Users/Elegido/Desktop/QtScanner5-build-desktop'

    mingw32-make: Leaving directory `C:/Users/Elegido/Desktop/QtScanner5-build-desktop'

    The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited normally.

    PLease Help!! tThanks

  16. #14
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt4 and TWAIN scanning

    Hi,

    Someone is telling me that the file is not uncompressing right. Try this other one
    Attached Files Attached Files
    Òscar Llarch i Galán

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.