How to create large SWT image?

落爺英雄遲暮 提交于 2019-12-10 13:57:49

问题


In my eclipse-rcp application I need to create an image with dimensions 30000x10000 px or more. This image is NatTable representation. Using standard image creation approach, it fails with different problems: OutOfMemory, SWTError - IllegalArgument or my PC stops responding (btw, its windows 7, 64bit, 4 RAM - client have much slower laptops, but the picture is still needs to be created). Here is a code snippet:

private Image getNattableImageRepresentation(final Display display) {
        final Rectangle totalGridArea = getTotalGridArea(); //this returns Rectangle(0,0,30000,10000)
        setGridLayerSize(totalGridArea);
        final Image nattableImage = new Image(display, totalGridArea);
        final GC nattableGC = new GC(nattableImage);
        gridLayer.getLayerPainter().paintLayer(gridLayer, nattableGC, 0, 0, totalGridArea, configRegistry);//nattable API, which draws an image into a specified gc
        restoreGridLayerState();
        return nattableImage;
    }
    return null;
}

Are there any tricks to create such huge images or may be API? Is Java Advanced Imaging Api suitable for this purpose?

Any suggestions are appreciated.


回答1:


ImageMagick is neat tool for image processing like this.. new CG is not the way, definitely.. If you'll join all spare images to the big one, there should be no problem at all..




回答2:


There is a simple solution for storing larger images in Java. BigBufferedImage stores the image on the hard drive in a very fast way:

https://stackoverflow.com/a/53205617/2631710



来源:https://stackoverflow.com/questions/9125593/how-to-create-large-swt-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!