|
20 | 20 | import org.eclipse.swt.graphics.GC; |
21 | 21 | import org.eclipse.swt.graphics.Image; |
22 | 22 | import org.eclipse.swt.graphics.ImageData; |
| 23 | +import org.eclipse.swt.graphics.ImageDataProvider; |
23 | 24 | import org.eclipse.swt.graphics.PaletteData; |
24 | 25 | import org.eclipse.swt.graphics.Point; |
25 | 26 | import org.eclipse.swt.graphics.RGB; |
@@ -139,16 +140,31 @@ private static Image createImage(Display display, Point size, Color rangeIndicat |
139 | 140 | int height= size.y; |
140 | 141 |
|
141 | 142 |
|
142 | | - ImageData imageData= new ImageData(width, height, 1, createPalette(display, rangeIndicatorColor)); |
| 143 | + ImageDataProvider imageDataProvider = zoom -> { |
| 144 | + |
| 145 | + float scaleFactor = (float) ((zoom) / 100.0); |
| 146 | + int scaled_width = Math.round(width * scaleFactor); |
| 147 | + int scaled_height = Math.round(height * scaleFactor); |
| 148 | + ImageData imageData = new ImageData(scaled_width, scaled_height, |
| 149 | + 1, |
| 150 | + createPalette(display, rangeIndicatorColor)); |
| 151 | + int blockSize = Math.round(scaleFactor); |
| 152 | + for (int y = 0; y < scaled_height; y++) |
| 153 | + for (int x = 0; x < scaled_width; x++) { |
| 154 | + if (((x / blockSize) + (y / blockSize)) % 2 == 0) { |
| 155 | + imageData.setPixel(x, y, 1); |
| 156 | + } |
| 157 | + |
| 158 | + } |
| 159 | + imageData.transparentPixel = 1; |
| 160 | + return imageData; |
| 161 | + |
| 162 | + }; |
143 | 163 |
|
144 | | - for (int y= 0, offset= 1; y < height; y++, offset= (offset + 1) % 2) |
145 | | - for (int x= offset; x < width; x += 2) |
146 | | - imageData.setPixel(x, y, 1); |
147 | 164 |
|
148 | | - imageData.transparentPixel= 1; |
149 | 165 |
|
150 | 166 |
|
151 | | - return new Image(display, imageData); |
| 167 | + return new Image(display, imageDataProvider); |
152 | 168 | } |
153 | 169 |
|
154 | 170 | /** |
|
0 commit comments