From 1cf07590ce78f47d9aca68fb9b3cbbf2be517457 Mon Sep 17 00:00:00 2001 From: arunjose696 Date: Tue, 15 Jul 2025 16:10:34 +0200 Subject: [PATCH] create Image with ImageDataProvider instead of ImageData in fillGradientRectangle() This PR refactors the image creation logic in fillGradientRectangle() by using an ImageDataProvider instead of directly creating ImageData. There is no visual impact for the changes the behavior should remain as before. --- .../common/org/eclipse/swt/graphics/ImageData.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java index 6b74adc9c26..679db492abe 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java @@ -2616,9 +2616,15 @@ static void fillGradientRectangle(GC gc, Device device, RGB fromRGB, RGB toRGB, int redBits, int greenBits, int blueBits, int zoom) { /* Create the bitmap and tile it */ - ImageData band = createGradientBand(width, height, vertical, - fromRGB, toRGB, redBits, greenBits, blueBits); - Image image = new Image(device, band); + ImageDataProvider imageDataProvider = imageZoom -> { + float scaleFactor = imageZoom / 100f; + int scaledWidth = Math.round(width * scaleFactor); + int scaledHeight = Math.round(height * scaleFactor); + return createGradientBand(scaledWidth, scaledHeight, vertical, fromRGB, toRGB, redBits, greenBits, + blueBits); + }; + Image image = new Image(device, imageDataProvider); + ImageData band = image.getImageData(); if ((band.width == 1) || (band.height == 1)) { gc.drawImage(image, 0, 0, DPIUtil.pixelToPoint(band.width, zoom), DPIUtil.pixelToPoint(band.height, zoom), DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(width, zoom),