Get the size of an image loaded into a panel
-
I'd like to draw an image centred in a panel, but without being able to calculate the ratio, I can only center it either vertically or horizontally.
I can do
g.drawImage([this.getWidth()/4, this.getHeight()/4, this.getWidth()/2, this.getHeight()/2], 0, 0)
But when the ratio of the image is not the same than the one of the panel, the larger dimension wins the race.
So is there a way to get the width and height of a loaded image?
-
@ustk Yes, you added it to HISE, then I also added it, and Christoph hasn't merged either, maybe he doesn't want to pick a favourite :)
https://github.com/christophhart/HISE/pull/289
https://github.com/christophhart/HISE/pull/403 -
@d-healey
2.5 years that I added it
-
@d-healey Actually a mix of the two might be a better candidate, keeping the w/h separated, and removing the for loop for a more direct
getLoadedImage(imageName)
@Christoph-Hart ?