diff dwt/graphics/Image.d @ 46:cfa563df4fdd

Updated Widget and Display to 3.514
author Jacob Carlborg <doob@me.com>
date Fri, 05 Dec 2008 16:00:41 +0100
parents d8635bb48c7c
children ad4e1fe71a5a
line wrap: on
line diff
--- a/dwt/graphics/Image.d	Mon Dec 01 17:07:00 2008 +0100
+++ b/dwt/graphics/Image.d	Fri Dec 05 16:00:41 2008 +0100
@@ -43,7 +43,7 @@
 import dwt.graphics.RGB;
 import dwt.graphics.Rectangle;
 import dwt.graphics.Resource;
-import dwt.internal.cocoa.NSInteger;
+import dwt.internal.objc.cocoa.Cocoa;
 import objc = dwt.internal.objc.runtime;
  
 /**
@@ -251,7 +251,7 @@
     }
 
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         device = this.device;
         this.type = srcImage.type;
@@ -274,7 +274,7 @@
     handle = cast(NSImage)(new NSImage()).alloc();
         handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-    rep = rep.initWithBitmapDataPlanes(null, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
+    rep = rep.initWithBitmapDataPlanes(null, width, height, srcRep.bitsPerSample(), srcRep.samplesPerPixel(), srcRep.samplesPerPixel() is 4, srcRep.isPlanar(), OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, srcRep.bytesPerRow(), srcRep.bitsPerPixel());
         handle.addRepresentation(rep);
 
     objc.id data = rep.bitmapData();
@@ -294,7 +294,7 @@
                 byte oneRed = cast(byte)oneRGB.red;
                 byte oneGreen = cast(byte)oneRGB.green;
                 byte oneBlue = cast(byte)oneRGB.blue;
-                byte[] line = new byte[(int)/*64*/bpr];
+                byte[] line = new byte[bpr];
                 for (int y=0; y<height; y++) {
                     OS.memmove(line.ptr, data + (y * bpr), bpr);
                     int offset = 0;
@@ -319,7 +319,7 @@
                 break;
             }
             case DWT.IMAGE_GRAY: {          
-                byte[] line = new byte[(int)/*64*/bpr];
+                byte[] line = new byte[bpr];
                 for (int y=0; y<height; y++) {
                     OS.memmove(line.ptr, data + (y * bpr), bpr);
                     int offset = 0;
@@ -377,7 +377,7 @@
     super(device);
     if (bounds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         init_(bounds.width, bounds.height);
         init_();
@@ -407,7 +407,7 @@
 public this(Device device, ImageData data) {
     super(device);
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         init_(data);
         init_();
@@ -449,7 +449,7 @@
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         mask = ImageData.convertMask(mask);
         ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data);
@@ -563,7 +563,7 @@
 void createAlpha () {
     if (transparentPixel is -1 && alpha is -1 && alphaData is null) return;
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         NSSize size = handle.size();
     int height = cast(int)size.height;
@@ -669,7 +669,7 @@
 public Rectangle getBounds() {
     if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         if (width !is -1 && height !is -1) {
             return new Rectangle(0, 0, width, height);
@@ -698,7 +698,7 @@
 public ImageData getImageData() {
     if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         NSSize size = handle.size();
     int width = cast(int)size.width;
@@ -711,8 +711,8 @@
     OS.memmove(srcData.ptr, imageRep.bitmapData(), dataSize);
 
         PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);
-        ImageData data = new ImageData(width, height, (int)/*64*/bpp, palette, 4, srcData);
-        data.bytesPerLine = (int)/*64*/bpr;
+        ImageData data = new ImageData(width, height, cast(int)/*64*/bpp, palette, 4, srcData);
+        data.bytesPerLine = cast(int)/*64*/bpr;
 
         data.transparentPixel = transparentPixel;
         if (transparentPixel is -1 && type is DWT.ICON) {
@@ -771,12 +771,12 @@
     image.type = type;
     image.handle = nsImage;
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         NSImageRep rep = nsImage.bestRepresentationForDevice(null);
-        if (rep.isKindOfClass(OS.class_NSBitmapImageRep)) { 
+        if (rep.isKindOfClass(cast(objc.Class)OS.class_NSBitmapImageRep)) { 
             rep.retain();
-            image.imageRep = new NSBitmapImageRep(rep.id_);
+            image.imageRep = new NSBitmapImageRep(rep.id);
         }
         return image;
     } finally {
@@ -795,7 +795,7 @@
  * @see #equals
  */
 public hash_t toHash () {
-    return handle !is null ? cast(hash_t) handle.id_ : 0;
+    return handle !is null ? cast(hash_t) handle.id : 0;
 }
 
 alias toHash hashCode;
@@ -814,7 +814,7 @@
     size.height = height;
     handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-    rep = rep.initWithBitmapDataPlanes_(null, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
+    rep = rep.initWithBitmapDataPlanes(null, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, width * 4, 32);
     OS.memset(rep.bitmapData(), 0xFF, cast(size_t) (width * height * 4));
     handle.addRepresentation(rep);
 //  rep.release();
@@ -923,7 +923,7 @@
     size.height = height;
     handle = handle.initWithSize(size);
     NSBitmapImageRep rep = imageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
-    rep = rep.initWithBitmapDataPlanes(0, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32);
+    rep = rep.initWithBitmapDataPlanes(null, width, height, 8, hasAlpha ? 4 : 3, hasAlpha, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, bpr, 32);
     OS.memmove(rep.bitmapData(), buffer.ptr, dataSize); 
     handle.addRepresentation(rep);
 //  rep.release();
@@ -948,7 +948,7 @@
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
     NSAutoreleasePool pool = null;
-    if (!NSThread.isMainThread()) pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
+    if (!NSThread.isMainThread()) pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
     try {
         NSBitmapImageRep rep = imageRep;
         if (imageRep.hasAlpha()) {
@@ -958,7 +958,7 @@
         if (data.bitmapDataAddress !is null) OS.free(data.bitmapDataAddress);
         data.bitmapDataAddress = cast(ubyte*) OS.malloc(C.PTR_SIZEOF);
         OS.memmove(data.bitmapDataAddress, bitmapData, C.PTR_SIZEOF);
-            rep = rep.initWithBitmapDataPlanes(data.bitmapDataAddress, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat , bpr, 32);
+            rep = rep.initWithBitmapDataPlanes(&data.bitmapDataAddress, width, height, 8, 3, false, false, OS.NSDeviceRGBColorSpace, OS.NSAlphaFirstBitmapFormat , bpr, 32);
             rep.autorelease();
         }
         handle.setCacheMode(OS.NSImageCacheNever);
@@ -980,7 +980,7 @@
             data.font = device.systemFont;
             data.image = this;
         }
-    return context.id_;
+    return context.id;
     } finally {
         if (pool !is null) pool.release();
     }