Mercurial > projects > dwt-mac
view 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 |
line wrap: on
line source
/******************************************************************************* * Copyright (c) 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * * Port to the D Programming language: * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.internal.cocoa.NSBitmapImageRep; import dwt.internal.cocoa.CGFloat; import dwt.internal.cocoa.id; import dwt.internal.cocoa.NSArray; import dwt.internal.cocoa.NSData; import dwt.internal.cocoa.NSDictionary; import dwt.internal.cocoa.NSImageRep; import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSRect; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; import objc = dwt.internal.objc.runtime; enum NSTIFFCompression { NSTIFFCompressionNone = 1, NSTIFFCompressionCCITTFAX3 = 3, NSTIFFCompressionCCITTFAX4 = 4, NSTIFFCompressionLZW = 5, NSTIFFCompressionJPEG = 6, NSTIFFCompressionNEXT = 32766, NSTIFFCompressionPackBits = 32773, NSTIFFCompressionOldJPEG = 32865 } enum NSBitmapFormat { NSAlphaFirstBitmapFormat = 1 << 0, NSAlphaNonpremultipliedBitmapFormat = 1 << 1, NSFloatingPointSamplesBitmapFormat = 1 << 2 } public class NSBitmapImageRep : NSImageRep { public this () { super(); } public this (objc.id id) { super(id); } public objc.id CGImage () { return OS.objc_msgSend(this.id, OS.sel_CGImage); } public NSData TIFFRepresentation () { objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentation); return result !is null ? new NSData(result) : null; } public static NSData static_TIFFRepresentationOfImageRepsInArray_ (NSArray array) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1, array !is null ? array.id : null); return result !is null ? new NSData(result) : null; } public static NSData static_TIFFRepresentationOfImageRepsInArray_usingCompression_factor_ (NSArray array, objc.id comp, float factor) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_TIFFRepresentationOfImageRepsInArray_1usingCompression_1factor_1, array !is null ? array.id : null, comp, factor); return result !is null ? new NSData(result) : null; } public NSData TIFFRepresentationUsingCompression (objc.id comp, float factor) { objc.id result = OS.objc_msgSend(this.id, OS.sel_TIFFRepresentationUsingCompression_1factor_1, comp, factor); return result !is null ? new NSData(result) : null; } public objc.id bitmapData () { return OS.objc_msgSend(this.id, OS.sel_bitmapData); } public objc.id bitmapFormat () { return OS.objc_msgSend(this.id, OS.sel_bitmapFormat); } public NSInteger bitsPerPixel () { return OS.objc_msgSend(this.id, OS.sel_bitsPerPixel); } public NSInteger bytesPerPlane () { return OS.objc_msgSend(this.id, OS.sel_bytesPerPlane); } public NSInteger bytesPerRow () { return OS.objc_msgSend(this.id, OS.sel_bytesPerRow); } public bool canBeCompressedUsing (objc.id compression) { return OS.objc_msgSend(this.id, OS.sel_canBeCompressedUsing_1, compression) !is null; } public NSColor colorAtX (NSInteger x, NSInteger y) { objc.id result = OS.objc_msgSend(this.id, OS.sel_colorAtX_1y_1, x, y); return result !is null ? new NSColor(result) : null; } public void colorizeByMappingGray (CGFloat midPoint, NSColor midPointColor, NSColor shadowColor, NSColor lightColor) { OS.objc_msgSend(this.id, OS.sel_colorizeByMappingGray_1toColor_1blackMapping_1whiteMapping_1, midPoint, midPointColor !is null ? midPointColor.id : null, shadowColor !is null ? shadowColor.id : null, lightColor !is null ? lightColor.id : null); } public void getBitmapDataPlanes (objc.id data) { OS.objc_msgSend(this.id, OS.sel_getBitmapDataPlanes_1, data); } public void getCompression (NSTIFFCompression* compression, float* factor) { OS.objc_msgSend(this.id, OS.sel_getCompression_1factor_1, compression, factor); } public void getPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y) { OS.objc_msgSend(this.id, OS.sel_getPixel_1atX_1y_1, p, x, y); } public static void getTIFFCompressionTypes (/*const*/NSTIFFCompression** list, NSInteger* numTypes) { OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_getTIFFCompressionTypes_1count_1, list, numTypes); } public static id imageRepWithData (NSData data) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepWithData_1, data !is null ? data.id : null); return result !is null ? new id(result) : null; } public static NSArray imageRepsWithData (NSData data) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_imageRepsWithData_1, data !is null ? data.id : null); return result !is null ? new NSArray(result) : null; } public NSInteger incrementalLoadFromData (NSData data, bool complete) { return OS.objc_msgSend(this.id, OS.sel_incrementalLoadFromData_1complete_1, data !is null ? data.id : null, complete); } public NSBitmapImageRep initForIncrementalLoad () { objc.id result = OS.objc_msgSend(this.id, OS.sel_initForIncrementalLoad); return result !is null ? this : null; } public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_ ( ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSBitmapFormat bitmapFormat, NSInteger rBytes, NSInteger pBits) { objc.id result = OS.objc_msgSend( this.id, OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bitmapFormat_1bytesPerRow_1bitsPerPixel_1, planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, bitmapFormat, rBytes, pBits); return result !is null ? this : null; } public NSBitmapImageRep initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_ ( ubyte** planes, NSInteger width, NSInteger height, NSInteger bps, NSInteger spp, bool alpha, bool isPlanar, NSString colorSpaceName, NSInteger rBytes, NSInteger pBits) { objc.id result = OS.objc_msgSend( this.id, OS.sel_initWithBitmapDataPlanes_1pixelsWide_1pixelsHigh_1bitsPerSample_1samplesPerPixel_1hasAlpha_1isPlanar_1colorSpaceName_1bytesPerRow_1bitsPerPixel_1, planes, width, height, bps, spp, alpha, isPlanar, colorSpaceName !is null ? colorSpaceName.id : null, rBytes, pBits); return result !is null ? this : null; } public NSBitmapImageRep initWithCGImage (objc.id cgImage) { objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCGImage_1, cgImage); return result !is null ? this : null; } public NSBitmapImageRep initWithCIImage (CIImage ciImage) { objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithCIImage_1, ciImage !is null ? ciImage.id : null); return result !is null ? this : null; } public NSBitmapImageRep initWithData (NSData data) { objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithData_1, data !is null ? data.id : null); return result !is null ? this : null; } public NSBitmapImageRep initWithFocusedViewRect (NSRect rect) { objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFocusedViewRect_1, rect); return result !is null ? this : null; } public bool isPlanar () { return OS.objc_msgSend(this.id, OS.sel_isPlanar) !is null; } public static NSString localizedNameForTIFFCompressionType (objc.id compression) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_localizedNameForTIFFCompressionType_1, compression); return result !is null ? new NSString(result) : null; } public NSInteger numberOfPlanes () { return OS.objc_msgSend(this.id, OS.sel_numberOfPlanes); } public static NSData representationOfImageRepsInArray (NSArray imageReps, objc.id storageType, NSDictionary properties) { objc.id result = OS.objc_msgSend(OS.class_NSBitmapImageRep, OS.sel_representationOfImageRepsInArray_1usingType_1properties_1, imageReps !is null ? imageReps.id : null, storageType, properties !is null ? properties.id : null); return result !is null ? new NSData(result) : null; } public NSData representationUsingType (objc.id storageType, NSDictionary properties) { objc.id result = OS.objc_msgSend(this.id, OS.sel_representationUsingType_1properties_1, storageType, properties !is null ? properties.id : null); return result !is null ? new NSData(result) : null; } public NSInteger samplesPerPixel () { return OS.objc_msgSend(this.id, OS.sel_samplesPerPixel); } public void setColor (NSColor color, NSInteger x, NSInteger y) { OS.objc_msgSend(this.id, OS.sel_setColor_1atX_1y_1, color !is null ? color.id : null, x, y); } public void setCompression (NSTIFFCompression compression, float factor) { OS.objc_msgSend(this.id, OS.sel_setCompression_1factor_1, compression, factor); } public void setPixel (/*NSUInteger[]*/NSUInteger* p, NSInteger x, NSInteger y) { OS.objc_msgSend(this.id, OS.sel_setPixel_1atX_1y_1, p, x, y); } public void setProperty (NSString property, id value) { OS.objc_msgSend(this.id, OS.sel_setProperty_1withValue_1, property !is null ? property.id : null, value !is null ? value.id : null); } public id valueForProperty (NSString property) { objc.id result = OS.objc_msgSend(this.id, OS.sel_valueForProperty_1, property !is null ? property.id : null); return result !is null ? new id(result) : null; } }