# Is there an easier way to get the updated Pixels

**URL:** <https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485>\
**Category:** Coding Questions\
**Created:** [June 1, 2020, 5:42pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485 "2020-06-01T17:42:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moritz](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Moritz](https://discourse.processing.org/u/Moritz)\
**Post date:** [June 1, 2020, 5:42pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/1 "2020-06-01T17:42:22Z")

</div>

I want to get the pixels that were updated in code between a and b without comparing loadPixels () at a with loadPixels() at b. Is that possible? (-\> and how is that possible?)

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [June 1, 2020, 6:22pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/2 "2020-06-01T18:22:23Z")

</div>

I can think of three options.

- create a PGraphics object, copy original pixels to PGraphics and do changes there. Then compare it to original pixels.
- create empty (black) PGraphics and do same changes as you do to pixels. You’ll at least know what pixels changed and to what
- save pixels to files and then compare them

---

<div class="post-metadata">

**Author:** ![Moritz](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Moritz](https://discourse.processing.org/u/Moritz)\
**Post date:** [June 1, 2020, 7:00pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/3 "2020-06-01T19:00:59Z")

</div>

thank you but the problem is:  
If I draw something with the same color as the background (black if ampty PGraphics) the changes will not be detected. I need this to save complex structures of rectangles/ellipses/… (so I don’t have to recalculate them). Is there an other way to save structures without losses?

---

<div class="post-metadata">

**Author:** ![Moritz](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Moritz](https://discourse.processing.org/u/Moritz)\
**Post date:** [June 1, 2020, 7:18pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/4 "2020-06-01T19:18:37Z")

</div>

If there is no other way, I will use a map\<Integer, Integer\> (index, value) to save the changes and I will recognize the changes with 2 different backgrounds, but this is not a good code …

---

<div class="post-metadata">

**Author:** ![SomeOne](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/someone/32/8639_2.png) [@SomeOne](https://discourse.processing.org/u/SomeOne)\
**Post date:** [June 2, 2020, 4:39am UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/5 "2020-06-02T04:39:32Z")

</div>

I agree it doesn’t sound to be a good solution. Because I have only a vague understanding what you are doing, I can only give very generic advice. So could you elaborate a bit what you are doing?

My experience is that if things get tricky and complicated then you are doing it wrong way.

---

<div class="post-metadata">

**Author:** ![Moritz](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Moritz](https://discourse.processing.org/u/Moritz)\
**Post date:** [June 2, 2020, 7:06am UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/6 "2020-06-02T07:06:42Z")

</div>

[https://www.processing.org/tutorials/pshape/](https://www.processing.org/tutorials/pshape/)

-groups-  
Thats what i wanted…

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [June 3, 2020, 3:15pm UTC](https://discourse.processing.org/t/is-there-an-easier-way-to-get-the-updated-pixels/21485/7 "2020-06-03T15:15:46Z")

</div>

Glad that you found a solution with PShape groups that worked for you.

> [@Moritz](#):
>
> If I draw something with the same color as the background (black if ampty PGraphics) the changes will not be detected.

For this – PGraphics can be created ARGB with an alpha (transparent) background. Anything drawn would be detectable as a change, including black.
