Skip to content

Commit 67ce839

Browse files
committed
Remove duplicate representation of alpha values in image data from SVG
The image data generated for a rasterized SVG currently uses a 32 bit data array and an alpha values array. The alpha values for every pixel are stored in both the alpha values array as well as the alpha channel of the 32 bit data array. This is a redundant representation not giving any benefits but just leading to unnecessary memory consumption. This change adapts the SVG rasterization to create image data with a 24 bit data array, such that the alpha values are only stored in the alpha array.
1 parent 1bf111f commit 67ce839

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bundles/org.eclipse.swt.svg/src/org/eclipse/swt/svg/JSVGRasterizer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ private ImageData convertToSWTImageData(BufferedImage rasterizedImage) {
121121
int width = rasterizedImage.getWidth();
122122
int height = rasterizedImage.getHeight();
123123
int[] pixels = ((DataBufferInt) rasterizedImage.getRaster().getDataBuffer()).getData();
124-
PaletteData paletteData = new PaletteData(0x00FF0000, 0x0000FF00, 0x000000FF);
125-
ImageData imageData = new ImageData(width, height, 32, paletteData);
124+
PaletteData paletteData = new PaletteData(0xFF0000, 0x00FF00, 0x0000FF);
125+
ImageData imageData = new ImageData(width, height, 24, paletteData);
126126
int index = 0;
127127
for (int y = 0; y < imageData.height; y++) {
128128
for (int x = 0; x < imageData.width; x++) {
129129
int alpha = (pixels[index] >> 24) & 0xFF;
130130
imageData.setAlpha(x, y, alpha);
131-
imageData.setPixel(x, y, pixels[index++]);
131+
imageData.setPixel(x, y, pixels[index++] & 0x00FFFFFF);
132132
}
133133
}
134134
return imageData;

0 commit comments

Comments
 (0)