|
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;
|
@@ -135,20 +136,28 @@ private Image getImage(Control control, Color rangeIndicatorColor) {
|
135 | 136 | */
|
136 | 137 | private static Image createImage(Display display, Point size, Color rangeIndicatorColor) {
|
137 | 138 |
|
138 |
| - int width= size.x; |
139 |
| - int height= size.y; |
140 |
| - |
141 |
| - |
142 |
| - ImageData imageData= new ImageData(width, height, 1, createPalette(display, rangeIndicatorColor)); |
143 |
| - |
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 |
| - |
148 |
| - imageData.transparentPixel= 1; |
149 |
| - |
| 139 | + int width = size.x; |
| 140 | + int height = size.y; |
| 141 | + |
| 142 | + ImageDataProvider imageDataProvider = zoom -> { |
| 143 | + float scaleFactor = zoom / 100.0f; |
| 144 | + int scaledWidth = Math.round(width * scaleFactor); |
| 145 | + int scaledHeight = Math.round(height * scaleFactor); |
| 146 | + ImageData imageData = new ImageData(scaledWidth, scaledHeight, 1, |
| 147 | + createPalette(display, rangeIndicatorColor)); |
| 148 | + int blockSize = Math.round(scaleFactor); |
| 149 | + for (int y = 0; y < scaledHeight; y++) { |
| 150 | + for (int x = 0; x < scaledWidth; x++) { |
| 151 | + if (((x / blockSize) + (y / blockSize)) % 2 == 0) { |
| 152 | + imageData.setPixel(x, y, 1); |
| 153 | + } |
| 154 | + } |
| 155 | + } |
| 156 | + imageData.transparentPixel = 1; |
| 157 | + return imageData; |
| 158 | + }; |
150 | 159 |
|
151 |
| - return new Image(display, imageData); |
| 160 | + return new Image(display, imageDataProvider); |
152 | 161 | }
|
153 | 162 |
|
154 | 163 | /**
|
|
0 commit comments