Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    PNG Images not sizing correctly on load

    I'm having trouble getting PNG images to size correctly on load. The images are maps dynamically generated on one of our servers. To simplify the problem, I've simulated the servlet call and eliminated browser caching from the problem by adding a date parameter on the image URL. The image renders in the browser at 25x100, where as its natural size is 350x208.

    How do I get the image to display at its natural size?

    Sample code is below. I'm running SmartClient Version: v8.2p_2012-04-10/Enterprise Deployment (built 2012-04-10) on Firefox 11.0, Mac OSX 10.6.8.

    Thanks,
    Chris

    Code:
    		VLayout example = new VLayout();
    
    		example = new VLayout();
    		example.setOverflow(Overflow.VISIBLE);
    		example.setPadding(5);
    		example.setMembersMargin(5);
    		example.setHeight(1);
    		example.setWidth(1);
    
    		final Img image = new Img(
    				"http://www.w3.org/Graphics/PNG/nurbcup2si.png?date="
    						+ System.currentTimeMillis());
    		image.setImageType(ImageStyle.NORMAL);
    
    		example.addMember(image);
    
    		example.draw();

    #2
    We don't know the natural size of the image until it's loaded, so we can't auto-size to it. You can use the core GWT "Image" class to wait until the image is loaded, then create the Img widget at that time.

    Comment

    Working...
    X