English 中文(简体)
GWT Canvas图像传播
原标题:GWT Image Loading for Canvas

在不使用任何图像装饰图书馆的情况下,我装上如下图象:

final Image img = new Image();
img.setVisible(false);
RootPanel.get().add(img);
img.addErrorHandler(new ErrorHandler() {
    @Override
    public void onError(ErrorEvent event) {
        System.out.println(event);
    }
});
img.addLoadHandler(new LoadHandler() {
    @Override
    public void onLoad(LoadEvent event) {
        ImageElement data = ImageElement.as(img.getElement());
        RootPanel.get().remove(img);
        obj.setData(data);
        System.out.println("Arrived:" + (System.currentTimeMillis()-startTime) + "ms");
        render();
    }
});

Without using RootPanel.get().add(img); the image will never be added to the DOM. So onLoad will not be triggered. But when you add the image into the DOM, if you don t remove it, this will be memory leak.

我对上述法典的看法:

  1. If I dont add the image to the DOM, load handler will not be triggered.
  2. If I do, but dont remove after loaded, a memory leak will be occured.
  3. I I do, and I do remove, Chrome will call garbage collection after 256 MB. Firefox never called garbage collection. So a memory leak occured. May be Firefox will call garbage collector when it needs. I dont know this issue so much.

My questions are, are there image loading procedures (libraries) handle image loading?
Do they automatically remove the image from the DOM after the image has loaded?
Is there a more appropriate way to handle this issue where you re drawing many images but does not require the image after drawing?
Also are there fast approaches to add and remove the images to/from the DOM?

最佳回答

装上图像时使用 com.google.gwt.widgetideas.graphics.client.Image Loader

在一个时候,这把大量图像装上了。

问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签