Skip to content

Replace usages of new Image(device, width, height) #1924

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

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion bundles/org.eclipse.swt.tools.spies/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.tools.spies;singleton:=true
Bundle-Version: 3.109.500.qualifier
Bundle-Version: 3.109.600.qualifier
Bundle-ManifestVersion: 2
Export-Package: org.eclipse.swt.tools.internal,
org.eclipse.swt.tools.views
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,8 @@ private void saveToFile(boolean prompt) {
if (saveImages) {
String suffix = String.format("%05d.png", i++);
String pngName = String.format("%s_%s", fileName, suffix);
Image image = new Image(saveAs.getDisplay(), 100, 100);
Image image = new Image(saveAs.getDisplay(), (gc, width, height) -> draw(gc, object), 100, 100);
try {
GC gc = new GC(image);
try {
draw(gc, object);
} finally {
gc.dispose();
}
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };
loader.save(pngName, SWT.IMAGE_PNG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1593,31 +1593,31 @@ void createCaretBitmaps() {
leftCaretBitmap.dispose();
}
int lineHeight = renderer.getLineHeight();
leftCaretBitmap = new Image(display, caretWidth, lineHeight);
GC gc = new GC (leftCaretBitmap);
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(0, 0, caretWidth, lineHeight);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(0,0,0,lineHeight);
gc.drawLine(0,0,caretWidth-1,0);
gc.drawLine(0,1,1,1);
gc.dispose();
final ImageGcDrawer leftCaretDrawer = (gc, width, height) -> {
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(0, 0, width, height);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(0,0,0,height);
gc.drawLine(0,0,width-1,0);
gc.drawLine(0,1,1,1);
};
leftCaretBitmap = new Image(display, leftCaretDrawer, caretWidth, lineHeight);

if (rightCaretBitmap != null) {
if (defaultCaret != null && rightCaretBitmap.equals(defaultCaret.getImage())) {
defaultCaret.setImage(null);
}
rightCaretBitmap.dispose();
}
rightCaretBitmap = new Image(display, caretWidth, lineHeight);
gc = new GC (rightCaretBitmap);
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(0, 0, caretWidth, lineHeight);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(caretWidth-1,0,caretWidth-1,lineHeight);
gc.drawLine(0,0,caretWidth-1,0);
gc.drawLine(caretWidth-1,1,1,1);
gc.dispose();
final ImageGcDrawer rightCaretDrawer = (gc, width, height) -> {
gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
gc.fillRectangle(0, 0, width, height);
gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
gc.drawLine(width-1,0,width-1,height);
gc.drawLine(0,0,width-1,0);
gc.drawLine(width-1,1,1,1);
};
rightCaretBitmap = new Image(display, rightCaretDrawer, caretWidth, lineHeight);
}
/**
* Moves the selected text to the clipboard. The text will be put in the
Expand Down
Loading