0

I'm generating a base64 image source at server side and then retrieving it to GWT client through async calls. Unfortunatelly, images are not showing after the callback ends (everything is working fine), but it is shown after a second callback. I have tryied to catch onLoad event immediatelly after creating the Image object, but it was no good.

Thanks!

Edit 1

After some investigation, it is a matter of dimensions, I mean, the base64 is there and the image tag is created correctly, but width and height are setted both to 0.

Edit 2

This is how I'm placing the image in the website:

import net.customware.gwt.dispatch.server.Dispatch
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Image;

dispatch.execute(action, new AsyncCallback<GenerateImageResult> () {
    @Override
    public void onFailure(Throwable caught) {};
    @Override
    public void onSuccess(GetCarpetasResult result) {
        String base64 = result.getBase64();
        Image image = new Image(base64);
        RootPanel.get().add(image);
    }
});
  • Please post your corresponding code. Are you using ClientBundle to generate base64 images? – rzymek May 05 '13 at 21:00
  • Actually, I'm generating the image in server side (by using Java 2D library) and then returning the base64 generated code to client side in the callback of the async call. –  May 05 '13 at 22:15
  • Ok. So show me how are you placing the image on the website. – rzymek May 06 '13 at 17:33

2 Answers2

0

I've been able to successfully display (in google-chome) base64 image data using this:

    String base64= "data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAAAAAAAAAAAAAAbGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf8AAAAAAAAAAGxsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/AAAAAAAAAABsbG3/bGxt/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABsbG3/bGxt/wAAAAAAAAAAbGxt/2xsbf8AAAAAbGxt/2xsbf9sbG3/bGxt/2xsbf9sbG3/bGxt/2xsbf8AAAAAbGxt/2xsbf8AAAAAAAAAAGxsbf9sbG3/AAAA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EAAPABAADwIQAA+MP///+H////DwAA/g8AAA==";
    Image image = new Image(base64);
    RootPanel.get().add(image);

Check these things:

  • is your base64 data starting with data:${mime};base64,?
  • is your mime really describing the decoded base64 image format?
rzymek
  • 9,064
  • 2
  • 45
  • 59
0

Have you tryied to add onLoadHandler to the image object? Something like this:

image.addLoadHandler(new LoadHandler () {
    @Override
    public void onLoad(LoadEvent event) {
        image.setUrl(base64);
    }
});