Results 1 to 15 of 15

Thread: Qt Printing Good Image Quality.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Default Qt Printing Good Image Quality.

    Hi to all,
    I'm having trouble printing an image inseted into a QTextDocument. The image has a 1900 dpi and the preview(Screenshot-1.png) looks good but printing it the resulting quality is poor(Screenshot-2.png).
    I'm attaching the project to allow you a test and give me a feedback.
    Thanks in advance, Danilo.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Qt Printing Good Image Quality.

    Ehm, the image has a width of 387 pixel. Assuming 1900dpi this would result in about 5mm! Your code seems to be all right, but the image quality is too poor.

  3. #3
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Default Re: Qt Printing Good Image Quality.

    The image is created by Inkscape, I scaled according to this formula DesignWidth = WantedWidth * 90 / WantedDpi.
    Any hints?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt Printing Good Image Quality.

    Why *90?

    If you want an image that is 1 inch wide and you want it to be 1900dpi then it has to be 1900 pixels wide. 387 pixels and 1900 dpi i 0.2'' which is about 4.9mm.


    BTW. Have you checked the actual resolution that the printer is set into when using QPrinter::HighResolution?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Default Re: Qt Printing Good Image Quality.

    Quote Originally Posted by wysota View Post
    Why *90?
    I've found this answer on an Inkscape forum:

    Your drawing in Inkscape must be 551,4x832,5 px so when you export it at 300dpi the size of the .png file will be 1838x2775px.
    the formula I used was a=1838*90/300=551,4
    so I scaled my drawing to 4.9mm in order to export an image of 387 pixels per 1900dpi. It has been an attempt to have a better result in printing. Before that I used to create my drawing with real size or rather as in that case a 387 pixels drawing at 90dpi. It's frustrating that the old software I'd like to replace has a better printing than I can do with Qt.

    Quote Originally Posted by wysota View Post
    BTW. Have you checked the actual resolution that the printer is set into when using QPrinter::HighResolution?
    Do you mean override the resolution with QPrinter::setResolution( int dpi )?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt Printing Good Image Quality.

    I mean to print a line of known length and use a ruler to calculate its resolution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Qt Printing Good Image Quality.

    So if you use Inkscape, then the easiest (= with no calculation of your own) would be to work with mm units while painting. In the export dialog you can then simply say what dpi you would like to have. By the way, scaling a svg only to export it perverts the whole purpose of vector drawing. Also please do not state that Qt has bad printing support, when it seems that you haven't understand the way Qt handle things.

    And about the 90: I guess that has to do with the screen resolution in combination with wysota's approach. (It is always an advantage to understand snippets something before c&p.)

  8. #8
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Default Re: Qt Printing Good Image Quality.

    Quote Originally Posted by wysota View Post
    I mean to print a line of known length and use a ruler to calculate its resolution.
    So, I printed a line of 200 pixels using Paint.exe and, on the paper, his length was about 5,60 cm.
    The formula I used to calculate DPI is:

    DPI = (Pixels * 2,54) / Length expressed in cm

    resulted of 91dpi.

    Using a
    Qt Code:
    1. QPrinter printer(QPrinter::HighResolution);
    To copy to clipboard, switch view to plain text mode 
    then I got the printer.resolution(); of 600 an the resulting length of the same line was of 5,3 cm about 95dpi.

    Sorry but I don't get it!

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt Printing Good Image Quality.

    It means your printer prints with 90 dpi and not 1900dpi. Did you set it to 1900dpi? Did you use QPrintDialog for that?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Jun 2008
    Location
    Rome, Italy
    Posts
    95
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    19
    Thanked 2 Times in 2 Posts

    Default Re: Qt Printing Good Image Quality.

    Quote Originally Posted by wysota View Post
    It means your printer prints with 90 dpi and not 1900dpi. Did you set it to 1900dpi? Did you use QPrintDialog for that?
    I didn't anything but use the project as it is.
    Here is the project with the different dpi images I tried an the SVG file too. I got the same poor result!
    PrintTest-1.zip

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Qt Printing Good Image Quality.

    The problem is not with the image but rather with your printer setup. Use QPrintDialog and set the printer resolution correctly. Your printer is set to 90 dpi so it will print in 90 dpi unless you tell it to print in higher resolution.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 4
    Last Post: 11th August 2011, 11:31
  2. Image Quality when printing to PDF
    By JayMan8081 in forum Qt Programming
    Replies: 4
    Last Post: 25th August 2010, 18:19
  3. QGraphicsScene Low Image Quality
    By nemmartins in forum Qt Programming
    Replies: 2
    Last Post: 30th March 2010, 20:19
  4. Printing Screenshot -> poor quality
    By MarcSchubert in forum Qt Programming
    Replies: 2
    Last Post: 14th May 2007, 10:48
  5. Painter greyscale, image quality paint-brush!
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 22nd March 2007, 20:32

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
  •  
Qt is a trademark of The Qt Company.