コード例 #1
0
ファイル: Image.java プロジェクト: palaniyappanBala/qtjambi
  private static QImage qtLogoImage(int width, int height, boolean render_logo) {
    QBrush tt_green = new QBrush(color_green);
    QBrush tt_black = new QBrush(new QColor(0, 0, 0));

    QImage image = new QImage(width, height, QImage.Format.Format_RGB32);
    QPainter p = new QPainter();
    p.begin(image);
    p.setRenderHint(QPainter.RenderHint.Antialiasing);

    // Fill the background
    p.scale(width, height);
    p.setPen(new QPen(tt_black, 0.05));
    p.setBrush(tt_green);
    p.drawRect(0, 0, 1, 1);

    if (render_logo) {
      // set up painter for the logo drawing..
      p.setPen(Qt.PenStyle.NoPen);
      p.setBrush(new QBrush(QColor.black));
      p.translate(0.5, 0.5);
      p.rotate(-45);

      double thickness = 0.13;
      double inner_radius = 0.24;
      double outer_radius = inner_radius + thickness;

      double ir2 = inner_radius * 2;
      double or2 = outer_radius * 2;
      double t_2 = thickness / 2;

      // draw the black circle
      QPainterPath circle_path = new QPainterPath();
      circle_path.addEllipse(-inner_radius, -inner_radius, ir2, ir2);
      circle_path.addEllipse(-outer_radius, -outer_radius, or2, or2);
      p.drawPath(circle_path);

      QPainterPath t_path = new QPainterPath();
      t_path.addRect(-t_2, 0, thickness, 0.48);
      t_path.addRect(-0.17, -t_2, 0.34, thickness);
      t_path.setFillRule(Qt.FillRule.WindingFill);
      p.drawPath(t_path);
    }
    p.end();

    return image;
  }