sanpera icon indicating copy to clipboard operation
sanpera copied to clipboard

Direct pixel access

Open eevee opened this issue 12 years ago • 0 comments

Currently no way to inspect or change a single pixel. Better fix that.

Keep in mind that IM's API is intended for batch work: it's built around requesting a rectangular region, not single pixels. (Question: how are conflicts resolved when two cache views of the same region try to write to the same pixel? Last one to sync wins?)

  • Need an __iter__ that runs through every pixel of the frame and yields pixels. (Are these pixel objects with coordinates, or just mutable colors?)
  • Also need a way to ask for a single pixel. Given the above, maybe there should be a way to ask for a proxy to a cache view, and that can have individual pixels modified?

I'm thinking out loud here, but I could also combine the above to create:

pixels = frame.pixels()
for pos, color in pixels:
    print pos
    color.red *= 2
# or...
for pixel in pixels:
    print pixel.position
    pixel.color = red

print pixels[0, 0]

region = frame.pixels((0, 0, 10, 10))

Or something. If you're only getting a single pixel then this is a bit of work, but it seems safe to assume you would rarely want that?

eevee avatar Oct 09 '12 01:10 eevee