Exemplo n.º 1
0
// TODO: this function scales the monitors up when they are bigger than the image :D might have to fix that sometime...
// TODO: ctrl+z erases one state too much
void CroppingWidget::scaleToWindowSize() {
    double prevScale = imageScale();
    mCurrentImage = mOriginalImage.scaled(size(), Qt::KeepAspectRatio);

    mScreen.scaleBy(imageScale() / prevScale, mCurrentImage);
    updateStatusBar();
}
Exemplo n.º 2
0
bool CroppingWidget::fullQualityCropPossible() const {
    double maxScreenScaleFactor = mScreen.getMinScaleFactor();
    // because of this: scale = (imageScale / mXScale) in Monitor::crop()
    if(maxScreenScaleFactor < imageScale())
        return false;
    // because the user cannot make the monitors bigger than the start, the monitors must either fit or be scaled down, so
    // above condition hits
    return true;
}
Exemplo n.º 3
0
void CroppingWidget::updateStatusBar() const {
    QString text = QString("Scales: Image: %1, Monitors: %2; Sizes: Image: %3, Screen: %4 -> %5")
                   .arg(imageScale())
                   .arg(mScreen.getMinScaleFactor())
                   .arg(QString("%1x%2").arg(mOriginalImage.width()).arg(mOriginalImage.height()))
                   .arg(mScreen.getSizeAsString())
                   .arg(fullQualityCropPossible() ? "ok" : "too small");
    mStatusBarView->setText(text);
}
QSizeF KisCoordinatesConverter::imageSizeInFlakePixels() const
{
    if(!m_d->image) return QSizeF();

    qreal scaleX, scaleY;
    imageScale(&scaleX, &scaleY);
    QSize imageSize = m_d->image->size();

    return QSizeF(imageSize.width() * scaleX, imageSize.height() * scaleY);
}
Exemplo n.º 5
0
FloatSize DragImage::clampedImageScale(const IntSize& imageSize, const IntSize& size,
    const IntSize& maxSize)
{
    // Non-uniform scaling for size mapping.
    FloatSize imageScale(
        static_cast<float>(size.width()) / imageSize.width(),
        static_cast<float>(size.height()) / imageSize.height());

    // Uniform scaling for clamping.
    const float clampScaleX = size.width() > maxSize.width()
        ? static_cast<float>(maxSize.width()) / size.width() : 1;
    const float clampScaleY = size.height() > maxSize.height()
        ? static_cast<float>(maxSize.height()) / size.height() : 1;
    imageScale.scale(std::min(clampScaleX, clampScaleY));

    return imageScale;
}
Exemplo n.º 6
0
void ColorChooser::loadForegroundPixmap(QRgb rgbBg)
{
  // build foreground/background pixmap. for the foreground color we use black or white,
  // whichever is furthest in rgb space from the background color
  int width = ChooserWidth + 2 * ChooserPadding;
  QImage imageScale(width, m_scaleHeight, 32);

  int rBg, gBg, bBg;
  QColor colorBg(rgbBg);
  colorBg.rgb(&rBg, &gBg, &bBg);
  
  QRgb rgbFg;
  int distanceBlack = (rBg - 0) * (rBg - 0) + (gBg - 0) * (gBg - 0) + (bBg - 0) * (bBg - 0);
  int distanceWhite = (rBg - 255) * (rBg - 255) + (gBg - 255) * (gBg - 255) + (bBg - 255) * (bBg - 255);
  if (distanceWhite > distanceBlack)
    rgbFg = QColor(Qt::white).rgb();
  else
    rgbFg = QColor(Qt::black).rgb();

  for (int x = 0; x < width; x++)
    for (int y = 0; y < m_scaleHeight; y++)
    {
      // show an triangle with bottom side on the left, and point on the right
      if (x < (y * width) / (m_scaleHeight - 2 * ChooserFrame))
        setPixelRGB(&imageScale, x, y, rgbBg);
      else
        setPixelRGB(&imageScale, x, y, rgbFg);
    }

  pixmapForeground.convertFromImage(imageScale, Qt::ThresholdDither);

  if (m_discretizeMethod == DiscretizeForeground)
  {
    scaleCanvas->setBackgroundPixmap(pixmapForeground);
    scaleCanvas->update();
  }
}
Exemplo n.º 7
0
void CroppingWidget::saveCrops(const QFile &path) const {
    mScreen.saveCrops(path, mOriginalImage, imageScale());
}