Interesting, I was on my cell phone before, couldn't check to see but could have sworn that it would take an Element. In any case, if it all fails I guess try then:
ImageElement element = ImageElement.as(image.getElement()); element.setWidth(image.getWidth()); element.setHeight(image.getHeight()); Depending on how involved you need to get with canvas stuff, you might also want to take a look at: http://www.emitrom.com/announcements/lienzo/alpha Regards, Alfredo On Sat, Nov 10, 2012 at 3:47 PM, markww <[email protected]> wrote: > Hi, > > Context2d.drawImage() wants an ImageElement, but orange.getElement() only > produces an Element instance. This is why in the example I had: > > ImageElement.as(orange.**getElement()); > > Thanks > > > On Saturday, 10 November 2012 14:07:27 UTC-5, Alfredo Quiroga-Villamil > wrote: > >> When you go to draw try passing orange.getElement() >> >> Sent from my iPhone >> >> >> 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<https://groups.google.com/d/msg/google-web-toolkit/-/xAgxozt0YKkJ> >> . >> To post to this group, send email to google-we...@**googlegroups.com. >> >> To unsubscribe from this group, send email to google-web-toolkit+** >> [email protected]. >> For more options, visit this group at http://groups.google.com/** >> group/google-web-toolkit?hl=en<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 view this discussion on the web visit > https://groups.google.com/d/msg/google-web-toolkit/-/xn1JzkTnHvQJ. > > 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. > -- Alfredo Quiroga-Villamil AOL/Yahoo/Gmail/MSN IM: lawwton -- 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.
