Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac Retina devices now generate Images at 2x (since Eclipse 4.12) #651

Closed
Phillipus opened this issue Jul 10, 2020 · 7 comments
Closed

Mac Retina devices now generate Images at 2x (since Eclipse 4.12) #651

Phillipus opened this issue Jul 10, 2020 · 7 comments

Comments

@Phillipus
Copy link
Member

@Phillipus Phillipus commented Jul 10, 2020

This affects Archi 4.6 and later on Mac Retina devices.

If you export an image to PNG or do "Copy As image to Clipboard" the outlines in the resulting image will look like they are anti-aliased and not solid. You can see this if you zoom in on the resulting image. The outlines should be solid.

I investigated this and found that it seems to be an issue in Eclipse.

  • Archi 4.5.1 does not have this issue - it uses Eclipse 4.11
  • Archi 4.6 has this issue - it uses Eclipse 4.13
  • Archi 4.7 has this issue - it uses Eclipse 4.15

I have reported this issue to Eclipse - https://bugs.eclipse.org/bugs/show_bug.cgi?id=565138

One workaround is to go into Archi's Preferences, General, and check "Export images at 2x size". The images will be double-sized but at least will have solid outlines.

@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 10, 2020

This was introduced in Eclipse 4.12.

https://www.eclipse.org/eclipse/news/4.12/platform.php#mac-hidpi

"On Mac, images and text are now drawn in high resolution during GC operations. You can see crisp images on high resolution displays in the editor rulers, forms, etc in Eclipse."

I guess this must mean that images have to be exported at 2x size as we do on Windows.

@Phillipus Phillipus changed the title Lines in exported images on Mac Retina devices are anti-aliased (Eclipse regression) Lines in exported images on Mac Retina devices are anti-aliased (Eclipse issue) Jul 10, 2020
@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 10, 2020

#596 is related to this.

It's a pain that if an Image is generated on hi-res devices we have to export it at 2x the logical size in order to retain quality.

Next experiment - generate image at 200% scale then use ImageData at 50%.

@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 11, 2020

Next experiment - generate image at 200% scale then use ImageData at 50%.

No, looks terrible.

I've just realised that the issue is due to the DPI in the exported image. If I take a Mac screen shot of an Archi diagram the DPI is 144 pixels/inch. The Image export and copy to clipboard routines in Archi rely on Eclipse's Image and ImageData classes that create images with a DPI of 72 pixels/inch. So in theory what we need to do is get the ImageData at 200 but export the image with double DPI. I don't even know if that's possible.

@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 11, 2020

So in theory what we need to do is get the ImageData at 200 but export the image with double DPI. I don't even know if that's possible.

Nope - can't change the DPI in Eclipse.

But what I don't understand is that some Image editing apps on Mac Retina (Pixelmator) will show the exported image at half its size.

https://www.pixelmator.com/community/viewtopic.php?f=5&t=15038

😕

(Paging @jbsarrodie who understands this stuff)

Phillipus added a commit that referenced this issue Jul 11, 2020
* Since Eclipse 4.12 Mac images are rendered at hi-res
* See #651
@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 12, 2020

  1. In order to maintain image quality on Mac Retina and Windows with hi-res screens we have to export images at the device zoom level (200%)
  2. However, this means that the images are twice as big as normal
  3. This is particularly obvious when creating the HTML report - the images of Views are twice as big
  4. This is due to the images having a DPI of 72 rather than 144

So, if we could set the DPI of the images to 144 we would have a great result. We can't do that in Eclipse...but we can change the DPI by re-loading, setting the DPI, and saving the file again using some Java code I found:

https://stackoverflow.com/questions/321736/how-to-set-dpi-information-in-an-image/43043998
https://forum.processing.org/two/discussion/27406/set-dpi-on-a-png-when-saving-a-pgraphics

This actually works. But only so far for PNG files.

@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 12, 2020

This actually works.

Not really.

Setting the DPI in the image to 144 makes it look the "right size" in the Preview app on Mac but not in a Browser. And the whole point of this DPI experiment was to make the images look the "right size" in the Browser, so there's no point in doing this.

Here's a summary of my findings:

When Eclipse creates an Image it creates it on a Device. This happens to be the physical screen, unfortunately not a virtual device. So if the screen is retina/hi-res then the Image is drawn at 200% and the ImageData (used to save the Image to file) has to be retrieved at 200% scale. If we retrieve the ImageData at 100% (as we have been doing on Mac Retina) the image quality will be compromised.

So, users with retina / hi-res devices have a choice:

  1. Images are saved at 100% size but the quality is less.
  2. Images are saved at 200% but the quality is 1:1.

And so in Archi 4.7.1 beta 2 this choice will appear in Preferences (this Preference is already in Archi 4.7 but only for Windows):

Screenshot 2020-07-12 at 16 13 23

Linux users are not affected by this issue...yet.

Phillipus added a commit that referenced this issue Jul 12, 2020
* Since Eclipse 4.12 Mac images are rendered at hi-res
* See #651
Phillipus added a commit that referenced this issue Jul 12, 2020
* Since Eclipse 4.12 Mac images are rendered at hi-res
* See #651
@Phillipus Phillipus changed the title Lines in exported images on Mac Retina devices are anti-aliased (Eclipse issue) Mac Retina devices now generate Images at 2x (since Eclipse 4.12) Jul 13, 2020
@Phillipus
Copy link
Member Author

@Phillipus Phillipus commented Jul 15, 2020

This is in Archi 4.7.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant