本文整理汇总了C++中document::Ptr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::size方法的具体用法?C++ Ptr::size怎么用?C++ Ptr::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类document::Ptr
的用法示例。
在下文中一共展示了Ptr::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
void PrintHelper::print(Document::Ptr doc)
{
doc->startLoadingFullImage();
doc->waitUntilLoaded();
QPrinter printer;
PrintOptionsPage* optionsPage = new PrintOptionsPage(doc->size());
optionsPage->loadConfig();
std::unique_ptr<QPrintDialog> dialog(
KdePrint::createPrintDialog(&printer,
QList<QWidget*>() << optionsPage,
d->mParent)
);
dialog->setWindowTitle(i18n("Print Image"));
bool wantToPrint = dialog->exec();
optionsPage->saveConfig();
if (!wantToPrint) {
return;
}
QPainter painter(&printer);
QRect rect = painter.viewport();
QSize size = d->adjustSize(optionsPage, doc, printer.resolution(), rect.size());
QPoint pos = d->adjustPosition(optionsPage, size, rect.size());
painter.setViewport(pos.x(), pos.y(), size.width(), size.height());
QImage image = doc->image();
painter.setWindow(image.rect());
painter.drawImage(0, 0, image);
}
示例2: adjustSize
QSize adjustSize(PrintOptionsPage* optionsPage, Document::Ptr doc, int printerResolution, const QSize & viewportSize)
{
QSize size = doc->size();
PrintOptionsPage::ScaleMode scaleMode = optionsPage->scaleMode();
if (scaleMode == PrintOptionsPage::ScaleToPage) {
bool imageBiggerThanPaper =
size.width() > viewportSize.width()
|| size.height() > viewportSize.height();
if (imageBiggerThanPaper || optionsPage->enlargeSmallerImages()) {
size.scale(viewportSize, Qt::KeepAspectRatio);
}
} else if (scaleMode == PrintOptionsPage::ScaleToCustomSize) {
double wImg = optionsPage->scaleWidth();
double hImg = optionsPage->scaleHeight();
size.setWidth(int(wImg * printerResolution));
size.setHeight(int(hImg * printerResolution));
} else {
// No scale
const double INCHES_PER_METER = 100. / 2.54;
int dpmX = doc->image().dotsPerMeterX();
int dpmY = doc->image().dotsPerMeterY();
if (dpmX > 0 && dpmY > 0) {
double wImg = double(size.width()) / double(dpmX) * INCHES_PER_METER;
double hImg = double(size.height()) / double(dpmY) * INCHES_PER_METER;
size.setWidth(int(wImg * printerResolution));
size.setHeight(int(hImg * printerResolution));
}
}
return size;
}
示例3: resizeImage
void ImageOpsContextManagerItem::resizeImage()
{
if (!d->ensureEditable()) {
return;
}
Document::Ptr doc = DocumentFactory::instance()->load(contextManager()->currentUrl());
doc->startLoadingFullImage();
DialogGuard<ResizeImageDialog> dialog(d->mMainWindow);
dialog->setOriginalSize(doc->size());
if (!dialog->exec()) {
return;
}
ResizeImageOperation* op = new ResizeImageOperation(dialog->size());
applyImageOperation(op);
}