Skip to content

Use constructor Image(Device, ImageDataProvider) for Radial gradients #3040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageDataProvider;
import org.eclipse.swt.graphics.ImageGcDrawer;
import org.eclipse.swt.graphics.PaletteData;
import org.eclipse.swt.graphics.Point;
Expand Down Expand Up @@ -135,13 +136,17 @@ public void handleEvent(Event event) {
}
}

BufferedImage image = getBufferedImage(size.x, size.y, colors,
CSSSWTColorHelper.getPercents(grad));
// long startTime = System.currentTimeMillis();
ImageData imagedata = convertToSWT(image);
// System.out.println("Conversion took "
// + (System.currentTimeMillis() - startTime) + " ms");
gradientImage = new Image(control.getDisplay(), imagedata);
ImageDataProvider imageDataProvider = zoom -> {
float scaleFactor = zoom / 100.0f;
Copy link
Contributor

@amartya4256 amartya4256 Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also just say 100f

int scaledWidth = Math.round(size.x * scaleFactor);
int scaledHeight = Math.round(size.y * scaleFactor);
BufferedImage image = getBufferedImage(scaledWidth, scaledHeight, colors,
CSSSWTColorHelper.getPercents(grad));
ImageData imagedata = convertToSWT(image);
return imagedata;
};

gradientImage = new Image(control.getDisplay(), imageDataProvider);
radialGradient = true;
} else if (oldImage == null || oldImage.isDisposed()
|| oldImage.getBounds().height != size.y || radialGradient
Expand Down
Loading