예제 #1
0
 @Override
 protected void resizeEvent(QResizeEvent event) {
   if (width() > image.width() || height() > image.height()) {
     int newWidth = Math.max(width() + 128, image.width());
     int newHeight = Math.max(height() + 128, image.height());
     image = resizeImage(image, new QSize(newWidth, newHeight));
     update();
   }
   super.resizeEvent(event);
 }
예제 #2
0
  private static QImage warpImage(QImage src, int warp, int sign) {
    int w = src.width();
    int ppl = src.bytesPerLine() / 4;
    int srch = src.height();
    int desth = srch + warp;

    QImage dest = new QImage(w, desth, QImage.Format.Format_ARGB32_Premultiplied);
    dest.fill(0);

    QNativePointer sbits = src.bits();
    QNativePointer dbits = dest.bits();

    sbits.setVerificationEnabled(false);
    dbits.setVerificationEnabled(false);

    double r = w / 2.0;

    int extra_offset = sign >= 0 ? 0 : warp;

    for (int x = 0; x < w; ++x) {
      int oset = (int) (((Math.sqrt(Math.abs(r * r - (x - r) * (x - r)))) * sign / r) * warp);
      for (int y = 0; y < srch; ++y) {
        int p = sbits.intAt(y * ppl + x);
        dbits.setIntAt(((y + oset + extra_offset) * ppl) + x, p);
      }
    }
    return dest;
  }
예제 #3
0
  private static QImage makeShade(QImage image, boolean highlight, boolean darker) {
    double shade_alpha = 0.8;
    double shade_size = 0.2;
    double hl_pos = GOLDEN_MEAN;

    QColor shade_color = QColor.fromRgbF(0, 0, 0, shade_alpha);
    QColor transparent = darker ? QColor.fromRgbF(0, 0, 0, 0.25) : QColor.fromRgbF(0, 0, 0, 0);
    QColor hl_color = QColor.fromRgbF(1, 1, 1, 0.7);

    image = image.copy();
    QPainter p = new QPainter();
    p.begin(image);
    p.scale(image.width(), image.height());

    QLinearGradient lg = new QLinearGradient(0, 0, 1, 0);
    lg.setColorAt(0, shade_color);
    lg.setColorAt(shade_size, transparent);
    if (highlight) lg.setColorAt(hl_pos, hl_color);
    lg.setColorAt(1 - shade_size, transparent);
    lg.setColorAt(1, shade_color);
    p.fillRect(0, 0, 1, 1, new QBrush(lg));

    if (highlight) {
      QRadialGradient rg = new QRadialGradient(hl_pos, 1 - hl_pos, 0.4, hl_pos, 1 - hl_pos);
      rg.setColorAt(0, hl_color);
      rg.setColorAt(1, transparent);
      p.fillRect(0, 0, 1, 1, new QBrush(rg));
    }

    p.end();

    return image;
  }
예제 #4
0
  @Override
  protected void paintEvent(QPaintEvent e) {
    m_smoke_effect.next();

    QPainter p = new QPainter();
    p.begin(this);
    p.fillRect(rect(), new QBrush(QColor.white));
    //  p.fillRect(rect(), new QBrush(Qt.CrossPattern));

    p.drawImage(50, 80, m_logo);

    p.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform);
    QImage im = m_smoke_effect.image();
    p.drawImage(
        new QRect(50, -20, im.width(), im.height()),
        im,
        new QRect(0, (int) (im.height() * 0.60), im.width(), (int) (im.height() * 0.39)));

    p.end();
  }