Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Paint. editor

    General and Desktop
    3
    3
    1547
    Loading More Posts
    • 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.
    • B
      beowulf last edited by

      I want to make a pixel editor, but i don't know how start, any tips?

      Thanks in advance.

      -- 0x00

      1 Reply Last reply Reply Quote 0
      • U
        utcenter last edited by

        Focus around QPainter and QPixmap. A brush can be represented by a monochrome 8 bit pixmap you can colorize in the desired color, then using QPainter you can imprint the brush pixmap onto another pixmap that represents your canvas.

        Keep in mind that QBrush won't provide the needed behavior.

        If this is your brush stencil:
        !http://i41.tinypic.com/34dr5nt.png(stenci)!

        using QBrush to fill a stroke will produce this:
        !http://i41.tinypic.com/21mde8j.png(qbrush)!

        it will fill the stroke in a patterned style instead of what an actual stroke with the stencil should look like:
        !http://i39.tinypic.com/2642m2e.png(brush)!

        Typically, you'd want to store 2 coordinates while drawing, the previous and current position of the cursor. Then you create a QLine between the two QPoints and draw the brush pixmap along that line based on how much your brush spacing is. This is the approach needed to solve the issue, presented by Qt's slow input event polling, which would create arbitrary single points along the path of drawing instead of a consistent line.

        Of course if you want only single pixel the task will be much easier. Bud going for the "brush" approach will allow you to draw with any kind of brush, not only pixel. You can also create brushes that automatically rotate to follow the direction of drawing, brush dynamics in regard to size, opacity, color, noise and so on.

        On how to colorize your brush, I already show a well commented step by step example "here":http://qt-project.org/forums/viewthread/18048

        There is also a sketch example shipping with Qt, but it is very limited in providing the ability to use different brush stencils.

        1 Reply Last reply Reply Quote 0
        • Z
          zester last edited by

          Thank you!!! Thank you!!! Thank you!!!! utcenter ;) This and your other posts were exactly the information I have been looking for, Please post more on the subject of this topic when you can. It would be much appreciated.

          Thank you soooo much!!!!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post