# Pixelated images

**URL:** https://discourse.processing.org/t/pixelated-images/46658
**Category:** Coding Questions
**Created:** [July 3, 2025, 5:39pm UTC](https://discourse.processing.org/t/pixelated-images/46658 "2025-07-03T17:39:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)
#### Post date: [July 3, 2025, 5:39pm UTC](https://discourse.processing.org/t/pixelated-images/46658/1 "2025-07-03T17:39:35Z")

</div>

Hi there!

I have been using processing again after sometime and I don’t understand why images are so pixelated. I am using processing 4.4.4 in Java mode in my pc and all the sketches are really pixelated, it doesn’t matter if a have 2 code lines or 200. How can I get clear images, please?

```auto
size (500,500);
background(255);
triangle(250,100, 100,400, 400,400);
save("image.png");

```

 ![prueba](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/d/4/d49980499072adb04632c3413a44a9ce88669748.jpeg)

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 3, 2025, 7:05pm UTC](https://discourse.processing.org/t/pixelated-images/46658/2 "2025-07-03T19:05:50Z")

</div>

Hello @humano,

Please run this and report back:

```auto
//Try these one at a time:

//size (250, 250); // This is default and the same as size (500, 500, JAVA2D);
size(250, 250, P2D);

background(255);
strokeWeight(3);
triangle(250/2, 100/2, 
         100/2, 400/2, 
         400/2, 400/2);
save("image.png");

import java.awt.*;

// Gets windows scaling and prints it:
float ws = (float) java.awt.GraphicsEnvironment
.getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getDefaultConfiguration().
getDefaultTransform().
getScaleX();

println("Windows scaling:", ws);

// Displays the displayDensity of your monitor:
int pd = displayDensity();
println("Pixel Density:", pd);

```

I have Windows scaling of 1.25x (I set this!) on my PC and my sketch window is scaled up by 1.25x with JAVA2D which is the default:

`size (500, 500);`

Scaling up by 1.25x also scales up the [jaggies](https://en.wikipedia.org/wiki/Jaggies) that you are seeing.

JAVA2D:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/3/33deb5e3edfb11eb74766cd4e23099f585d3fa75.png)

It is NOT scaled up with P2D and looks much better:

`size(500, 500, P2D);`

P2D:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/a/7aed8cda33c5542b75cb0fdf8680325752e77966.png)

You can also try smooth with P2D or P3D.

FX2D:

```auto
import processing.javafx.*;
size(250, 250, FX2D);

```

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/2/42cb58e94c703a1dff4e3c0d046ad1d0dc48f5c2.png)

I have a W10 PC and use Processing 4.4.4.  
My monitors are _pixelDensity_ of 1.

Sometimes setting to _pixelDensity_ of 1 resolves issues.

Try this in your code of you report a pixelDensity of 2:

`pixelDensity(1);`

And please report back.

References:

- [displayDensity() / Reference / Processing.org](https://processing.org/reference/displayDensity_.html)
- [pixelDensity() / Reference / Processing.org](https://processing.org/reference/pixelDensity_.html)
- [smooth() / Reference / Processing.org](https://processing.org/reference/smooth_.html)

Have fun!

`:)`

---

<div class="post-metadata">

### Author: ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)
#### Post date: [July 3, 2025, 8:43pm UTC](https://discourse.processing.org/t/pixelated-images/46658/3 "2025-07-03T20:43:43Z")

</div>

P2D/P3D with and without smooth doesn’t solve pixelation and neither does pixelDensity. So, as I feared, processing now produces less sharp images - isn’t there an earlier version of the code that produces less pixelated images? I could have sworn that with earlier versions of processing you got sharp images automatically.

---

<div class="post-metadata">

### Author: ![svan](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@svan](https://discourse.processing.org/u/svan)
#### Post date: [July 3, 2025, 10:10pm UTC](https://discourse.processing.org/t/pixelated-images/46658/4 "2025-07-03T22:10:54Z")

</div>

Did you try FX2D for comparison?

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 3, 2025, 11:05pm UTC](https://discourse.processing.org/t/pixelated-images/46658/5 "2025-07-03T23:05:15Z")

</div>

> [@humano](#):
>
> I could have sworn that with earlier versions of processing you got sharp images automatically.

Pixels on most modern day LCD monitors are square.  
Angled lines in digital graphics often show pixelation because of the square nature of screen pixels.  
Smoothing can help reduce the jagged appearance by blending colors at the edges but it doesn’t fully eliminate pixelation.

Look up anti-aliasing to help better understand this.

I have scaling on my Windows 10 set to 1.25x and it will make my sketches look works in JAVA2D because they are scaled up by Windows.  
The P2D sketches are not scaled up.

If you zoom into an image as you have done you will see the pixels and the smoothing!

Keep in mind that Windows (and other OSes) also do smoothing of the image and the final image on the screen is the end result of these.

References:

- [Pixelation - Wikipedia](https://en.wikipedia.org/wiki/Pixelation)
- [Antialiasing – Display Daily](https://displaydaily.com/antialiasing/)

`:)`

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 4, 2025, 12:16am UTC](https://discourse.processing.org/t/pixelated-images/46658/6 "2025-07-04T00:16:52Z")

</div>

> [@svan](#):
>
> Did you try FX2D for comparison?

I added it to my previous post for comparison.

Related topic:

> [@Canvas Scaling with different renderers](https://discourse.processing.org/t/canvas-scaling-with-different-renderers/46337):
>
> Hello folks, I noticed different scaling for sketch windows on W10 with the following for my Display settings and using different renderers: Test code: import processing.javafx.\*; void setup() { size(400, 200); //size(400, 200, FX2D); //size(400, 200, P2D); //size(400, 200, P3D); background(0); textAlign(CENTER, CENTER); textSize(18); text("0123456789" + "\n" + "abcdefghijklmnopqrstuvwxyz" + "\n" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ", width/2, height/…

`:)`

---

<div class="post-metadata">

### Author: ![humano](https://avatars.discourse-cdn.com/v4/letter/h/dbc845/32.png) [@humano](https://discourse.processing.org/u/humano)
#### Post date: [July 4, 2025, 12:58pm UTC](https://discourse.processing.org/t/pixelated-images/46658/7 "2025-07-04T12:58:20Z")

</div>

The processing.javafx.\* library is not included or available in standard Processing (the PDE environment you download from [processing.org](http://processing.org)).

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 4, 2025, 1:07pm UTC](https://discourse.processing.org/t/pixelated-images/46658/8 "2025-07-04T13:07:58Z")

</div>

> [@humano](#):
>
> The processing.javafx.\* library is not included or available in standard Processing

The only constant in the universe is change. That applies to code and software as well and Processing is evolving and has gone through many changes over the years since 2001.

There is a section on renderers here that comments on FX2D and Processing 4 releases:

> **[Environment](https://processing.org/environment/#renderers)**
>
> The Processing Environment includes a text editor, a compiler, and a display window. It enables the creation of software within a carefully designed set of constraints.

It is now available in the Contribution Manager:

- Install the _JavaFX library_.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/2/f/2f1e1245847537c9e3c64bca055fa0130a17b0f3.png)

- Import the _JavaFX library_ in your code:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/9/3/93e334253f21700dad689f7a798685fe2337762b.png)

- This will allow you to use the FX2D renderer.

```auto
import processing.javafx.*;
size(250, 250, FX2D);

```

`:)`
