On Tue, 20 Oct 2026 21:30:34 GMT, Andy Goryachev <[email protected]> wrote:

> More findings, but we are getting close.
> 
> Question: why is rendering using the `DrawingContext` seems always blurry?

There's two reasons:
- Canvas cheats (I think I commented on that in this PR somewhere) -- if 
display scale > 1, it allocates a texture twice the size which makes things 
look crispier
- WritableImage uses the exact amount of pixels you gave it, but when displayed 
on a high DPI screen, it is scaled up (ie. x2 or x1.5) making it look blurry as 
there simply aren't enough pixels to map to the screen pixels

This is known problem and there are ways to get crispy sharp images (it has 
nothing to do with `DrawingContext`):

- Allocate more pixels, and apply a scale to the `ImageView` that "undoes" the 
display scale. This involves wrapping the `ImageView` in a `Group` (to keep 
correct layout after a scale is applied as scale is otherwise not taken into 
account for layout)
- (NEW OPTION) Use `DrawingContext` but set a scale transform that undoes the 
display scale

Also in your program you had a fall-through that after filling a text, it also 
strokes it, which make it look extra blurry as the stroke/fill can be partially 
transparent.

Here is an image of the fixed program:

<img width="1883" height="1321" alt="image" 
src="https://github.com/user-attachments/assets/7a131b37-451e-4327-a12a-25f3981fe691";
 />

And the program fixed:

[DrawingContext_8390915.java](https://github.com/user-attachments/files/33744946/DrawingContext_8390915.java)

-------------

PR Comment: https://git.openjdk.org/jfx/pull/1969#issuecomment-6305144379

Reply via email to