|
25 | 25 | import org.eclipse.swt.graphics.GC; |
26 | 26 | import org.eclipse.swt.graphics.Image; |
27 | 27 | import org.eclipse.swt.graphics.ImageData; |
| 28 | +import org.eclipse.swt.graphics.ImageDataProvider; |
28 | 29 | import org.eclipse.swt.graphics.Point; |
29 | 30 | import org.eclipse.swt.graphics.Rectangle; |
30 | 31 | import org.eclipse.swt.layout.GridData; |
@@ -485,25 +486,29 @@ public static Form getForm(Control c) { |
485 | 486 | } |
486 | 487 |
|
487 | 488 | public static Image createAlphaMashImage(Device device, Image srcImage) { |
488 | | - Rectangle bounds = srcImage.getBounds(); |
489 | | - int alpha = 0; |
490 | | - int calpha = 0; |
491 | | - ImageData data = srcImage.getImageData(); |
492 | | - // Create a new image with alpha values alternating |
493 | | - // between fully transparent (0) and fully opaque (255). |
494 | | - // This image will show the background through the |
495 | | - // transparent pixels. |
496 | | - for (int i = 0; i < bounds.height; i++) { |
497 | | - // scan line |
498 | | - alpha = calpha; |
499 | | - for (int j = 0; j < bounds.width; j++) { |
500 | | - // column |
501 | | - data.setAlpha(j, i, alpha); |
502 | | - alpha = alpha == 255 ? 0 : 255; |
| 489 | + |
| 490 | + ImageDataProvider imageDataProvider = zoom -> { |
| 491 | + int alpha = 0; |
| 492 | + int calpha = 0; |
| 493 | + ImageData data = srcImage.getImageData(zoom); |
| 494 | + // Create a new image with alpha values alternating |
| 495 | + // between fully transparent (0) and fully opaque (255). |
| 496 | + // This image will show the background through the |
| 497 | + // transparent pixels. |
| 498 | + for (int i = 0; i < data.height; i++) { |
| 499 | + // scan line |
| 500 | + alpha = calpha; |
| 501 | + for (int j = 0; j < data.width; j++) { |
| 502 | + // column |
| 503 | + data.setAlpha(j, i, alpha); |
| 504 | + alpha = alpha == 255 ? 0 : 255; |
| 505 | + } |
| 506 | + calpha = calpha == 255 ? 0 : 255; |
503 | 507 | } |
504 | | - calpha = calpha == 255 ? 0 : 255; |
505 | | - } |
506 | | - return new Image(device, data); |
| 508 | + |
| 509 | + return data; |
| 510 | + }; |
| 511 | + return new Image(device, imageDataProvider); |
507 | 512 | } |
508 | 513 |
|
509 | 514 | public static boolean mnemonicMatch(String text, char key) { |
|
0 commit comments