Skip to content

Replacing Image(Device, ImageData) constructor in DefaultRangeIndicator with Image(Device, ImageDataProvider) #3003

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

Closed
Closed
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 @@ -20,6 +20,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.PaletteData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
Expand Down Expand Up @@ -139,16 +140,31 @@ private static Image createImage(Display display, Point size, Color rangeIndicat
int height= size.y;


ImageData imageData= new ImageData(width, height, 1, createPalette(display, rangeIndicatorColor));
ImageDataProvider imageDataProvider = zoom -> {

float scaleFactor = (float) ((zoom) / 100.0);
int scaledWidth = Math.round(width * scaleFactor);
int scaledHeight = Math.round(height * scaleFactor);
ImageData imageData = new ImageData(scaled_width, scaled_height,
1,
createPalette(display, rangeIndicatorColor));
int blockSize = Math.round(scaleFactor);
for (int y = 0; y < scaled_height; y++)
for (int x = 0; x < scaled_width; x++) {
if (((x / blockSize) + (y / blockSize)) % 2 == 0) {
imageData.setPixel(x, y, 1);
}

}
imageData.transparentPixel = 1;
return imageData;

};

for (int y= 0, offset= 1; y < height; y++, offset= (offset + 1) % 2)
for (int x= offset; x < width; x += 2)
imageData.setPixel(x, y, 1);

imageData.transparentPixel= 1;


return new Image(display, imageData);
return new Image(display, imageDataProvider);
}

/**
Expand Down