Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. resize image size and printer
Forum Updated to NodeBB v4.3 + New Features

resize image size and printer

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 177 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Ramkumar MohanR Offline
    Ramkumar MohanR Offline
    Ramkumar Mohan
    wrote on last edited by
    #1

    I Wrote this code,

    QPixmap image("E:/QT Offline/Qt5.12.12/build_Generator-Desktop_Qt_5_12_12_MinGW_64_bit-Debug/XXX.png");
    QPrinter *printer=new QPrinter(QPrinter::HighResolution);
    printer->setPrinterName("Canon");
    QPainter painter;
    painter.begin(printer);
    double xscale = printer->pageRect().width() / double(image.width());
    double yscale = printer->pageRect().height() / double(image.height());
    double scale = qMin(xscale, yscale);
    painter.translate(printer->paperRect().x() + printer->pageRect().width() / 2,
    printer->paperRect().y() + printer->pageRect().height() / 2);
    painter.scale(scale, scale);
    painter.translate(-width() / 2, -height() / 2);
    painter.drawPixmap(0, 0, image);
    painter.end();
    ui->label_21->render(&painter);

    If I run the code in this, the printing is larger than the paper size.

    How to Resize image (Width & Height) and print ?
    Printing Paper Size Width : 60mm and Heigth 25mm

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved