Skip to content

Commit 0cd839a

Browse files
committed
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.
1 parent ebcb6b9 commit 0cd839a

File tree

1 file changed

+8
-3
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics

1 file changed

+8
-3
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,9 +2616,14 @@ static void fillGradientRectangle(GC gc, Device device,
26162616
RGB fromRGB, RGB toRGB,
26172617
int redBits, int greenBits, int blueBits, int zoom) {
26182618
/* Create the bitmap and tile it */
2619-
ImageData band = createGradientBand(width, height, vertical,
2620-
fromRGB, toRGB, redBits, greenBits, blueBits);
2621-
Image image = new Image(device, band);
2619+
ImageDataProvider imageDataProvider = imageZoom -> {
2620+
int scaledWidth = Win32DPIUtils.pointToPixel(width, imageZoom);
2621+
int scaledHeight = Win32DPIUtils.pointToPixel(height, imageZoom);
2622+
return createGradientBand(scaledWidth, scaledHeight, vertical, fromRGB, toRGB, redBits, greenBits,
2623+
blueBits);
2624+
};
2625+
Image image = new Image(device, imageDataProvider);
2626+
ImageData band = image.getImageData(zoom);
26222627
if ((band.width == 1) || (band.height == 1)) {
26232628
gc.drawImage(image, 0, 0, DPIUtil.pixelToPoint(band.width, zoom), DPIUtil.pixelToPoint(band.height, zoom),
26242629
DPIUtil.pixelToPoint(x, zoom), DPIUtil.pixelToPoint(y, zoom), DPIUtil.pixelToPoint(width, zoom),

0 commit comments

Comments
 (0)