-
Notifications
You must be signed in to change notification settings - Fork 20
Closed
Milestone
Description
See eclipse-emf/org.eclipse.emf#73 for context. The SEG_ADD and SEG_MOVE cursors are created using the following snippet:
Lines 39 to 42 in f8ad590
| static { | |
| CURSOR_SEG_ADD = new Cursor(null, GefUIPluginImages.DESC_SEG_ADD.getImageData(getDeviceZoom()), 0, 0); | |
| CURSOR_SEG_MOVE = new Cursor(null, GefUIPluginImages.DESC_SEG_MOVE.getImageData(getDeviceZoom()), 0, 0); | |
| } |
The problem: The source are two PNG files for 100% and 200% display zoom, respectively. If the zoom level is e.g. 125%, getImageData(125) returns null, which then triggers an IllegalArgumentException by SWT.
Suggestion:
Check if the image data for the given zoom level is null and if so, artificially scale it.
public static ImageData scaledImageData(ImageDescriptor descriptor, int zoom) {
// Default case: Image in matching resolution has been found
ImageData data = descriptor.getImageData(zoom);
if (data != null) {
return data;
}
// Otherwise artifically scale the image
Image image = descriptor.createImage();
try {
return image.getImageData(zoom);
} finally {
image.dispose();
}
}Though I believe the provided ImageData should generally be at 100% zoom. Otherwise the scaling is done twice: Once by GMF and once by SWT (which would then lead to e.g. a 400% zoom cursor at 200% zoom).
Metadata
Metadata
Assignees
Labels
No labels