Skip to content

Refactor fillGradientRectangle to avoid DPIUtil.autoScaleDown() #2284

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 @@ -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 / 100.0f;
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),
Expand Down
Loading