0

I need help. I need display jpg image from url.

Desktop version work fine

byte[] imgBytes
new Pixmap(imgBytes, 0, imgBytes.length)

But it is not work in GWT project. I try this solution "Tainted canvases may not be loaded" Cross domain issue with WebGL textures

public void downloadPixmap(final String url, final DownloadPixmapResponse response) {
    final RootPanel root = RootPanel.get("embed-html");
    final Image img = new Image(url);
    img.getElement().setAttribute("crossOrigin", "anonymous");
    img.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            HtmlLauncher.application.getPreloader().images.put(url, ImageElement.as(img.getElement()));
            response.downloadComplete(new Pixmap(Gdx.files.internal(url)));
            root.remove(img);
        }
    });
    root.add(img);
}

interface DownloadPixmapResponse {
     void downloadComplete(Pixmap pixmap);       
     void downloadFailed(Throwable e);
}

but it is work only in Chrome browser. It is not work in Mozilla Firefox. Help me please

Community
  • 1
  • 1

1 Answers1

0

Problem was in url. Some url do not have header Access-Control-Allow-Origin *

That is why images do not display. I fix this using nginx. Here link to my settings, my problems and ansvers https://serverfault.com/questions/816080/nginx-proxy-pass-regexp-to-another-domain

Community
  • 1
  • 1