QPointF AdvancedImageWidget::imageToWidgetF(const QPointF &p) { #if 0 if (mOutputRect.height() == 0 || mOutputRect.width() == 0 || mInputRect .height() == 0 || mInputRect .width() == 0) { return p; } double x1 = (double)(p.x() - mInputRect.x()) / (mInputRect. width()); double y1 = (double)(p.y() - mInputRect.y()) / (mInputRect.height()); double x2 = x1; double y2 = y1; switch (mUi->rotationComboBox->currentIndex()) { case 1: x2 = 1.0 - y1; y2 = x1; break; /* 90 */ case 2: x2 = 1.0 - x1; y2 = 1.0 - y1; break; /* 180 */ case 3: x2 = y1; y2 = 1.0 - x1; break; /* 270 */ default: break; } double resultX = x2 * (mOutputRect.width() ) + mOutputRect.x(); double resultY = y2 * (mOutputRect.height()) + mOutputRect.y(); return QPointF(resultX, resultY); #else Matrix33 m = currentTransformMatrix(); Vector2dd out = m * Qt2Core::Vector2ddFromQPointF(p); return Core2Qt::QPointFromVector2dd(out); #endif }
SkPoint View::convertToLocal(SkPoint point, View* reference) { SkMatrix m; if (currentTransformMatrix(reference).invert(&m)) { m.mapPoints(&point, 1); } return point; }
void AdvancedImageWidget::drawResized(QPainter &painter) { //qDebug("AdvancedImageWidget::drawResized():called"); if (mImage.isNull()) { qDebug("AdvancedImageWidget::drawResized():image is null"); painter.drawText(0,0, this->width(), this->height(), Qt::AlignHCenter | Qt::AlignVCenter, QString("NO ACTIVE IMAGE")); return; } if (mUi->rotationComboBox->currentIndex() == 0) { painter.drawImage(mOutputRect, *mImage, mInputRect); return; } // qDebug() << "Input" << mInputRect; // qDebug() << "Output" << mOutputRect; Matrix33 matrix = currentTransformMatrix(); // cout << "Transfrom Matrix:\n" << matrix << std::endl << std::flush; QTransform transform = Core2Qt::QTransformFromMatrix(matrix); // qDebug() << "QTransfrom" << transform; QTransform old = painter.transform(); painter.setTransform(transform, false); painter.drawImage(mOutputRect.topLeft(), *mImage, mImage->rect()); #if 0 painter.setPen(Qt::red); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { painter.drawPoint(i * 64, j * 48); } } #endif painter.setTransform(old); }