Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -874,13 +874,20 @@ public Image(Device device, ImageGcDrawer imageGcDrawer, int width, int height)
this.imageGcDrawer = imageGcDrawer;
this.width = width;
this.height = height;
ImageData data = drawWithImageGcDrawer(imageGcDrawer, width, height, DPIUtil.getDeviceZoom());
ImageData data = drawWithImageGcDrawer(imageGcDrawer, width, height, 100);
if (data == null) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
NSAutoreleasePool pool = null;
if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
try {
init (data);
init ();
init ();
ImageData data2x = drawWithImageGcDrawer(imageGcDrawer, width, height, 200);
if (data2x != null) {
alphaInfo_200 = new AlphaInfo();
NSBitmapImageRep rep = createRepresentation (data2x, alphaInfo_200);
handle.addRepresentation(rep);
rep.release();
}
} finally {
if (pool != null) pool.release();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,8 +759,8 @@ public void test_getBounds() {
@SuppressWarnings("deprecation")
@Test
public void test_getBoundsInPixels() {
Rectangle bounds = new Rectangle(0, 0, 10, 20);
Image image = new Image(display, bounds.width, bounds.height);
Rectangle initialBounds = new Rectangle(0, 0, 10, 20);
Image image = new Image(display, initialBounds.width, initialBounds.height);
image.dispose();
try {
image.getBoundsInPixels();
Expand All @@ -770,38 +770,43 @@ public void test_getBoundsInPixels() {
}

// creates bitmap image
image = new Image(display, bounds.width, bounds.height);
image = new Image(display, initialBounds.width, initialBounds.height);
Rectangle boundsInPixels = image.getBoundsInPixels();
Rectangle bounds = image.getBounds();
image.dispose();
assertEquals(":a: Image.getBoundsInPixels method doesn't return bounds in Pixel values.", boundsInPixels, DPIUtil.autoScaleUp(bounds));
assertEquals("Image.getBounds method doesn't return original bounds.", initialBounds, bounds);
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values.", DPIUtil.autoScaleUp(initialBounds), boundsInPixels);

// create icon image
ImageData imageData = new ImageData(bounds.width, bounds.height, 1, new PaletteData(new RGB[] {new RGB(0, 0, 0)}));
ImageData imageData = new ImageData(initialBounds.width, initialBounds.height, 1, new PaletteData(new RGB[] {new RGB(0, 0, 0)}));
image = new Image(display, imageData);
boundsInPixels = image.getBoundsInPixels();
bounds = image.getBounds();
image.dispose();
assertEquals(":b: Image.getBoundsInPixels method doesn't return bounds in Pixel values.", boundsInPixels, DPIUtil.autoScaleUp(bounds));
assertEquals("Image.getBounds method doesn't return original bounds.", initialBounds, bounds);
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values.", DPIUtil.autoScaleUp(initialBounds), boundsInPixels);

// create image with FileNameProvider
image = new Image(display, imageFileNameProvider);
boundsInPixels = image.getBoundsInPixels();
bounds = image.getBounds();
image.dispose();
assertEquals(":c: Image.getBoundsInPixels method doesn't return bounds in Pixel values.", boundsInPixels, DPIUtil.autoScaleUp(bounds));
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values.", DPIUtil.autoScaleUp(bounds), boundsInPixels);

// create image with ImageDataProvider
image = new Image(display, imageDataProvider);
boundsInPixels = image.getBoundsInPixels();
bounds = image.getBounds();
image.dispose();
assertEquals(":d: Image.getBoundsInPixels method doesn't return bounds in Pixel values.", boundsInPixels, DPIUtil.autoScaleUp(bounds));
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values.", DPIUtil.autoScaleUp(bounds), boundsInPixels);

// create image with ImageGcDrawer
image = new Image(display, imageGcDrawer, bounds.width, bounds.height);
image = new Image(display, imageGcDrawer, initialBounds.width, initialBounds.height);
boundsInPixels = image.getBoundsInPixels();
bounds = image.getBounds();
image.dispose();
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values for ImageGcDrawer.", boundsInPixels, DPIUtil.autoScaleUp(bounds));
assertEquals("Image.getBounds method doesn't return original bounds.", initialBounds, bounds);
assertEquals("Image.getBoundsInPixels method doesn't return bounds in Pixel values for ImageGcDrawer.", DPIUtil.autoScaleUp(initialBounds), boundsInPixels);
}

@SuppressWarnings("deprecation")
Expand Down
Loading