Skip to content

Commit 1e45dab

Browse files
Use existing methods to create handles instead of creating a new image
1 parent de34f0a commit 1e45dab

File tree

2 files changed

+8
-12
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT

2 files changed

+8
-12
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -903,24 +903,22 @@ public Image(Device device, ImageGcDrawer imageGcDrawer, int width, int height)
903903

904904
private ImageData drawWithImageGcDrawer(ImageGcDrawer imageGcDrawer, int width, int height, int zoom) {
905905
int gcStyle = imageGcDrawer.getGcStyle();
906-
Image image;
907906
if ((gcStyle & SWT.TRANSPARENT) != 0) {
908907
/* Create a 24 bit image data with alpha channel */
909908
final ImageData resultData = new ImageData (width, height, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000));
910909
resultData.alphaData = new byte [width * height];
911-
image = new Image(device, resultData);
910+
init(resultData, zoom);
912911
} else {
913-
image = new Image(device, width, height);
912+
init(width, height);
914913
}
915-
GC gc = new GC(image, gcStyle);
914+
GC gc = new GC(Image.this, gcStyle);
916915
try {
917916
imageGcDrawer.drawOn(gc, width, height);
918-
ImageData imageData = image.getImageData(zoom);
917+
ImageData imageData = Image.this.getImageData(zoom);
919918
imageGcDrawer.postProcess(imageData);
920919
return imageData;
921920
} finally {
922921
gc.dispose();
923-
image.dispose();
924922
}
925923
}
926924

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,24 +1169,22 @@ public ImageData getImageData (int zoom) {
11691169

11701170
private ImageData drawWithImageGcDrawer(int width, int height, int zoom) {
11711171
int gcStyle = imageGcDrawer.getGcStyle();
1172-
Image image;
11731172
if ((gcStyle & SWT.TRANSPARENT) != 0) {
11741173
/* Create a 24 bit image data with alpha channel */
11751174
final ImageData resultData = new ImageData(width, height, 24, new PaletteData (0xFF, 0xFF00, 0xFF0000));
11761175
resultData.alphaData = new byte [width * height];
1177-
image = new Image(device, resultData, zoom);
1176+
init(resultData, zoom);
11781177
} else {
1179-
image = new Image(device, width, height);
1178+
init(width, height);
11801179
}
1181-
GC gc = new GC(image, gcStyle);
1180+
GC gc = new GC(Image.this, gcStyle);
11821181
try {
11831182
imageGcDrawer.drawOn(gc, width, height);
1184-
ImageData imageData = image.getImageData(zoom);
1183+
ImageData imageData = Image.this.getImageData(zoom);
11851184
imageGcDrawer.postProcess(imageData);
11861185
return imageData;
11871186
} finally {
11881187
gc.dispose();
1189-
image.dispose();
11901188
}
11911189
}
11921190

0 commit comments

Comments
 (0)