JUCE ignores image resolution


JUCE seems to ignore the resolution of images. Instead it renders the image with the same size regardless of its dpi setting.
A 10x10 72 image dpi should have the same size on screen as a 20x20 144dpi.

How can this be achieved? Do I need to scale all images before drawing so they are shown correctly?


Personally, I would write an ImageDisplay (or similarly named) subclass of Component which handles scaling by taking the desktop scale factor into account before drawing the image in the paint() method - this allows it to play nicely in the component hierarchy while keeping Graphics-level hackery needed to render at the correct DPI localized to one spot.


Thanks, exactly thats what I am considering also, I just wanted to verify if I am missing here something or if this is just JUCEs ignorance…


Now, if I have to do all by myself how do I find out the dpi of an juce::Image?


By the time you get to using an Image, the data is already rasterised by that point and unrelated to any device - the concept of DPI no longer applies until you have some kind of context.


Yes, the juce Image class has never contained any kind of information about its DPI, and none of our image file format readers will pull that info out of a file either. It’s a valid feature request, but not something we’ll do in the near term.


no, its implicitly related to a fixed pixel density. Thats why its a necessary information to display an image correctly. It works only because the developer assumes/don’t cares about the image/screen relation.