omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Saving painted image as matrix

    Pythonista
    image
    3
    5
    3292
    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.
    • HT
      HT last edited by ccc

      Hi everyone,

      I want to make a little program which allows the user to paint in an area on the screen. After hitting a button I want to translate this image into a binary matrix with 1 for each white and 0 for each black pixel. I'm new to iOS programming and am not sure how to go about it.
      Right now I'm drawing in a scene with nodes like this:

      marker = ui.Path().oval(0, 0, 4, 4)
      marker.fill()
      marker.close()
      
      self.pending_mark_a = ShapeNode(marker, position = self.a, color = "#000000", size = (self.dotSize,self.dotSize))
      self.pending_mark_a.z_position = 1
      self.add_child(self.pending_mark_a)
      

      Can anyone help?

      Cheers

      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @HT last edited by

        @HT, not 100% clear what you are after. A black-and-white Paint app or something more specialized?

        In any case, have you noticed the Sketch.py included in the Examples, under User Interface? By default you draw with black on white, and there’s a Save Image option, so sounds like it could be a good reference.

        1 Reply Last reply Reply Quote 1
        • HT
          HT last edited by

          Thanks, that is perfect! For some reason I didn't have this example.

          Could you explain how I could add this sketchpad to a view that's only the bottom half of the screen?
          I would like to display another image in the top half and have the bottom half be paintable.

          1 Reply Last reply Reply Quote 0
          • enceladus
            enceladus last edited by

            You can use designer. See
            https://gist.github.com/8f81907e4844d579ef8eda2ed5d65d5e

            1 Reply Last reply Reply Quote 1
            • HT
              HT last edited by

              That looks perfect. Thanks a lot!

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors