When you go to draw try passing orange.getElement()

Sent from my iPhone

On Nov 10, 2012, at 2:03 PM, markww <[email protected]> wrote:

> Hi,
> 
> I'm trying to use ClientBundle with an image. My interface:
> 
>     public interface MyImages extends ClientBundle {
>         @Source("orange.png")
>         ImageResource orange();
>     }
> 
> The image "orange.png" is in the same package as the above class.
> 
> Now I try to use it:
> 
>     public void drawCanvas() {
>         MyImages resources = GWT.create(MyImages.class);
>       Image orange = new Image(resources.orange());    
>         System.out.println("size: " + orange.getWidth() + ", " + 
> orange.getHeight(); // prints 500x500
> 
>         ImageElement ie = ImageElement.as(orange.getElement());
>         System.out.println("size: " + ie.getWidth() + ", " + ie.getHeight(); 
> // prints 1x1
>         
>         canvasContext.drawImage(ie, 0, 0);
>     }
> 
> The Image instance prints its width/height, correct at 500x500 pixels. I try 
> to convert it to an ImageElement so I can draw it to a canvas, it prints its 
> width as 1x1 pixels. Which is incorrect. So of course, nothing gets drawn to 
> the canvas. 
> 
> Am I using ClientBundle wrong? I have other methods for loading/drawing the 
> image which work fine. I just wanted to try this interface out,
> 
> Thanks
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/google-web-toolkit/-/xAgxozt0YKkJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to