Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSBitmapImageRep.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSBitmapImageRep; | |
15 | |
16 import dwt.internal.cocoa.CGFloat; | |
17 import dwt.internal.cocoa.id; | |
18 import dwt.internal.cocoa.NSArray; | |
19 import dwt.internal.cocoa.NSData; | |
20 import dwt.internal.cocoa.NSDictionary; | |
21 import dwt.internal.cocoa.NSImageRep; | |
22 import dwt.internal.cocoa.NSInteger; | |
23 import dwt.internal.cocoa.NSRect; | |
24 import dwt.internal.cocoa.NSString; | |
25 import dwt.internal.cocoa.OS; | |
26 import objc = dwt.internal.objc.runtime; | |
27 | |
28 enum NSTIFFCompression | |
29 { | |
30 NSTIFFCompressionNone = 1, | |
31 NSTIFFCompressionCCITTFAX3 = 3, | |
32 NSTIFFCompressionCCITTFAX4 = 4, | |
33 NSTIFFCompressionLZW = 5, | |
34 NSTIFFCompressionJPEG = 6, | |
35 NSTIFFCompressionNEXT = 32766, | |
36 NSTIFFCompressionPackBits = 32773, | |
37 NSTIFFCompressionOldJPEG = 32865 | |
38 } | |
39 | |
40 enum NSBitmapFormat | |
41 { | |
42 NSAlphaFirstBitmapFormat = 1 << 0, | |
43 NSAlphaNonpremultipliedBitmapFormat = 1 << 1, | |
44 NSFloatingPointSamplesBitmapFormat = 1 << 2 | |
45 } | |
46 | |
47 public class NSBitmapImageRep : NSImageRep | |
48 { | |
49 public this () | |
50 { | |
51 super(); | |
52 } | |
53 | |
54 public this (objc.id id) | |
55 { | |
56 super(id); | |
57 } | |
58 | |
59 public objc.id CGImage () | |
60 { | |
61 return OS.objc_msgSend(this.id, OS.sel_CGImage); | |
62 } | |
63 | |
64 public NSData TIFFRepresentation () | |
65 { | |
66 objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation); | |
67 return result !is null ? new NSData(result) : null; | |
68 } | |
69 | |
70 public static NSData static_TIFFRepresentationOfImageRepsInArray_ (NSArray array) | |
71 { | |
72 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1, array !is null ? array.id : null); | |
73 return result !is null ? new NSData(result) : null; | |
74 } | |
75 | |
76 public static NSData static_TIFFRepresentationOfImageRepsInArray_usingCompression_factor_ (NSArray array, objc.id comp, float factor) | |
77 { | |
78 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1usingCompression_1factor_1, | |
79 array !is null ? array.id : null, comp, factor); | |
80 return result !is null ? new NSData(result) : null; | |
81 } | |
82 | |
83 public NSData TIFFRepresentationUsingCompression (objc.id comp, float factor) | |
84 { | |
85 objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, factor); | |
86 return result !is null ? new NSData(result) : null; | |
87 } | |
88 | |
89 public objc.id bitmapData () | |
90 { | |
91 return OS.objc_msgSend(this.id, OS.sel_bitmapData); | |
92 } | |
93 | |
94 public objc.id bitmapFormat () | |
95 { | |
96 return OS.objc_msgSend(this.id, OS.sel_bitmapFormat); | |
97 } | |
98 | |
99 public NSInteger bitsPerPixel () | |
100 { | |
101 return OS.objc_msgSend(this.id, OS.sel_bitsPerPixel); | |
102 } | |
103 | |
104 public NSInteger bytesPerPlane () | |
105 { | |
106 return OS.objc_msgSend(this.id, OS.sel_bytesPerPlane); | |
107 } | |
108 | |
109 public NSInteger bytesPerRow () | |
110 { | |
111 return OS.objc_msgSend(this.id, OS.sel_bytesPerRow); | |
112 } | |
113 | |
114 public bool canBeCompressedUsing (objc.id compression) | |
115 { | |
116 return OS.objc_msgSend(this.id, OS.sel_canBeCompressedUsing_1, compression) !is null; | |
117 } | |
118 | |
119 public NSColor colorAtX (NSInteger x, NSInteger y) | |
120 { | |
121 objc.id result = OS.objc_msgSend(this.id, OS.sel_colorAtX_1y_1, x, y); | |
122 return result !is null ? new NSColor(result) : null; | |
123 } | |
124 | |
125 public void colorizeByMappingGray (CGFloat midPoint, NSColor midPointColor, NSColor shadowColor, NSColor lightColor) | |
126 { | |
127 OS.objc_msgSend(this.id, OS.sel_colorizeByMappingGray_1toColor_1blackMapping_1whiteMapping_1, midPoint, | |
128 midPointColor !is null ? midPointColor.id : null, shadowColor !is null ? shadowColor.id : null, | |
129 lightColor !is null ? lightColor.id : null); | |
130 } | |
131 | |
132 public void getBitmapDataPlanes (objc.id data) | |
133 { | |
134 OS.objc_msgSend(this.id, OS.sel_getBitmapDataPlanes_1, data); | |
135 } | |
136 | |
137 public void getCompression (NSTIFFCompression* compression, float* factor) | |
138 { | |
139 OS.objc_msgSend(this.id, OS.sel_getCompression_1factor_1, compression, factor); | |
140 } | |
141 | |
142 public void getPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y) | |
143 { | |
144 OS.objc_msgSend(this.id, OS.sel_getPixel_1atX_1y_1, p, x, y); | |
145 } | |
146 | |
147 public static void getTIFFCompressionTypes (/*const*/NSTIFFCompression** list, NSInteger* numTypes) | |
148 { | |
149 OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_getTIFFCompressionTypes_1count_1, list, numTypes); | |
150 } | |
151 | |
152 public static id imageRepWithData (NSData data) | |
153 { | |
154 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepWithData_1, data !is null ? data.id : null); | |
155 return result !is null ? new id(result) : null; | |
156 } | |
157 | |
158 public static NSArray imageRepsWithData (NSData data) | |
159 { | |
160 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepsWithData_1, data !is null ? data.id : null); | |
161 return result !is null ? new NSArray(result) : null; | |
162 } | |
163 | |
164 public NSInteger incrementalLoadFromData (NSData data, bool complete) | |
165 { | |
166 return OS.objc_msgSend(this.id, OS.sel_incrementalLoadFromData_1complete_1, data !is null ? data.id : null, complete); | |
167 } | |
168 | |
169 public NSBitmapImageRep initForIncrementalLoad () | |
170 { | |
171 objc.id result = OS.objc_msgSend(this.id, OS.sel_initForIncrementalLoad); | |
172 return result !is null ? this : null; | |
173 } | |
174 | |
175 public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_ ( | |
176 ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, | |
177 NSBitmapFormat bitmapFormat, NSInteger rBytes, NSInteger pBits) | |
178 { | |
179 objc.id | |
180 result = OS.objc_msgSend( | |
181 this.id, | |
182 OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bitmapFormat_1bytesPerRow_1bitsPerPixel_1, | |
183 planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, bitmapFormat, rBytes, | |
184 pBits); | |
185 return result !is null ? this : null; | |
186 } | |
187 | |
188 public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( | |
189 ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSInteger rBytes, NSInteger pBits) | |
190 { | |
191 objc.id | |
192 result = OS.objc_msgSend( | |
193 this.id, | |
194 OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bytesPerRow_1bitsPerPixel_1, | |
195 planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, rBytes, pBits); | |
196 return result !is null ? this : null; | |
197 } | |
198 | |
199 public NSBitmapImageRep initWithCGImage (objc.id cgImage) | |
200 { | |
201 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCGImage_1, cgImage); | |
202 return result !is null ? this : null; | |
203 } | |
204 | |
205 public NSBitmapImageRep initWithCIImage (CIImage ciImage) | |
206 { | |
207 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCIImage_1, ciImage !is null ? ciImage.id : null); | |
208 return result !is null ? this : null; | |
209 } | |
210 | |
211 public NSBitmapImageRep initWithData (NSData data) | |
212 { | |
213 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null); | |
214 return result !is null ? this : null; | |
215 } | |
216 | |
217 public NSBitmapImageRep initWithFocusedViewRect (NSRect rect) | |
218 { | |
219 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFocusedViewRect_1, rect); | |
220 return result !is null ? this : null; | |
221 } | |
222 | |
223 public bool isPlanar () | |
224 { | |
225 return OS.objc_msgSend(this.id, OS.sel_isPlanar) !is null; | |
226 } | |
227 | |
228 public static NSString localizedNameForTIFFCompressionType (objc.id compression) | |
229 { | |
230 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_localizedNameForTIFFCompressionType_1, compression); | |
231 return result !is null ? new NSString(result) : null; | |
232 } | |
233 | |
234 public NSInteger numberOfPlanes () | |
235 { | |
236 return OS.objc_msgSend(this.id, OS.sel_numberOfPlanes); | |
237 } | |
238 | |
239 public static NSData representationOfImageRepsInArray (NSArray imageReps, objc.id storageType, NSDictionary properties) | |
240 { | |
241 objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_representationOfImageRepsInArray_1usingType_1properties_1, | |
242 imageReps !is null ? imageReps.id : null, storageType, properties !is null ? properties.id : null); | |
243 return result !is null ? new NSData(result) : null; | |
244 } | |
245 | |
246 public NSData representationUsingType (objc.id storageType, NSDictionary properties) | |
247 { | |
248 objc.id result = OS.objc_msgSend(this.id, OS.sel_representationUsingType_1properties_1, storageType, | |
249 properties !is null ? properties.id : null); | |
250 return result !is null ? new NSData(result) : null; | |
251 } | |
252 | |
253 public NSInteger samplesPerPixel () | |
254 { | |
255 return OS.objc_msgSend(this.id, OS.sel_samplesPerPixel); | |
256 } | |
257 | |
258 public void setColor (NSColor color, NSInteger x, NSInteger y) | |
259 { | |
260 OS.objc_msgSend(this.id, OS.sel_setColor_1atX_1y_1, color !is null ? color.id : null, x, y); | |
261 } | |
262 | |
263 public void setCompression (NSTIFFCompression compression, float factor) | |
264 { | |
265 OS.objc_msgSend(this.id, OS.sel_setCompression_1factor_1, compression, factor); | |
266 } | |
267 | |
268 public void setPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y) | |
269 { | |
270 OS.objc_msgSend(this.id, OS.sel_setPixel_1atX_1y_1, p, x, y); | |
271 } | |
272 | |
273 public void setProperty (NSString property, id value) | |
274 { | |
275 OS.objc_msgSend(this.id, OS.sel_setProperty_1withValue_1, property !is null ? property.id : null, value !is null ? value.id : null); | |
276 } | |
277 | |
278 public id valueForProperty (NSString property) | |
279 { | |
280 objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForProperty_1, property !is null ? property.id : null); | |
281 return result !is null ? new id(result) : null; | |
282 } | |
283 } |