on 10-02-2013 9:49 AM
Hi!
I want to dynamically display an image for a LinkToUrl ui element in my web dynpro application that I get from an URL. I'm trying to restrict the size to either max 400px width or max 400px height depending on which is biggest, without distorting the image proportions or enlarging smaller images.
Currently I just set the width to 400px, but that means narrower images are stretched (enlarged) to 400px which makes them blurry and possibly higher than 400px. In never want to enlarge images.
If i set both width and height to 400px images are distorted to fit that size.
I have tried setting the image to 100% and put it in inside a container limited to 400px but that didn't work either.
It seems relative size in % is related to image size and not container size.
I even tried to get the width and height from the url using the javax.ImageIO api but the buffered image is null (possibly due to proxy issues?)
Like this:
URL urlx = new URL(url);
BufferedImage bufferedImage = ImageIO.read(urlx.openStream());
//Always null
if (bufferedImage != null) {
Graphics graphics = bufferedImage.getGraphics();
int maxWidth = 400;
int width = bufferedImage.getWidth();
int height = bufferedImage.getHeight();
}
Any ideas how to solve this?
Best regards,
Richard Linnander
Point of setting the size: use two context variables of type int. Assign these variables to the ui element's height and width property. Set these values in the code.
Now, to the tricky part of getting size of image: its pure java. Just found some links with same issue:
how to get the size of an image in java - Stack Overflow
Hope its of help to you.
Regards,
Sharath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.