From fa5408b897aebba0f5c65924f08ec23e81226504 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 | 11 ++++++++--- 1 file changed, 8 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 6b74adc9c2..c9f788da54 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,14 @@ 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 -> { + int scaledWidth = DPIUtil.pointToPixel(width, imageZoom); + int scaledHeight = DPIUtil.pointToPixel(height, imageZoom); + return createGradientBand(scaledWidth, scaledHeight, vertical, fromRGB, toRGB, redBits, greenBits, + blueBits); + }; + Image image = new Image(device, imageDataProvider); + ImageData band = image.getImageData(zoom); 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),