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. Paint. editor
Forum Updated to NodeBB v4.3 + New Features

Paint. editor

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.7k 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.
  • B Offline
    B Offline
    beowulf
    wrote on last edited by
    #1

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

    Thanks in advance.

    -- 0x00

    1 Reply Last reply
    0
    • U Offline
      U Offline
      utcenter
      wrote on last edited by
      #2

      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
      0
      • Z Offline
        Z Offline
        zester
        wrote on last edited by
        #3

        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
        0

        • Login

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