QImage TwoDModelEngineApi::areaUnderSensor(const PortInfo &port, qreal widthFactor) const { DeviceInfo device = mModel.robotModels()[0]->configuration().type(port); if (device.isNull()) { device = mModel.robotModels()[0]->info().specialDevices()[port]; if (device.isNull()) { return QImage(); } } const QPair<QPointF, qreal> neededPosDir = countPositionAndDirection(port); const QPointF position = neededPosDir.first; const qreal direction = neededPosDir.second; const QRect imageRect = mModel.robotModels()[0]->info().sensorImageRect(device); const qreal width = imageRect.width() * widthFactor / 2.0; const QRectF sensorRectangle = QTransform().rotate(direction).map(QPolygonF(QRectF(imageRect))).boundingRect(); const qreal rotationFactor = sensorRectangle.width() / imageRect.width(); const qreal realWidth = width * rotationFactor; const QRectF scanningRect = QRectF(position.x() - realWidth, position.y() - realWidth , 2 * realWidth, 2 * realWidth); const QImage image(mFakeScene->render(scanningRect)); const QPoint offset = QPointF(width, width).toPoint(); const QImage rotated(image.transformed(QTransform().rotate(-(90 + direction)))); const QRect realImage(rotated.rect().center() - offset + QPoint(1, 1), rotated.rect().center() + offset); QImage result(realImage.size(), QImage::Format_RGB32); result.fill(Qt::white); QPainter painter(&result); painter.drawImage(QRect(QPoint(), result.size()), rotated, realImage); painter.end(); return result; }
void draw(const QPoint ¢er) { auto const p = center - src.rect().center(); auto const dstRect = QRect(p, src.size()).intersected(dst.rect()); if (!dstRect.isEmpty()) { auto const srcRect = src.rect().intersected({-p, dst.size()}); draw(dstRect, srcRect); } }
qreal PdfElementImage::paint(QPainter *painter) { qreal x = toQReal(_attributes.value("x", "0")); qreal y = toQReal(_attributes.value("y", "0")) + _offsetY; qreal w = toQReal(_attributes.value("width", "0")); qreal h = toQReal(_attributes.value("height", "0")); if (w > 0 && h > 0) { painter->setPen(Qt::NoPen); painter->setBrush(Qt::NoBrush); QRectF box(QPointF(x, y), QSizeF(w, h)); QImage picture; // Get the variable defined in the attribute "file" QString var = _attributes.value("file", ""); bool drawn = FALSE; // No variable found, the attribute "file" might point to an imagefile if (_variables->value(var, "").isEmpty()) { // Load the image (or default image) and print it QList<QString> images = replaceVariables(var); QString img; for (int i = 0; i < images.size(); i++) { img = QString("/").prepend(_templatePath).append(images.at(i)); if (picture.load(img)) { painter->drawImage( box, picture, QRectF(picture.rect()) ); drawn = TRUE; break; } } } else { // if an attribute exists with the addition "_file" the string in the attribute should be iinterpreted as a file, otherwise as SVG-Content bool imageIsFile = _variables->contains(var) && !_variables->value(var.append("_file"), "").isEmpty(); // Try to render a normal pixel image or as an SVG Image / Content QSvgRenderer svg; if (imageIsFile && picture.load(_variables->value(var))) { painter->drawImage( box, picture, QRectF(picture.rect()) ); drawn = TRUE; } else if ( (imageIsFile && svg.load( _variables->value(var) )) || (!imageIsFile && svg.load( _variables->value(var).toUtf8() )) ) { svg.render(painter, box); drawn = TRUE; } } // If the Image isn't drawn, show the default one if (!drawn) { showDefaultImage(painter, box); } } return bottom(); }
bool BE::Contacts::setPhoto(const QString &path) { QRect r(0,0,160,160); QImage img = QImage( path ); if (img.isNull()) return false; const float f = qMin( float(img.width())/float(r.width()), float(img.height())/float(r.height()) ); r.setSize( r.size()*f ); r.moveTopRight( img.rect().topRight() ); img = img.copy(r).scaled( QSize(160,160), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); img = img.convertToFormat(QImage::Format_ARGB32); // if ( !MPC::setting("rgbCover").toBool() ) { int r,g,b; palette().color(foregroundRole()).getRgb(&r,&g,&b); int n = img.width() * img.height(); const uchar *bits = img.bits(); QRgb *pixel = (QRgb*)(const_cast<uchar*>(bits)); // this creates a (slightly) translucent monochromactic version of the // image using the foreground color // the gray value is turned into the opacity #define ALPHA qAlpha(pixel[i]) #define GRAY qGray(pixel[i]) #define OPACITY 224 if ( qMax( qMax(r,g), b ) > 128 ) // value > 50%, bright foreground for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (OPACITY*GRAY) / 255 ) ) / 255 ); else // inverse for (int i = 0; i < n; ++i) pixel[i] = qRgba( r,g,b, ( ALPHA * ( (OPACITY*(255-GRAY)) / 255 ) ) / 255 ); } #if 1 QPainterPath glasPath; glasPath.moveTo( img.rect().topLeft() ); glasPath.lineTo( img.rect().topRight() ); glasPath.quadTo( img.rect().center()/2, img.rect().bottomLeft() ); QPainter p( &img ); p.setRenderHint( QPainter::Antialiasing ); p.setPen( Qt::NoPen ); p.setBrush( QColor(255,255,255,64) ); p.drawPath(glasPath); p.end(); #endif m_ui2->photo->setPixmap( QPixmap::fromImage( img ) ); return true; }
QImage ImageManager::createNewCanvas(QSize size, bool white) { QImage canvas (size, QImage::Format_RGB32); QPainter painter (&canvas); if (white) painter.fillRect( canvas.rect(), QColor ("white")); else painter.fillRect( canvas.rect(), QColor ("black")); return canvas; }
void drawOver( QImage& dst, QRect const& dst_rect, QImage const& src, QRect const& src_rect) { if (src_rect.size() != dst_rect.size()) { throw std::invalid_argument("drawOver: source and destination areas have different sizes"); } if (dst.format() != src.format()) { throw std::invalid_argument("drawOver: source and destination have different formats"); } if (dst_rect.intersected(dst.rect()) != dst_rect) { throw std::invalid_argument("drawOver: destination area exceeds the image"); } if (src_rect.intersected(src.rect()) != src_rect) { throw std::invalid_argument("drawOver: source area exceeds the image"); } uint8_t* dst_line = dst.bits(); int const dst_bpl = dst.bytesPerLine(); uint8_t const* src_line = src.bits(); int const src_bpl = src.bytesPerLine(); int const depth = src.depth(); assert(dst.depth() == depth); if (depth % 8 != 0) { assert(depth == 1); // Slow but simple. BinaryImage dst_bin(dst); BinaryImage src_bin(src); rasterOp<RopSrc>(dst_bin, dst_rect, src_bin, src_rect.topLeft()); dst = dst_bin.toQImage().convertToFormat(dst.format()); // FIXME: we are not preserving the color table. return; } int const stripe_bytes = src_rect.width() * depth / 8; dst_line += dst_bpl * dst_rect.top() + dst_rect.left() * depth / 8; src_line += src_bpl * src_rect.top() + src_rect.left() * depth / 8; for (int i = src_rect.height(); i > 0; --i) { memcpy(dst_line, src_line, stripe_bytes); dst_line += dst_bpl; src_line += src_bpl; } }
void MainWindow::renderMat(cv::Mat mat) { // Converting Mat to QImage for further rendering. QImage renderImage = FormatsConverter::mat2image(mat); // Clearing our scene from previous images. imageResultView->scene()->clear(); // Adding current image on the scene. imageResultView->scene()->addPixmap(QPixmap::fromImage(renderImage)); // Setting scene size to fit image and prevent it from growing. imageResultView->scene()->setSceneRect(renderImage.rect()); // Fitting image into view. imageResultView->fitInView(renderImage.rect(), Qt::KeepAspectRatio); }
void AppViewer::displayImage(QImage img){ scene->clear(); QImage resized = img.scaled(ui.graphicsView->size() *= 0.85, Qt::KeepAspectRatio); scene->addPixmap(QPixmap::fromImage(resized)); scene->setSceneRect(resized.rect()); ui.graphicsView->setScene(scene); }
void VideoSurface::paintEvent(QPaintEvent*) { lock(); QPainter painter(this); painter.fillRect(painter.viewport(), Qt::black); if (lastFrame) { QImage frame = lastFrame->toQImage(rect().size()); if (frame.isNull()) lastFrame.reset(); painter.drawImage(boundingRect, frame, frame.rect(), Qt::NoFormatConversion); } else { painter.fillRect(boundingRect, Qt::white); QPixmap drawnAvatar = avatar; if (drawnAvatar.isNull()) drawnAvatar = Style::scaleSvgImage(":/img/contact_dark.svg", boundingRect.width(), boundingRect.height()); painter.drawPixmap(boundingRect, drawnAvatar, drawnAvatar.rect()); } unlock(); }
void QtFrameBuffer::updateFrameBuffer() { QImage img = QPixmap::grabWindow(win).toImage(); #if 0 // This is actually slower than updating the whole desktop... QSize imgSize = img.size(); // verify what part of the image need to be marked as changed // fbImage is the previous version of the image, // img is the current one QImage map(imgSize, QImage::Format_Mono); map.fill(0); for (int x = 0; x < imgSize.width(); x++) { for (int y = 0; y < imgSize.height(); y++) { if (img.pixel(x, y) != fbImage.pixel(x, y)) { map.setPixel(x, y, 1); } } } QRegion r(QBitmap::fromImage(map)); tiles = tiles + r.rects(); #else tiles.append(img.rect()); #endif memcpy(fb, (const char *)img.bits(), img.byteCount()); fbImage = img; }
QImage GLImageDrawable::applyBorder(const QImage& sourceImg) { if(renderBorder() && m_borderWidth > 0.001) { QSizeF originalSizeWithBorder = sourceImg.size(); double x = m_borderWidth * 2; originalSizeWithBorder.rwidth() += x; originalSizeWithBorder.rheight() += x; QImage cache(originalSizeWithBorder.toSize(),QImage::Format_ARGB32_Premultiplied); memset(cache.scanLine(0),0,cache.byteCount()); QPainter p(&cache); int bw = (int)(m_borderWidth / 2); p.drawImage(bw,bw,sourceImg); //drawImage(bw,bw,sourceImg); p.setPen(QPen(m_borderColor,m_borderWidth)); p.drawRect(sourceImg.rect().adjusted(bw,bw,bw,bw)); //QRectF(sourceImg.rect()).adjusted(-bw,-bw,bw,bw)); m_imageWithBorder = cache; return cache; } if(!m_imageWithBorder.isNull()) m_imageWithBorder = QImage(); return sourceImg; }
QPixmap StyleHelper::alphaBlend(const QPixmap& src) { QImage imageSrc = src.toImage(); QImage imageCopy = imageSrc.convertToFormat(QImage::Format_ARGB32); QRect rectSrc = imageCopy.rect(); int w = rectSrc.width(); int h = rectSrc.height(); uchar* pixels = imageCopy.bits(); uint mask = 0; QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied; // Make a QImage out of the QPixmap and add alpha QImage image(w, h, imageFormat); if (!image.isNull()) { int bytes_per_line = w * sizeof(QRgb); for (int y = 0; y < h; ++y) { QRgb* dest = (QRgb*) image.scanLine(y); const QRgb* src = (const QRgb *) (pixels + y * bytes_per_line); for (int x = 0; x < w; ++x) { const uint pixel = src[x]; if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0) dest[x] = pixel | 0xff000000; else dest[x] = pixel | mask; } } } return QPixmap::fromImage(image, Qt::AutoColor); }
void ScanForAxes::updateView(const QImage& img) { // this is somewhat slow. since this may be an issue on slower computers, it can be disabled // in the default settings m_doc->slotUpdateViews(0, img.rect()); m_doc->sendUpdateGeometry(); }
void KTBrushEditor::paintEvent(QPaintEvent *e) { QFrame::paintEvent(e); if ( m_editor->editing ) { QImage *editArea = displayDevice(); QPainter painter( editArea ) ; painter.setRenderHint(QPainter::Antialiasing); painter.setPen(Qt::black); editArea->fill(qRgb(255, 255, 255)); painter.save(); drawEditor(&painter); painter.restore(); painter.end(); painter.begin(this); painter.translate(QPoint(width()/2-50, (height() - editArea->height())/2 )); painter.drawImage(QPoint(0, 0), *editArea); painter.drawRect(editArea->rect()); } else { DDisplayPath::paintEvent(e); } }
/*! \sa rotateWithCornerFilling(const QImage image) */ QImage Rotater::RotateImage( const QImage image, const QImage imageOrig) { QImage outImage = QImage( image); // outImage.fill( 0); ///////////////////////////////// QRect rect = image.rect(); QPainter painter( &outImage); painter.setRenderHint( QPainter::SmoothPixmapTransform); // Paint original as background ///// painter.drawImage ( rect, image); // a. no need to do this as outImage is a already copied // b. can't agree: without above line, the rotated image is bluring // a. it is bluring regardless having that line or not // Clip path QPainterPath path( QPointF( 0, 0)); path.addRect( rect); painter.setClipPath( path); // Transformer: rotate at center of original image with angle m_theta // use m_transform instead painter.setTransform( m_transform /*transform*/); // Overlap it to original painter.drawImage( rect, imageOrig); return outImage; }
void FrameReader::append( QImage recimg , int playtime ) { int position = movie.size(); int fplay = playtime; if (fplay < 30) { fplay = default_play_time_ms; } if (!recimg.isNull()) { QImage record; if (position == 0) { record = recimg; } else { APNGFRAME first = movie[0]; record = recimg.scaled(first.maxframe.width(), first.maxframe.height(), Qt::IgnoreAspectRatio); } buffer->clear(); record.save(buffer->device(),"PNG"); APNGFRAME one; one.dimg = buffer->stream(); one.maxframe = record.rect(); one.pos = position; one.point = QPoint(0,0); one.item = record; one.play = fplay; one.bg = QColor(Qt::black); buffer->clear(); ValidApng = true; disconnect(this); movie.insert(position,one); ////////qDebug() << "### append " << position; } }
void QGVNode::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { painter->save(); painter->setPen(_pen); if(isSelected()) { QBrush tbrush(_brush); tbrush.setColor(tbrush.color().darker(120)); painter->setBrush(tbrush); } else painter->setBrush(_brush); painter->drawPath(_path); painter->setPen(QGVCore::toColor(getAttribute("labelfontcolor"))); const QRectF rect = boundingRect().adjusted(2,2,-2,-2); //Margin if(_icon.isNull()) { painter->drawText(rect, Qt::AlignCenter , QGVNode::label()); } else { painter->drawText(rect.adjusted(0,0,0, -rect.height()*2/3), Qt::AlignCenter , QGVNode::label()); const QRectF img_rect = rect.adjusted(0, rect.height()/3,0, 0); QImage img = _icon.scaled(img_rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation); painter->drawImage(img_rect.topLeft() + QPointF((img_rect.width() - img.rect().width())/2, 0), img); } painter->restore(); }
QImage MainWindow::createImageWithOverlay(const QImage& baseImage, const QImage& overlayImage, QPoint orig, qreal opacity, qreal rotate) { QImage imageWithOverlay = QImage(baseImage.size(), QImage::Format_RGB32); // was Format_ARGB32_Premultiplied QPainter painter(&imageWithOverlay); qint32 halfX = overlayImage.size().width() / 2; qint32 halfY = overlayImage.size().height() / 2; painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(imageWithOverlay.rect(), Qt::transparent); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.drawImage(0, 0, baseImage); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.setOpacity(opacity); if (abs(rotate) > 0.1) { painter.translate(halfX, halfY); painter.rotate(rotate); painter.drawImage(orig.x() - halfX, orig.y() - halfY, overlayImage); } else painter.drawImage(orig.x(), orig.y(), overlayImage); painter.end(); return imageWithOverlay; }
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); }
/** * Provides printing support of the plot image. * */ void ScatterPlotWindow::printPlot() { QPixmap pixmap; /* Initialize a printer*/ static QPrinter *printer = NULL; if (printer == NULL) printer = new QPrinter; printer->setPageSize(QPrinter::Letter); printer->setColorMode(QPrinter::Color); QPrintDialog printDialog(printer,(QWidget *)parent()); if (printDialog.exec() == QDialog::Accepted) { /* Get display widget as a pixmap and convert to an image*/ pixmap = QPixmap::grabWidget(p_plot); QImage img = pixmap.toImage(); /* C++ Gui Programming with Qt, page 201*/ QPainter painter(printer); QRect rect = painter.viewport(); QSize size = img.size(); size.scale(rect.size(),Qt::KeepAspectRatio); painter.setViewport(rect.x(),rect.y(), size.width(),size.height()); painter.setWindow(img.rect()); painter.drawImage(0,0,img); } }
QImage HistogramFilter::makeHistogram(const QImage& image, bool alwaysMakeImage) { if(image.isNull()) return image; QSize smallSize = image.size(); smallSize.scale(200,150,Qt::KeepAspectRatio); //smallSize.scale(4,1,Qt::KeepAspectRatio); //smallSize.scale(160,120,Qt::KeepAspectRatio); QImage origScaled = image;//.scaled(640,480).scaled(smallSize); if(origScaled.format() != QImage::Format_RGB32) origScaled = origScaled.convertToFormat(QImage::Format_RGB32); if(m_frameAccumEnabled) { m_frameAccum.enqueue(origScaled); if(m_frameAccum.size() >= m_frameAccumNum) m_frameAccum.dequeue(); QPainter p(&origScaled); p.fillRect(origScaled.rect(), Qt::black); double opac = 1. / (double)m_frameAccum.size(); //qDebug() << "HistogramFilter::makeHistogram: [FRAME ACCUM] Queue Size: "<<m_frameAccum.size()<<", opac:"<<opac; int counter = 0; foreach(QImage img, m_frameAccum) { p.setOpacity(counter == 0 ? 1 : opac); p.drawImage(0,0,img); counter ++; } }
ARender::ARender(ARenderPrivate *data, QObject *parent) : QObject(parent), d_ptr(data) { Q_D(ARender); d->time = 0; connect(lApp, &Local::aboutToQuit, this, &ARender::deleteLater); if (Config::getValue("/Interface/Version", true)){ d->tv.setFileName(":/Picture/tv.gif"); d->tv.setCacheMode(QMovie::CacheAll); d->tv.start(); d->me = QImage(":/Picture/version.png"); connect(APlayer::instance(), &APlayer::begin, &d->tv, &QMovie::stop); connect(APlayer::instance(), &APlayer::reach, &d->tv, &QMovie::start); connect(&d->tv, &QMovie::updated, [=](){ QImage cf = d->tv.currentImage(); QPoint ps = QRect(QPoint(0, 0), getActualSize()).center() - cf.rect().center(); ps.ry() -= 40; draw(QRect(ps, cf.size())); }); } QString path = Config::getValue("/Interface/Background", QString()); if (!path.isEmpty()){ d->background = QImage(path); } d->sound = QImage(":/Picture/sound.png"); d->music = 1; d->dirty = 0; d->videoAspectRatio = 0; d->pixelAspectRatio = 1; connect(APlayer::instance(), &APlayer::stateChanged, [d](){d->last = QTime(); }); }
void Cover::setCoverPixmap(const QPixmap &pixmap) { Q_D(Cover); int radius = d->m_radius; QSize sz = size(); QPainter::CompositionMode mode = QPainter::CompositionMode_SourceIn; QPixmap destinationImage(sz); destinationImage.fill(Qt::transparent); QPainterPath path; path.addRoundRect(QRectF(0, 0, sz.width(), sz.height()), radius); QPainter bkPainter(&destinationImage); bkPainter.setRenderHint(QPainter::Antialiasing); bkPainter.setPen(QPen(Qt::white, 1)); bkPainter.fillPath(path, QBrush(Qt::red)); QPixmap backgroundImage = pixmap.scaled(sz, Qt::KeepAspectRatioByExpanding); QImage resultImage = QImage(sz, QImage::Format_ARGB32_Premultiplied); QPainter painter(&resultImage); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(resultImage.rect(), Qt::transparent); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.drawImage(0, 0, destinationImage.toImage()); painter.setCompositionMode(mode); painter.drawImage(0, 0, backgroundImage.toImage()); painter.setCompositionMode(QPainter::CompositionMode_DestinationOver); painter.end(); d->m_Background = QPixmap::fromImage(resultImage); }
void CGMainWindow::applyFilter(BaseFilter* filter) { QMdiSubWindow *active = ui->mdiArea->activeSubWindow(); if (active != NULL) { MdiElement* activeElement = dynamic_cast<MdiElement*> (active->widget()); QImage image = activeElement->pixmap().toImage(); QImage result; if (!activeElement->isRubberBandVisible()) { result = filter->process(image); } else { QRectF selection = activeElement->getSelectionRect(); QRect boundingRect = QRect(selection.left(), selection.top(), selection.width(), selection.height()); boundingRect = boundingRect.intersect(image.rect()); QImage toProcess = image.copy(boundingRect); QImage areaResult = filter->process(toProcess); result = image; for (int i = boundingRect.left(); i < boundingRect.right(); ++i) { for (int j = boundingRect.top(); j < boundingRect.bottom(); ++j) { result.setPixel(i, j, areaResult.pixel(i - boundingRect.left(), j - boundingRect.top())); } } activeElement->hideRubberBand(); } QPixmap pixmap = QPixmap::fromImage(result); activeElement->setPixmap(pixmap); } }
QImage edge_detector::detectEdgeImage(const QImage image, int kernel) { QImage destImage = QImage( image); QRect rect = image.rect(); QColor qc; int H = rect.height(); int W = rect.width(); int **a; qreal gradient, gangle; int r, g, b; int maxg(0); for (int y=0; y<H; y++) // y=1; y<H-1; { for (int x=0; x<W; x++) // x=1; x<W-1; { a = get_neighbor_pixels(image, x, y, 1, true); edge_detect(a, kernel, &gradient, &gangle); deleteArray(a, 3); //size of array allocated by get_neighbor_pixels is 3x3, 3 = (range=1)*2+1 if ((gangle >= -22.5 && gangle < 22.5) || (gangle >= 157.5 || gangle < -157.5)) { r = 0; g = 0; b = 255; } else if ((gangle >= 22.5 && gangle < 67.5) || (gangle <= -112.5 && gangle > -157.5)) { r = 0; g = 255; b = 0; } else if ((gangle >= 67.5 && gangle < 112.5) || (gangle <= -67.5 && gangle > -112.5)) { r = 255; g = 255; b = 0; } else if ((gangle >= 112.5 && gangle < 157.5) || (gangle <= -22.5 && gangle > -67.5)) { r = 255; g = 0; b = 0; } if (gradient > maxg) maxg = gradient; qc.setRgb((int)gradient & r, (int)gradient & g, (int)gradient & b); destImage.setPixel( x, y, qc.rgba()); } } //printf("gangle = %f, maxg = %d\n", gangle, maxg); return destImage; }
void DocumentLoadedImpl::applyTransformation(Orientation orientation) { QImage image = document()->image(); QMatrix matrix = ImageUtils::transformMatrix(orientation); image = image.transformed(matrix); setDocumentImage(image); imageRectUpdated(image.rect()); }
QImage XCursorThemeData::autoCropImage (const QImage &image) const { // Compute an autocrop rectangle for the image QRect r(image.rect().bottomRight(), image.rect().topLeft()); const quint32 *pixels = reinterpret_cast<const quint32*>(image.bits()); for (int y = 0; y < image.height(); y++) { for (int x = 0; x < image.width(); x++) { if (*(pixels++)) { if (x < r.left()) r.setLeft(x); if (x > r.right()) r.setRight(x); if (y < r.top()) r.setTop(y); if (y > r.bottom()) r.setBottom(y); } } } // Normalize the rectangle return image.copy(r.normalized()); }
// Draws the base image then paints the overlay over it. void OverlayDisplayModule::run_() { imageIn.latch(); QImage base = ImageDisplayModule::makeImageOfChannel(channel); QPainter painter(&base); painter.drawImage(base.rect(), overlay); setPixmap(QPixmap::fromImage(base)); }
QImage BlurPhotoEffect::apply(const QImage & image) { QImage result = image; QPainter p(&result); p.setCompositionMode(QPainter::CompositionMode_SourceOver); p.drawImage(0,0,PhotoEffectsLoader::apply(blurred(image, image.rect(), m_radius))); return result; }
QImage PdfDocument::renderPage(int index) { if (not documentLoaded()) return QImage(); QImage image = document->page(index)->renderToImage(); last_image_rect = image.rect(); return image; }