diff dwt/graphics/Image.d @ 36:db5a898b2119

Fixed a lot of compile errors
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 07 Oct 2008 12:56:18 +0200
parents 7d135fe0caf2
children d8635bb48c7c
line wrap: on
line diff
--- a/dwt/graphics/Image.d	Sun Sep 14 23:32:29 2008 +0200
+++ b/dwt/graphics/Image.d	Tue Oct 07 12:56:18 2008 +0200
@@ -93,6 +93,8 @@
  */
 public final class Image : Resource, Drawable {
 
+    alias Resource.init_ init_;
+    
     /**
      * specifies whether the receiver is a bitmap or an icon
      * (one of <code>DWT.BITMAP</code>, <code>DWT.ICON</code>)
@@ -189,8 +191,8 @@
  */
 public this(Device device, int width, int height) {
     super(device);
-    init(width, height);
-    init();
+    init_(width, height);
+    init_();
 }
 
 /**
@@ -258,7 +260,7 @@
     handle = cast(NSImage)(new NSImage()).alloc();
     handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(null, cast(NSInteger) width, cast(NSInteger) height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
+    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(null, cast(NSInteger) width, cast(NSInteger) height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
     handle.addRepresentation(rep);
     
     objc.id data = rep.bitmapData();
@@ -321,7 +323,7 @@
             }
         }
     }
-    init();
+    init_();
 }
 
 /**
@@ -357,8 +359,8 @@
 public this(Device device, Rectangle bounds) {
     super(device);
     if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    init(bounds.width, bounds.height);
-    init();
+    init_(bounds.width, bounds.height);
+    init_();
 }
 
 /**
@@ -381,8 +383,8 @@
  */
 public this(Device device, ImageData data) {
     super(device);
-    init(data);
-    init();
+    init_(data);
+    init_();
 }
 
 /**
@@ -421,7 +423,7 @@
     ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
     image.maskPad = mask.scanlinePad;
     image.maskData = mask.data;
-    init(image);
+    init_(image);
 }
 
 /**
@@ -474,8 +476,8 @@
  */
 public this(Device device, InputStream stream) {
     super(device);
-    init(new ImageData(stream));
-    init();
+    init_(new ImageData(stream));
+    init_();
 }
 
 /**
@@ -507,8 +509,8 @@
  */
 public this(Device device, String filename) {
     super(device);
-    init(new ImageData(filename));
-    init();
+    init_(new ImageData(filename));
+    init_();
 }
 
 void createAlpha () {
@@ -596,7 +598,7 @@
     int red = (transparentPixel >> 16) & 0xFF;
     int green = (transparentPixel >> 8) & 0xFF;
     int blue = (transparentPixel >> 0) & 0xFF;
-    return Color.cocoa_new(device, new float[][red / 255f, green / 255f, blue / 255f, 1]);
+    return Color.cocoa_new(device, [red / 255f, green / 255f, blue / 255f, 1]);
 }
 
 /**
@@ -723,12 +725,12 @@
  * @see #equals
  */
 public hash_t toHash () {
-    return handle !is null ? handle.id_ : null;
+    return handle !is null ? cast(hash_t) handle.id_ : 0;
 }
 
 alias toHash hashCode;
 
-void init(int width, int height) {
+void init_(int width, int height) {
     if (width <= 0 || height <= 0) {
         DWT.error (DWT.ERROR_INVALID_ARGUMENT);
     }
@@ -742,13 +744,13 @@
     size.height = height;
     handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(0, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4), 32);
+    rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(null, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4), 32);
     OS.memset(rep.bitmapData(), 0xFF, cast(size_t) (width * height * 4));
     handle.addRepresentation(rep);
 //  rep.release();
 }
 
-void init(ImageData image) {
+void init_(ImageData image) {
     if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     this.width = image.width;
     this.height = image.height;
@@ -852,7 +854,7 @@
     handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
     rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
-            null, cast(NSInteger) width, cast(NSInteger) height, 8, hasAlpha ? 4 : 3, hasAlpha, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) bpr, 32);
+            null, cast(NSInteger) width, cast(NSInteger) height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) bpr, 32);
     OS.memmove(rep.bitmapData(), buffer.ptr, dataSize); 
     handle.addRepresentation(rep);
 //  rep.release();
@@ -871,7 +873,7 @@
  * @param data the platform specific GC data 
  * @return the platform specific GC handle
  */
-public int internal_new_GC (GCData data) {
+public objc.id internal_new_GC (GCData data) {
     if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (type !is DWT.BITMAP || memGC !is null) {
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
@@ -881,12 +883,12 @@
     if (imageRep.hasAlpha()) {
         NSInteger bpr = width * 4;
         rep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-        int bitmapData = imageRep.bitmapData();
+        objc.id bitmapData = imageRep.bitmapData();
         if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
-        data.bitmapDataAddress = OS.malloc((void*).sizeof);
-        OS.memmove(data.bitmapDataAddress, (new int[] (bitmapData)).ptr, (void*).sizeof);
+        data.bitmapDataAddress = cast(ubyte*) OS.malloc((void*).sizeof);
+        OS.memmove(data.bitmapDataAddress, bitmapData, (void*).sizeof);
         rep = rep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(
-                &data.bitmapDataAddress, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, new NSString(OS.NSDeviceRGBColorSpace()), OS.NSAlphaFirstBitmapFormat , bpr, 32);
+                &data.bitmapDataAddress, cast(NSInteger) width, cast(NSInteger) height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat , bpr, 32);
         rep.autorelease();
     }
     NSGraphicsContext context = NSGraphicsContext.graphicsContextWithBitmapImageRep(rep);
@@ -908,7 +910,7 @@
         data.image = this;
     }
     NSGraphicsContext.setCurrentContext(current);
-    return context.id;
+    return context.id_;
 }
 
 /**  
@@ -924,7 +926,7 @@
  * @param hDC the platform specific GC handle
  * @param data the platform specific GC data 
  */
-public void internal_dispose_GC (int context, GCData data) {
+public void internal_dispose_GC (objc.id context, GCData data) {
     if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
     data.bitmapDataAddress = null;
 }