comparison dwt/dnd/ImageTransfer.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 1a8b3cb347e0
children a9ab4c738ed8
comparison
equal deleted inserted replaced
6:b903c16b6f48 7:e831403a80a9
70 if (!checkImage(object) || !isSupportedType(transferData)) { 70 if (!checkImage(object) || !isSupportedType(transferData)) {
71 DND.error(DND.ERROR_INVALID_DATA); 71 DND.error(DND.ERROR_INVALID_DATA);
72 } 72 }
73 transferData.result = -1; 73 transferData.result = -1;
74 74
75 ImageData imgData = (ImageData) object; 75 ImageData imgData = cast(ImageData) object;
76 Image image = new Image(Display.getCurrent(), imgData); 76 Image image = new Image(Display.getCurrent(), imgData);
77 int handle = image.handle; 77 int handle = image.handle;
78 int width = OS.CGImageGetWidth(handle); 78 int width = OS.CGImageGetWidth(handle);
79 int height = OS.CGImageGetHeight(handle); 79 int height = OS.CGImageGetHeight(handle);
80 int alphaInfo = OS.CGImageGetAlphaInfo(handle); 80 int alphaInfo = OS.CGImageGetAlphaInfo(handle);
81 int bpr = OS.CGImageGetBytesPerRow(handle); 81 int bpr = OS.CGImageGetBytesPerRow(handle);
82 82
83 Rect rect = new Rect(); 83 Rect rect = new Rect();
84 rect.left = 0; 84 rect.left = 0;
85 rect.top = 0; 85 rect.top = 0;
86 rect.right = (short) width; 86 rect.right = cast(short) width;
87 rect.bottom = (short) height; 87 rect.bottom = cast(short) height;
88 88
89 int[] gWorld = new int[1]; 89 int[] gWorld = new int[1];
90 int format = OS.k24RGBPixelFormat; 90 int format = OS.k24RGBPixelFormat;
91 if (alphaInfo !is OS.kCGImageAlphaNoneSkipFirst) { 91 if (alphaInfo !is OS.kCGImageAlphaNoneSkipFirst) {
92 format = OS.k32ARGBPixelFormat; 92 format = OS.k32ARGBPixelFormat;
96 int[] curGWorld = new int[1]; 96 int[] curGWorld = new int[1];
97 OS.GetGWorld(curPort, curGWorld); 97 OS.GetGWorld(curPort, curGWorld);
98 OS.SetGWorld(gWorld[0], curGWorld[0]); 98 OS.SetGWorld(gWorld[0], curGWorld[0]);
99 int pictHandle = OS.OpenPicture(rect); 99 int pictHandle = OS.OpenPicture(rect);
100 int portBitMap = OS.GetPortBitMapForCopyBits(gWorld[0]); 100 int portBitMap = OS.GetPortBitMapForCopyBits(gWorld[0]);
101 OS.CopyBits(portBitMap, portBitMap, rect, rect, (short) OS.srcCopy, 0); 101 OS.CopyBits(portBitMap, portBitMap, rect, rect, cast(short) OS.srcCopy, 0);
102 OS.ClosePicture(); 102 OS.ClosePicture();
103 OS.SetGWorld(curPort[0], curGWorld[0]); 103 OS.SetGWorld(curPort[0], curGWorld[0]);
104 OS.DisposeGWorld(gWorld[0]); 104 OS.DisposeGWorld(gWorld[0]);
105 int length = OS.GetHandleSize(pictHandle); 105 int length = OS.GetHandleSize(pictHandle);
106 OS.HLock(pictHandle); 106 OS.HLock(pictHandle);
140 if (dataProvider !is 0) { 140 if (dataProvider !is 0) {
141 int pictDataRef = OS.QDPictCreateWithProvider(dataProvider); 141 int pictDataRef = OS.QDPictCreateWithProvider(dataProvider);
142 // get bounds for the image 142 // get bounds for the image
143 CGRect rect = new CGRect(); 143 CGRect rect = new CGRect();
144 OS.QDPictGetBounds(pictDataRef, rect); 144 OS.QDPictGetBounds(pictDataRef, rect);
145 int width = (int) rect.width; 145 int width = cast(int) rect.width;
146 int height = (int) rect.height; 146 int height = cast(int) rect.height;
147 147
148 /* Create the image */ 148 /* Create the image */
149 int bpr = width * 4; 149 int bpr = width * 4;
150 int dataSize = height * bpr; 150 int dataSize = height * bpr;
151 int data = OS.NewPtr(dataSize); 151 int data = OS.NewPtr(dataSize);