# Render PImage using P2D?

**URL:** <https://discourse.processing.org/t/render-pimage-using-p2d/41429>\
**Category:** Beginners\
**Created:** [March 24, 2023, 2:41pm UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429 "2023-03-24T14:41:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aryszin](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Post date:** [March 24, 2023, 2:41pm UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429/1 "2023-03-24T14:41:32Z")

</div>

Is it possible to render a PImage as with P2D like it is possible to render PGraphics with P2D too.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [March 24, 2023, 4:18pm UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429/2 "2023-03-24T16:18:19Z")

</div>

Hi @Aryszin,

By “render”, you mean saving an image to disk? or displaying with the `P2D` renderer?

I mean it’s as usual (same behavior with a `PImage`):

```processing
void setup() {
  size(500, 500, P2D);
  
  PGraphics pg = createGraphics(200, 200, P2D);
  pg.beginDraw();
  pg.background(255, 0, 0);
  pg.endDraw();
  
  image(pg, 0, 0);
}

```

---

<div class="post-metadata">

**Author:** ![Aryszin](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@Aryszin](https://discourse.processing.org/u/Aryszin)\
**Post date:** [March 24, 2023, 5:31pm UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429/3 "2023-03-24T17:31:35Z")

</div>

I mean the graphics library p2d can be used to create a PGraphics. Is that possible with pimages?

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [March 25, 2023, 9:54am UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429/4 "2023-03-25T09:54:01Z")

</div>

A `PGraphics` is a subclass of `PImage` and you can use them interchangeably so what’s your use case?

> <https://github.com/processing/processing4/blob/main/core/src/processing/core/PGraphics.java#L154>

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 25, 2023, 12:19pm UTC](https://discourse.processing.org/t/render-pimage-using-p2d/41429/5 "2023-03-25T12:19:05Z")

</div>

> [@Aryszin](#):
>
> can be used to create a PGraphics. Is that possible with pimages?

It’s not necessary.

You can just handle the PGraphics as if it were a PImage.

```auto
  image(pg, 0, 0);

```
