示例#1
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;
  }
示例#2
0
  public void next() {
    // blur
    for (int y = 1; y < m_height; ++y) {
      int oset = y * m_width;
      //      System.out.println("y:::");
      for (int x = 1; x < m_width - 1; ++x) {
        //      int dl = m_data[oset + m_width + x - 1];
        //      int dr = m_data[oset + m_width + x + 1];
        //      int d = m_data[oset + m_width + x];
        //          m_data[oset + x] = (int) ((dl + (d * 2) + dr) / (4 + 10.0 / m_width));
        //      m_data[oset + x] = (int) ((dl + du + dr + dd) / 4);
        m_data[oset + x] =
            (((m_data[oset + x + m_width] << 2)
                        + (m_data[oset + x] << 1)
                        + (m_data[oset + x + 1])
                        + (m_data[oset + x - 1]))
                    - 7)
                >> 3;
        if (m_data[oset + x] < 0) m_data[oset + x] = 0;
        //      System.out.print(" " + m_data[oset + x]);
      }
      //      System.out.println();
    }

    // seed the last row for the next step...
    seedLastRow();

    QNativePointer np = m_image.bits();
    np.setVerificationEnabled(false);
    int ppl = m_image.bytesPerLine() / 4;
    for (int y = 0; y < m_height; ++y) {
      int oset = ppl * y;
      for (int x = 0; x < m_width; ++x) {
        int val = m_data[oset + x];
        val = val * val / (255);
        int val_2 = 0;
        np.setIntAt(oset + x, (val << 24) | (val_2 << 16) | (val_2 << 8) | (val_2));
      }
    }
  }