/*************************************************************************** * Copyright (C) 2005 by Stefan Kebekus * * kebekus@kde.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include "faxrenderer.h" #include "core/page.h" //#define KF_DEBUG KPDF_EXPORT_PLUGIN(FaxRenderer) FaxRenderer::FaxRenderer(KPDFDocument * doc) : Generator( doc ) { kWarning() << "fax generator has landed" <async) a="As"; kWarning() << a << "ync Pixmaprequestuest of " << request->width << "x" << request->height << " size, pageNo " << request->pageNumber << ", priority: " << request->priority << " pageaddress " << (unsigned long long int) request->page << endl; // Wait for all access to this documentRenderer to finish QPixmap* pix = new QPixmap(request->width,request->height); pix->fill(); QPainter p(pix); QImage img = fax.page(request->pageNumber).scaled(request->width,request->height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); p.drawImage( 0,0, img, 0,0,img.width(),img.height()); /* SimplePageSize psize = pageSizes[page->getPageNumber() - 1]; if (psize.isValid()) { QPainter *foreGroundPaint = page->getPainter(); if (foreGroundPaint != 0) { // Compute an image for the page. // WARNING: It may be tempting to compute the image size in // pixel, using page->height() and page->width(). DON'T DO // THAT. KViewShell uses transformations e.g. to rotate the // page, and sets the argument 'resolution' accordingly. Similar // problems occur if KViewShell required a shrunken version of // the page, e.g. to print multiple pages on one sheet of paper. int width_in_pixel = qRound(resolution * psize.width().getLength_in_inch()); int height_in_pixel = qRound(resolution * psize.height().getLength_in_inch()); img = img.scaled(width_in_pixel, height_in_pixel, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); foreGroundPaint->drawImage(0, 0, img); page->returnPainter(foreGroundPaint); } } else kError() << "FaxRenderer::drawPage() called, but page size for page " << page->getPageNumber() << " is invalid." << endl; // To indicate that the page was drawn, we set the appropriate flas in the page structure page->isEmpty = false; */ mutex.unlock(); request->page->setPixmap( request->id, pix ); signalRequestDone( request ); } bool FaxRenderer::loadDocument( const QString & fileName, QVector< KPDFPage * > & pagesVector ) { #ifdef KF_DEBUG kDebug() << "FaxRenderer::setFile(" << fname << ") called" << endl; #endif // Wait for all access to this documentRenderer to finish // mutex.lock(); // Now we assume that the file is fine and load the file into the // fax member. We abort on error and give an error message. bool ok = fax.loadImage(fileName); kWarning(1000) << "fax " << fileName << " loaded ok: " << ok <