Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] DrawEllipse and save image problem
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] DrawEllipse and save image problem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TFabbri
    wrote on last edited by
    #1

    Hi to all,
    I'm trying to draw an ellipse and save it in a PNG file.
    The image is really simple, but I've a problem because the image saved is not clear (it has something like noise...).

    @ QImage *placemark = new QImage(QSize(16,16),QImage::Format_ARGB32);
    QPainter p;
    p.begin(placemark);
    p.setPen(c);
    p.setBrush(QBrush(c));
    p.drawEllipse(QRectF(4,4,8,8));
    p.end();

    placemark->save(QString("./images/%1.png").arg(name), "PNG")<< endl;
    @

    The variable c is a QColor.
    The result is this "image":http://dl.dropbox.com/u/3894235/BOAT.png

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Have you tried to clear the image first?

      It will contain random bits after construction. Cleaning them up takes time and an idea which color the user will want as a background.

      If you are going to draw each pixel anyway, then that clean-up time as also wasted.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TFabbri
        wrote on last edited by
        #3

        Thank you so much Tobias!
        I've solved by cleaning the image.
        I've used this code:

        @ painter.setCompositionMode(QPainter::CompositionMode_Source)
        painter.fillRect(0,0,image->width(),image->height(), Qt::transparent);
        @
        Now it is ok!!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved