# Processing in Java: canvas size + image cleanup

**URL:** https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272
**Category:** Processing
**Created:** [August 8, 2022, 1:43am UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272 "2022-08-08T01:43:08Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 8, 2022, 1:43am UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/1 "2022-08-08T01:43:08Z")

</div>

How can I make my processing canvas in a Java project run/look exactly like it does when I use the processing IDE for this project?

I’m using P4 beta (I also get this issue with P3) as graphics library for a java project I’m working on. The issue is that when I’m using the processing IDE the canvas size, say 800x800 looks great and it appears as though there’s some clean up and image processing going on. However, when I’m not using this IDE and running in java it looks like garbage and the image is huge.

---

<div class="post-metadata">

### Author: ![JSGauthier](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jsgauthier/32/9910_2.png) [@JSGauthier](https://discourse.processing.org/u/JSGauthier)
#### Post date: [August 9, 2022, 3:39am UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/2 "2022-08-09T03:39:14Z")

</div>

Hello,

Are you running P3 or P4 on a high resolution display, like 4K?

You may want to do some tests with the displayDensity() as it may be upscaling graphics and then looking poorly.

> **[Reference](https://processing.org/reference/displayDensity_.html)**
>
> This function returns the number "2" if the screen is a high-density screen (called a Retina display on OS X or high-dpi on Windows and Linux) and a "1" if not. This information is useful for a progra…

Best wishes

PS: Remember not to bite your nails…  
🙂

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 9, 2022, 10:24pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/3 "2022-08-09T22:24:46Z")

</div>

I think it’s a 1080p laptop. But I’m absolutely going to try displayDensity(), thank you for the refrence!

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 9, 2022, 10:47pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/4 "2022-08-09T22:47:11Z")

</div>

pixelDensity(2) is not applicable to my display unfortunately. I’m thinking there’s some setting the Processing IDE applies where it downscales everything to make it look nicer (like supersampling or downsampling the buffer is what I believe is happening).

For example, without the P4/P3 IDE and using java, 800x800 is huge, but 800x800 in the P4/P3 IDE is a great size, looks like it’s actually 600x600 on my display, and everything is smooth but not blurry. Here are some pictures to demonstrate the issue:

This was generated in the Processing IDE

 ![AA10xcspss](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/d/fd5befcfd6149731f84815347758301a6f6708ef.jpeg)

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 9, 2022, 10:47pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/5 "2022-08-09T22:47:41Z")

</div>

This was generated with java using P4 as a GL

 ![iyla](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/9/29ff194a5415cde004eaed53f36f65d1abc964ba.jpeg)

---

<div class="post-metadata">

### Author: ![JSGauthier](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jsgauthier/32/9910_2.png) [@JSGauthier](https://discourse.processing.org/u/JSGauthier)
#### Post date: [August 11, 2022, 9:23pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/6 "2022-08-11T21:23:13Z")

</div>

Please share your code as this will allow the community to debug with you further.

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 24, 2022, 6:23pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/7 "2022-08-24T18:23:56Z")

</div>

Not necessary, just figured it out.

For some reason, the default processing renderer (a.k.a size(x,y); type calls) gives dense pixels.  
when you pass the P3D renderer to size, it gives the same results as if I were programming in the P4 IDE.

Thanks for your engagement!

If anyone finds this thread with the same issue, make sure you make a “natives” folder in your project folder, then copy the “os-processor64/32” into natives. So for me, right in my project folder I have this: natives\windows-amd64  
where windows-amd64 is copied directly from processing 4’s core\library

then I got a an openGL context and used GL2 for my project instead, bascially boosted it off of processing so I don’t have to deal with the backend management and just go put pixels on the screen (the only drawing is done with GL.POINTS in one method)

tldr: P3D good (with GL2), default renderer bad

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [August 24, 2022, 6:24pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/8 "2022-08-24T18:24:52Z")

</div>

If you’re curious to see the project though I’ll post a link when it’s done/released

---

<div class="post-metadata">

### Author: ![xXx\_jesushchrist\_xXx](https://avatars.discourse-cdn.com/v4/letter/x/9de053/32.png) [@xXx\_jesushchrist\_xXx](https://discourse.processing.org/u/xXx_jesushchrist_xXx)
#### Post date: [June 26, 2023, 10:36pm UTC](https://discourse.processing.org/t/processing-in-java-canvas-size-image-cleanup/38272/9 "2023-06-26T22:36:37Z")

</div>

Been a while, here is a link to a github repo with zip/JAR

> **[GitHub - gabor6502/Fractal-Viewer: Contains a zip file for a Windows...](https://github.com/gabor6502/Fractal-Viewer)**
>
> Contains a zip file for a Windows implementation of a fractal viewing program I created. - GitHub - gabor6502/Fractal-Viewer: Contains a zip file for a Windows implementation of a fractal viewing ...
