diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java index 9227e6d1dc6..ea30b25694b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java @@ -154,25 +154,6 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int this.device.registerResourceWithZoomSupport(this); } -private static CursorHandle setupCursorFromImageData(ImageData source, ImageData mask, int hotspotX, int hotspotY) { - if (mask == null) { - mask = source.getTransparencyMask(); - } - /* Convert depth to 1 */ - mask = ImageData.convertMask(mask); - source = ImageData.convertMask(source); - - /* Make sure source and mask scanline pad is 2 */ - byte[] sourceData = ImageData.convertPad(source.data, source.width, source.height, source.depth, source.scanlinePad, 2); - byte[] maskData = ImageData.convertPad(mask.data, mask.width, mask.height, mask.depth, mask.scanlinePad, 2); - - /* Create the cursor */ - long hInst = OS.GetModuleHandle(null); - long handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData, maskData); - if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES); - return new CustomCursorHandle(handle); -} - /** * Constructs a new cursor given a device, image data describing * the desired cursor appearance, and the x and y coordinates of @@ -209,7 +190,7 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) { this.device.registerResourceWithZoomSupport(this); } -private static CursorHandle setupCursorFromImageData(Device device, ImageData source, int hotspotX, int hotspotY) { +private static CursorHandle setupCursorFromImageData(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); long hBitmap = 0; long hMask = 0; @@ -258,7 +239,9 @@ private static CursorHandle setupCursorFromImageData(Device device, ImageData so hMask = OS.CreateBitmap(source.width, source.height, 1, 1, new byte[(((source.width + 7) / 8) + 3) / 4 * 4 * source.height]); if (hMask == 0) SWT.error(SWT.ERROR_NO_HANDLES); } else { - ImageData mask = source.getTransparencyMask(); + if (mask == null) { + mask = source.getTransparencyMask(); + } long [] result = Image.initIcon(device, source, mask); hBitmap = result[0]; hMask = result[1]; @@ -649,7 +632,7 @@ public CursorHandle createHandle(Device device, int zoom) { source = tempImage.getImageData(zoom); tempImage.dispose(); } - return setupCursorFromImageData(device, source, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom)); + return setupCursorFromImageData(device, source, null, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom)); } } @@ -667,7 +650,7 @@ public ImageDataCursorHandleProvider(ImageData source, int hotspotX, int hotspot public CursorHandle createHandle(Device device, int zoom) { int accessibilityFactor = getPointerSizeScaleFactor(); ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom * accessibilityFactor, DEFAULT_ZOOM); - return setupCursorFromImageData(device, scaledSource, getHotpotXInPixels(zoom), + return setupCursorFromImageData(device, scaledSource, null, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom)); } } @@ -697,10 +680,12 @@ private void validateMask(ImageData source, ImageData mask) { @Override public CursorHandle createHandle(Device device, int zoom) { - ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom, DEFAULT_ZOOM); - ImageData scaledMask = this.mask != null ? DPIUtil.scaleImageData(device, mask, zoom, DEFAULT_ZOOM) + ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, getPointerSizeScaleFactor() * zoom, DEFAULT_ZOOM); + ImageData scaledMask = this.mask != null ? DPIUtil.scaleImageData(device, mask, getPointerSizeScaleFactor() * zoom, DEFAULT_ZOOM) : null; - return setupCursorFromImageData(scaledSource, scaledMask, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom)); + + return setupCursorFromImageData(device, scaledSource, scaledMask, getHotpotXInPixels(zoom), + getHotpotYInPixels(zoom)); } }