# How to make clone stamp tool as the photoshop?

**URL:** <https://discourse.processing.org/t/how-to-make-clone-stamp-tool-as-the-photoshop/25547>\
**Category:** Coding Questions\
**Created:** [November 19, 2020, 11:55pm UTC](https://discourse.processing.org/t/how-to-make-clone-stamp-tool-as-the-photoshop/25547 "2020-11-19T23:55:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![datacolor](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@datacolor](https://discourse.processing.org/u/datacolor)\
**Post date:** [November 19, 2020, 11:55pm UTC](https://discourse.processing.org/t/how-to-make-clone-stamp-tool-as-the-photoshop/25547/1 "2020-11-19T23:55:49Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

The idea is with mouse pointer(as photoshop) clone pixel or pixels from the PImage1 to PImage2,please!!

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [November 20, 2020, 6:01am UTC](https://discourse.processing.org/t/how-to-make-clone-stamp-tool-as-the-photoshop/25547/2 "2020-11-20T06:01:23Z")

</div>

From left to right. If you want a round stamp you need to use a mask.

```auto
PImage pi_1, pi_2, pi_3;
int stamp_width = 30;
int stamp_height = 30;
int transparency = 15;

void setup() {
  String url = "https://i.pinimg.com/236x/d9/63/aa/d963aa82a6b11b236543d0a3a0842e50.jpg";
  pi_1 = loadImage(url, "png");
  pi_2 = pi_1;
  size(800, 400);
  background(255);
  pi_1.resize(400, 400);
  pi_1.resize(400, 400);
  image(pi_1, 0, 0);
  image(pi_2, 400, 0);
  
}

void draw() {
  if(mouseX > 440 && mousePressed) {
    image(pi_3, mouseX-stamp_width/2, mouseY-stamp_height/2);
    tint(255, transparency);
  }
}

void mousePressed () {
  if(mouseX < 360) pi_3 = get(mouseX-stamp_width/2, mouseY-stamp_height/2, stamp_width, stamp_height);
}

```
