How to create large SWT image?

2019-06-22 13:04发布

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.

2条回答
狗以群分
2楼-- · 2019-06-22 13:44

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

查看更多
Ridiculous、
3楼-- · 2019-06-22 14:02

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..

查看更多
登录 后发表回答