SWT Image Concatenation or Tiling / Mosaic

I have an Eclipse RCP application that displays many (10k +) small images next to each other, for example, with a strip for a movie. For each image, I use a SWT object Image. It uses an excessive amount of memory and resources. I am looking for a more efficient way. I thought about taking all these images and combining them, creating an object ImageDatafor the correct general concatenated width (with a constant height) and using setPixel()for the rest of the pixels. However Palette, used in the constructor ImageData, I cannot understand.

I also looked for SWT tile or mosaic functions to create a single image from a group of images, but didn't find anything.

Any ideas how I can efficiently display thousands of small images next to each other? Please note that after the images are displayed, they are not processed, so this is a one-time cost.

+3
source share
3 answers

You can draw directly on the GC (graphic context) a new (large) image. Having one large image should result in significantly less resource use than thousands of smaller images (each image in the SWT stores an OS object handle)

What you can try is something like this:

        final List<Image> images;
        final Image bigImage = new Image(Display.getCurrent(), combinedWidth, height);
        final GC gc = new GC(bigImage);
        //loop thru all the images while increasing x as necessary:
        int x = 0;
        int y = 0;
        for (Image curImage : images) {
            gc.drawImage(curImage, x, y);
            x += curImage.getBounds().width;
        }
        //very important to dispose GC!!!
                    gc.dispose();
        //now you can use bigImage
+2
source

, ? , , ( ) , , . , , .

0

Java , java imaging (JAI) SWT. , , , java. , ImageMagick . , ++ API ImageMagick, .

0

Source: https://habr.com/ru/post/1699304/


All Articles