changeset 23:f5482da87ed8

Image, ImageData
author Frank Benoit <benoit@tionex.de>
date Sun, 27 Jan 2008 17:43:55 +0100
parents 5f2e72114476
children 7b3e88548661
files dwt/dwthelper/System.d dwt/dwthelper/utils.d dwt/graphics/Color.d dwt/graphics/Device.d dwt/graphics/Font.d dwt/graphics/FontData.d dwt/graphics/FontMetrics.d dwt/graphics/GC.d dwt/graphics/GCData.d dwt/graphics/Image.d dwt/graphics/ImageData.d dwt/graphics/Region.d dwt/graphics/Transform.d dwt/internal/win32/OS.d
diffstat 14 files changed, 234 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dwthelper/System.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/dwthelper/System.d	Sun Jan 27 17:43:55 2008 +0100
@@ -1,4 +1,4 @@
-/**
+/**
  * Authors: Frank Benoit <keinfarbton@googlemail.com>
  */
 module dwt.dwthelper.System;
@@ -9,7 +9,7 @@
     debug{
         static void validCheck(uint SrcLen, uint DestLen, uint copyLen){
             if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){
-                Util.trace("Error : SimpleType.arraycopy(), out of bounds.");
+                //Util.trace("Error : SimpleType.arraycopy(), out of bounds.");
                 assert(0);
             }
         }
--- a/dwt/dwthelper/utils.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/dwthelper/utils.d	Sun Jan 27 17:43:55 2008 +0100
@@ -89,7 +89,7 @@
 }
 
 public void getChars( char[] src, int srcBegin, int srcEnd, char[] dst, int dstBegin){
-    dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = str[ srcBegin .. srcEnd ];
+    dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ];
 }
 
 public bool endsWith( char[] src, char[] pattern ){
--- a/dwt/graphics/Color.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Color.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Color;
 
--- a/dwt/graphics/Device.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Device.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Device;
 
--- a/dwt/graphics/Font.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Font.d	Sun Jan 27 17:43:55 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2006 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
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Font;
 
@@ -18,10 +20,10 @@
 
 import dwt.graphics.Resource;
 import dwt.graphics.FontData;
-import dwt.graphics.Device; 
+import dwt.graphics.Device;
 
 import tango.text.convert.Format;
-//import tango.stdc.stringz; 
+//import tango.stdc.stringz;
 
 /**
  * Instances of this class manage operating system resources that
@@ -29,7 +31,7 @@
  * by providing a device and either name, size and style information
  * or a <code>FontData</code> object which encapsulates this data.
  * <p>
- * Application code must explicitly invoke the <code>Font.dispose()</code> 
+ * Application code must explicitly invoke the <code>Font.dispose()</code>
  * method to release the operating system resources managed by each instance
  * when those instances are no longer required.
  * </p>
@@ -38,7 +40,7 @@
  */
 
 public final class Font : Resource {
-    
+
     /**
      * the handle to the OS font resource
      * (Warning: This field is platform dependent)
@@ -50,23 +52,23 @@
      * </p>
      */
     public HFONT handle;
-    
+
 /**
  * Prevents uninitialized instances from being created outside the package.
  */
 this() {
 }
 
-/**  
+/**
  * Constructs a new font given a device and font data
  * which describes the desired font's appearance.
  * <p>
- * You must dispose the font when it is no longer required. 
+ * You must dispose the font when it is no longer required.
  * </p>
  *
  * @param device the device to create the font on
  * @param fd the FontData that describes the desired font (must not be null)
- * 
+ *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
  *    <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
@@ -79,20 +81,20 @@
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     init(device, fd);
-    if (device.tracking) device.new_Object(this);   
+    if (device.tracking) device.new_Object(this);
 }
 
-/**  
+/**
  * Constructs a new font given a device and an array
  * of font data which describes the desired font's
  * appearance.
  * <p>
- * You must dispose the font when it is no longer required. 
+ * You must dispose the font when it is no longer required.
  * </p>
  *
  * @param device the device to create the font on
  * @param fds the array of FontData that describes the desired font (must not be null)
- * 
+ *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
  *    <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
@@ -102,7 +104,7 @@
  * @exception DWTError <ul>
  *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
  * </ul>
- * 
+ *
  * @since 2.1
  */
 public this(Device device, FontData[] fds) {
@@ -114,22 +116,22 @@
         if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
     init(device, fds[0]);
-    if (device.tracking) device.new_Object(this);   
+    if (device.tracking) device.new_Object(this);
 }
 
-/**  
+/**
  * Constructs a new font given a device, a font name,
  * the height of the desired font in points, and a font
  * style.
  * <p>
- * You must dispose the font when it is no longer required. 
+ * You must dispose the font when it is no longer required.
  * </p>
  *
  * @param device the device to create the font on
  * @param name the name of the font (must not be null)
  * @param height the font height in points
  * @param style a bit or combination of NORMAL, BOLD, ITALIC
- * 
+ *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
  *    <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
@@ -144,7 +146,7 @@
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     init(device, new FontData (name, height, style));
-    if (device.tracking) device.new_Object(this);   
+    if (device.tracking) device.new_Object(this);
 }
 
 /*public*/ this(Device device, char[] name, float height, int style) {
@@ -152,7 +154,7 @@
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     init(device, new FontData (name, height, style));
-    if (device.tracking) device.new_Object(this);   
+    if (device.tracking) device.new_Object(this);
 }
 
 /**
@@ -189,8 +191,8 @@
 
 /**
  * Returns an array of <code>FontData</code>s representing the receiver.
- * On Windows, only one FontData will be returned per font. On X however, 
- * a <code>Font</code> object <em>may</em> be composed of multiple X 
+ * On Windows, only one FontData will be returned per font. On X however,
+ * a <code>Font</code> object <em>may</em> be composed of multiple X
  * fonts. To support this case, we return an array of font data objects.
  *
  * @return an array of font data objects describing the receiver
@@ -207,8 +209,8 @@
 }
 
 /**
- * Returns an integer hash code for the receiver. Any two 
- * objects that return <code>true</code> when passed to 
+ * Returns an integer hash code for the receiver. Any two
+ * objects that return <code>true</code> when passed to
  * <code>equals</code> must return the same value for this
  * method.
  *
@@ -256,7 +258,7 @@
     return Format( "Font {{{}}", handle );
 }
 
-/**  
+/**
  * Invokes platform specific functionality to allocate a new font.
  * <p>
  * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
--- a/dwt/graphics/FontData.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/FontData.d	Sun Jan 27 17:43:55 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 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
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.FontData;
 
@@ -52,7 +54,7 @@
  */
 
 public final class FontData {
-    
+
     /**
      * A Win32 LOGFONT struct
      * (Warning: This field is platform dependent)
@@ -64,7 +66,7 @@
      * </p>
      */
     public LOGFONT data;
-    
+
     /**
      * The height of the font data in points
      * (Warning: This field is platform dependent)
@@ -84,7 +86,7 @@
 
     private static FontData s_this;
 
-/**  
+/**
  * Constructs a new uninitialized font data.
  */
 public this() {
@@ -98,7 +100,7 @@
 /**
  * Constructs a new font data given the Windows <code>LOGFONT</code>
  * that it should represent.
- * 
+ *
  * @param data the <code>LOGFONT</code> for the result
  */
 this(LOGFONT* data, float height) {
@@ -112,7 +114,7 @@
  * method.
  * <p>
  * Note that the representation varies between platforms,
- * and a FontData can only be created from a string that was 
+ * and a FontData can only be created from a string that was
  * generated on the same platform.
  * </p>
  *
@@ -132,16 +134,16 @@
     if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     char[] version1 = string.substring(start, end);
     try {
-        if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
+        if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     } catch (NumberFormatException e) {
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
-    
+
     start = end + 1;
     end = string.indexOf('|', start);
     if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     char[] name = string.substring(start, end);
-    
+
     start = end + 1;
     end = string.indexOf('|', start);
     if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
@@ -151,7 +153,7 @@
     } catch (NumberFormatException e) {
         DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     }
-    
+
     start = end + 1;
     end = string.indexOf('|', start);
     if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
@@ -246,9 +248,9 @@
     }
 }
 
-/**  
+/**
  * Constructs a new font data given a font name,
- * the height of the desired font in points, 
+ * the height of the desired font in points,
  * and a font style.
  *
  * @param name the name of the font (must not be null)
@@ -301,7 +303,7 @@
             * This code is intentionally commented.  When creating
             * a FontData, lfHeight is not necessarily set.  Instead
             * we check the height field which is always set.
-            */ 
+            */
     //      data.lfHeight is lf.lfHeight &&
             height is fd.height &&
             data.lfWidth is lf.lfWidth &&
@@ -382,7 +384,7 @@
  * given language/country locale, the variant portion of the
  * locale will determine the character set.
  * </p>
- * 
+ *
  * @return the <code>String</code> representing a Locale object
  * @since 3.0
  */
@@ -400,14 +402,14 @@
     if (variant !is null) {
         buffer.append (variant);
     }
-    
+
     char[] result = buffer.toString ();
     int length_ = result.length;
     if (length_ > 0) {
         if (result.charAt (length_ - 1) is sep) {
             result = result.substring (0, length_ - 1);
         }
-    } 
+    }
     return result;
 }
 
@@ -425,12 +427,12 @@
 }
 
 /**
- * Returns the style of the receiver which is a bitwise OR of 
+ * Returns the style of the receiver which is a bitwise OR of
  * one or more of the <code>DWT</code> constants NORMAL, BOLD
  * and ITALIC.
  *
  * @return the style of this <code>FontData</code>
- * 
+ *
  * @see #setStyle
  */
 public int getStyle() {
@@ -441,8 +443,8 @@
 }
 
 /**
- * Returns an integer hash code for the receiver. Any two 
- * objects that return <code>true</code> when passed to 
+ * Returns an integer hash code for the receiver. Any two
+ * objects that return <code>true</code> when passed to
  * <code>equals</code> must return the same value for this
  * method.
  *
@@ -469,7 +471,7 @@
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
  * </ul>
- * 
+ *
  * @see #getHeight
  */
 public void setHeight(int height) {
@@ -495,17 +497,17 @@
  * given language/country locale, the variant portion of the
  * locale will determine the character set.
  * </p>
- * 
+ *
  * @param locale the <code>String</code> representing a Locale object
  * @see java.util.Locale#toString
  */
-public void setLocale(char[] locale) {  
+public void setLocale(char[] locale) {
     lang = country = variant = null;
     if (locale !is null) {
         char sep = '_';
         int length_ = locale.length;
         int firstSep, secondSep;
-        
+
         firstSep = locale.indexOf(sep);
         if (firstSep is -1) {
             firstSep = secondSep = length_;
@@ -542,7 +544,7 @@
  * </p>
  * <p>
  * On platforms that do not support font foundries, only the face name
- * (for example, "courier") is used in <code>setName()</code> and 
+ * (for example, "courier") is used in <code>setName()</code> and
  * <code>getName()</code>.
  * </p>
  *
@@ -565,7 +567,7 @@
 
 /**
  * Sets the style of the receiver to the argument which must
- * be a bitwise OR of one or more of the <code>DWT</code> 
+ * be a bitwise OR of one or more of the <code>DWT</code>
  * constants NORMAL, BOLD and ITALIC.  All other style bits are
  * ignored.
  *
@@ -588,7 +590,7 @@
 
 /**
  * Returns a string representation of the receiver which is suitable
- * for constructing an equivalent instance using the 
+ * for constructing an equivalent instance using the
  * <code>FontData(String)</code> constructor.
  *
  * @return a string representation of the FontData
@@ -604,30 +606,30 @@
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(getStyle()));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append("WINDOWS|1|"); //$NON-NLS-1$  
+    buffer.append("WINDOWS|1|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfHeight));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfWidth));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfEscapement));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfOrientation));  
+    buffer.append(to!(char[])(data.lfOrientation));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfWeight));  
+    buffer.append(to!(char[])(data.lfWeight));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfItalic));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfUnderline));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfStrikeOut));  
+    buffer.append(to!(char[])(data.lfStrikeOut));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfCharSet)); 
+    buffer.append(to!(char[])(data.lfCharSet));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfOutPrecision));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfClipPrecision));  
+    buffer.append(to!(char[])(data.lfClipPrecision));
     buffer.append("|"); //$NON-NLS-1$
-    buffer.append(to!(char[])(data.lfQuality)); 
+    buffer.append(to!(char[])(data.lfQuality));
     buffer.append("|"); //$NON-NLS-1$
     buffer.append(to!(char[])(data.lfPitchAndFamily));
     buffer.append("|"); //$NON-NLS-1$
@@ -635,7 +637,7 @@
     return buffer.toString();
 }
 
-/**  
+/**
  * Invokes platform specific functionality to allocate a new font data.
  * <p>
  * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
--- a/dwt/graphics/FontMetrics.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/FontMetrics.d	Sun Jan 27 17:43:55 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 2005 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
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.FontMetrics;
 
@@ -22,9 +24,9 @@
  *
  * @see GC#getFontMetrics
  */
- 
+
 public final class FontMetrics {
-    
+
     /**
      * On Windows, handle is a Win32 TEXTMETRIC struct
      * On Photon, handle is a Photon FontQueryInfo struct
@@ -37,7 +39,7 @@
      * </p>
      */
     public TEXTMETRIC* handle;
-    
+
 /**
  * Prevents instances from being created outside the package.
  */
@@ -84,7 +86,7 @@
 
 /**
  * Returns the ascent of the font described by the receiver. A
- * font's <em>ascent</em> is the distance from the baseline to the 
+ * font's <em>ascent</em> is the distance from the baseline to the
  * top of actual characters, not including any of the leading area,
  * measured in pixels.
  *
@@ -117,7 +119,7 @@
 }
 
 /**
- * Returns the height of the font described by the receiver, 
+ * Returns the height of the font described by the receiver,
  * measured in pixels. A font's <em>height</em> is the sum of
  * its ascent, descent and leading area.
  *
@@ -143,8 +145,8 @@
 }
 
 /**
- * Returns an integer hash code for the receiver. Any two 
- * objects that return <code>true</code> when passed to 
+ * Returns an integer hash code for the receiver. Any two
+ * objects that return <code>true</code> when passed to
  * <code>equals</code> must return the same value for this
  * method.
  *
@@ -162,7 +164,7 @@
         handle.tmPitchAndFamily ^ handle.tmCharSet;
 }
 
-/**  
+/**
  * Invokes platform specific functionality to allocate a new font metrics.
  * <p>
  * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
--- a/dwt/graphics/GC.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/GC.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,11 +7,25 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.GC;
 
+import dwt.graphics.GCData;
+import dwt.graphics.Image;
+import dwt.internal.win32.WINTYPES;
+
 //PORTING_TYPE
 class GC{
+    void dispose();
+    bool isDisposed();
+    void flush ();
+    GCData data;
+    HDC handle;
+public void drawImage(Image image, int x, int y) ;
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) ;
+void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) ;
 }
 
 /++
--- a/dwt/graphics/GCData.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/GCData.d	Sun Jan 27 17:43:55 2008 +0100
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*******************************************************************************
  * Copyright (c) 2000, 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
@@ -12,12 +12,20 @@
  *******************************************************************************/
 module dwt.graphics.GCData;
 
- 
+
 import dwt.DWT;
 import dwt.internal.win32.WINTYPES;
+import dwt.graphics.Image;
+import dwt.graphics.Device;
 
 //PORTING_TYPE
 class GCData {
+    HBITMAP hNullBitmap;
+    int style;
+    int layout;
+    Device device;
+    Image image;
+    HFONT hFont;
 }
 /+++
 /**
--- a/dwt/graphics/Image.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Image.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Image;
 
@@ -785,8 +787,7 @@
     byte[] bmi;
     if (isDirect) bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
     else  bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
-    bmi[ 0 .. BITMAPINFOHEADER.sizeof ] = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof ];
-    //OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+    *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
 
     /* Set the rgb colors into the bitmap info */
     int offset = BITMAPINFOHEADER.sizeof;
@@ -978,7 +979,8 @@
             OS.GetObject(hBitmap, BITMAP.sizeof, &bm);
             int imgWidth = bm.bmWidth;
             int imgHeight = hBitmap is iconInfo.hbmMask ? bm.bmHeight / 2 : bm.bmHeight;
-            int img = 0, pixels = 0;
+            Gdip.Bitmap* img;
+            byte* pixels;
             if (imgWidth > imgHeight) {
                 auto hDC = device.internal_new_GC(null);
                 auto srcHdc = OS.CreateCompatibleDC(hDC);
@@ -992,8 +994,7 @@
                 OS.BitBlt(memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, hBitmap is iconInfo.hbmMask ? imgHeight : 0, OS.SRCCOPY);
                 OS.SelectObject(memHdc, oldMemBitmap);
                 OS.DeleteObject(memHdc);
-                byte[] srcData = new byte[dibBM.bmWidthBytes * dibBM.bmHeight];
-                OS.MoveMemory(srcData, dibBM.bmBits, srcData.length);
+                byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. dibBM.bmWidthBytes * dibBM.bmHeight].dup;
                 OS.DeleteObject(memDib);
                 OS.SelectObject(srcHdc, iconInfo.hbmMask);
                 for (int y = 0, dp = 0; y < imgHeight; ++y) {
@@ -1009,17 +1010,17 @@
                 OS.SelectObject(srcHdc, oldSrcBitmap);
                 OS.DeleteObject(srcHdc);
                 device.internal_dispose_GC(hDC, null);
-                int hHeap = OS.GetProcessHeap();
-                pixels = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length);
-                if (pixels is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-                OS.MoveMemory(pixels, srcData, srcData.length);
+                auto hHeap = OS.GetProcessHeap();
+                pixels = cast(byte*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length);
+                if (pixels is null) DWT.error(DWT.ERROR_NO_HANDLES);
+                pixels[ 0 .. srcData.length ] = srcData[];
                 img = Gdip.Bitmap_new(imgWidth, imgHeight, dibBM.bmWidthBytes, Gdip.PixelFormat32bppARGB, pixels);
             } else {
                 img = Gdip.Bitmap_new(handle);
             }
-            if (iconInfo.hbmColor !is 0) OS.DeleteObject(iconInfo.hbmColor);
-            if (iconInfo.hbmMask !is 0) OS.DeleteObject(iconInfo.hbmMask);
-            return [img, pixels];
+            if (iconInfo.hbmColor !is null) OS.DeleteObject(iconInfo.hbmColor);
+            if (iconInfo.hbmMask !is null) OS.DeleteObject(iconInfo.hbmMask);
+            return [ cast(int)img, cast(int) pixels ];
         }
         default: DWT.error(DWT.ERROR_INVALID_IMAGE);
     }
@@ -1090,31 +1091,31 @@
     auto hDC = device.internal_new_GC(null);
 
     /* Compute the background color */
-    BITMAP bm = new BITMAP();
-    OS.GetObject(handle, BITMAP.sizeof, bm);
+    BITMAP bm;
+    OS.GetObject(handle, BITMAP.sizeof, &bm);
     auto hdcMem = OS.CreateCompatibleDC(hDC);
     auto hOldObject = OS.SelectObject(hdcMem, handle);
     int red = 0, green = 0, blue = 0;
     if (bm.bmBitsPixel <= 8)  {
         if (OS.IsWinCE) {
-            byte[] pBits = new byte[1];
-            OS.MoveMemory(pBits, bm.bmBits, 1);
+            byte* pBits = cast(byte*)bm.bmBits;
+            //OS.MoveMemory(pBits, bm.bmBits, 1);
             byte oldValue = pBits[0];
             int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
             pBits[0] = cast(byte)((transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
-            OS.MoveMemory(bm.bmBits, pBits, 1);
+            //OS.MoveMemory(bm.bmBits, bm.bmBits, 1);
             int color = OS.GetPixel(hdcMem, 0, 0);
             pBits[0] = oldValue;
-            OS.MoveMemory(bm.bmBits, pBits, 1);
+            //OS.MoveMemory(bm.bmBits, bm.bmBits, 1);
             blue = (color & 0xFF0000) >> 16;
             green = (color & 0xFF00) >> 8;
             red = color & 0xFF;
         } else {
-            byte[] color = new byte[4];
-            OS.GetDIBColorTable(hdcMem, transparentPixel, 1, color);
-            blue = color[0] & 0xFF;
-            green = color[1] & 0xFF;
-            red = color[2] & 0xFF;
+            RGBQUAD color;
+            OS.GetDIBColorTable(hdcMem, transparentPixel, 1, &color);
+            blue = color.rgbBlue;
+            green = color.rgbGreen;
+            red = color.rgbRed;
         }
     } else {
         switch (bm.bmBitsPixel) {
@@ -1164,22 +1165,22 @@
     }
     switch (type) {
         case DWT.BITMAP:
-            BITMAP bm = new BITMAP();
-            OS.GetObject(handle, BITMAP.sizeof, bm);
+            BITMAP bm;
+            OS.GetObject(handle, BITMAP.sizeof, &bm);
             return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight);
         case DWT.ICON:
             if (OS.IsWinCE) {
                 return new Rectangle(0, 0, width = data.width, height = data.height);
             } else {
-                ICONINFO info = new ICONINFO();
-                OS.GetIconInfo(handle, info);
-                int hBitmap = info.hbmColor;
-                if (hBitmap is 0) hBitmap = info.hbmMask;
-                bm = new BITMAP();
-                OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+                ICONINFO info;
+                OS.GetIconInfo(handle, &info);
+                auto hBitmap = info.hbmColor;
+                if (hBitmap is null) hBitmap = info.hbmMask;
+                BITMAP bm;
+                OS.GetObject(hBitmap, BITMAP.sizeof, &bm);
                 if (hBitmap is info.hbmMask) bm.bmHeight /= 2;
-                if (info.hbmColor !is 0) OS.DeleteObject(info.hbmColor);
-                if (info.hbmMask !is 0) OS.DeleteObject(info.hbmMask);
+                if (info.hbmColor !is null) OS.DeleteObject(info.hbmColor);
+                if (info.hbmMask !is null) OS.DeleteObject(info.hbmMask);
                 return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight);
             }
         default:
@@ -1209,14 +1210,13 @@
     switch (type) {
         case DWT.ICON: {
             if (OS.IsWinCE) return data;
-            ICONINFO info = new ICONINFO();
+            ICONINFO info;
             if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-            OS.GetIconInfo(handle, info);
+            OS.GetIconInfo(handle, &info);
             /* Get the basic BITMAP information */
-            int hBitmap = info.hbmColor;
-            if (hBitmap is 0) hBitmap = info.hbmMask;
-            bm = new BITMAP();
-            OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+            auto hBitmap = info.hbmColor;
+            if (hBitmap is null) hBitmap = info.hbmMask;
+            OS.GetObject(hBitmap, BITMAP.sizeof, &bm);
             depth = bm.bmPlanes * bm.bmBitsPixel;
             width = bm.bmWidth;
             if (hBitmap is info.hbmMask) bm.bmHeight /= 2;
@@ -1224,7 +1224,7 @@
             int numColors = 0;
             if (depth <= 8) numColors = 1 << depth;
             /* Create the BITMAPINFO */
-            BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+            BITMAPINFOHEADER bmiHeader;
             bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
             bmiHeader.biWidth = width;
             bmiHeader.biHeight = -height;
@@ -1232,7 +1232,7 @@
             bmiHeader.biBitCount = cast(short)depth;
             bmiHeader.biCompression = OS.BI_RGB;
             byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
-            OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+            *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
 
             /* Get the HDC for the device */
             auto hDC = device.internal_new_GC(null);
@@ -1241,10 +1241,10 @@
             auto hBitmapDC = OS.CreateCompatibleDC(hDC);
             auto hOldBitmap = OS.SelectObject(hBitmapDC, hBitmap);
             /* Select the palette if necessary */
-            int oldPalette = 0;
+            HPALETTE oldPalette;
             if (depth <= 8) {
-                int hPalette = device.hPalette;
-                if (hPalette !is 0) {
+                auto hPalette = device.hPalette;
+                if (hPalette !is null) {
                     oldPalette = OS.SelectPalette(hBitmapDC, hPalette, false);
                     OS.RealizePalette(hBitmapDC);
                 }
@@ -1253,17 +1253,16 @@
             int imageSize;
             /* Call with null lpBits to get the image size */
             if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
-            OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+            bmiHeader = *cast(BITMAPINFOHEADER*)bmi.ptr;
             imageSize = bmiHeader.biSizeImage;
-            byte[] data = new byte[imageSize];
             /* Get the bitmap data */
-            int hHeap = OS.GetProcessHeap();
-            int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
-            if (lpvBits is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto hHeap = OS.GetProcessHeap();
+            auto lpvBits = cast(byte*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+            if (lpvBits is null) DWT.error(DWT.ERROR_NO_HANDLES);
             if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
-            OS.MoveMemory(data, lpvBits, imageSize);
+            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, lpvBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+            byte[] data = lpvBits[ 0 .. imageSize].dup; /*PORTING_OPTIMIZE?*/
             /* Calculate the palette */
             PaletteData palette = null;
             if (depth <= 8) {
@@ -1286,16 +1285,15 @@
 
             /* Do the mask */
             byte [] maskData = null;
-            if (info.hbmColor is 0) {
+            if (info.hbmColor is null) {
                 /* Do the bottom half of the mask */
-                maskData = new byte[imageSize];
                 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-                OS.GetDIBits(hBitmapDC, hBitmap, height, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
-                OS.MoveMemory(maskData, lpvBits, imageSize);
+                OS.GetDIBits(hBitmapDC, hBitmap, height, height, lpvBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+                maskData = lpvBits[ 0 .. imageSize].dup;
             } else {
                 /* Do the entire mask */
                 /* Create the BITMAPINFO */
-                bmiHeader = new BITMAPINFOHEADER();
+                bmiHeader = BITMAPINFOHEADER.init;
                 bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
                 bmiHeader.biWidth = width;
                 bmiHeader.biHeight = -height;
@@ -1303,7 +1301,7 @@
                 bmiHeader.biBitCount = 1;
                 bmiHeader.biCompression = OS.BI_RGB;
                 bmi = new byte[BITMAPINFOHEADER.sizeof + 8];
-                OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+                *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
 
                 /* First color black, second color white */
                 int offset = BITMAPINFOHEADER.sizeof;
@@ -1312,15 +1310,15 @@
                 OS.SelectObject(hBitmapDC, info.hbmMask);
                 /* Call with null lpBits to get the image size */
                 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
-                OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+                bmiHeader = *cast(BITMAPINFOHEADER*)bmi.ptr;
                 imageSize = bmiHeader.biSizeImage;
                 maskData = new byte[imageSize];
-                int lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
-                if (lpvMaskBits is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+                if (lpvMaskBits is null) DWT.error(DWT.ERROR_NO_HANDLES);
                 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, lpvMaskBits, bmi, OS.DIB_RGB_COLORS);
-                OS.MoveMemory(maskData, lpvMaskBits, imageSize);
+                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, lpvMaskBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+                maskData[] = (cast(byte*)lpvMaskBits)[ 0 .. imageSize ];
                 OS.HeapFree(hHeap, 0, lpvMaskBits);
                 /* Loop to invert the mask */
                 for (int i = 0; i < maskData.length; i++) {
@@ -1338,7 +1336,7 @@
             /* Clean up */
             OS.HeapFree(hHeap, 0, lpvBits);
             OS.SelectObject(hBitmapDC, hOldBitmap);
-            if (oldPalette !is 0) {
+            if (oldPalette !is null) {
                 OS.SelectPalette(hBitmapDC, oldPalette, false);
                 OS.RealizePalette(hBitmapDC);
             }
@@ -1347,8 +1345,8 @@
             /* Release the HDC for the device */
             device.internal_dispose_GC(hDC, null);
 
-            if (info.hbmColor !is 0) OS.DeleteObject(info.hbmColor);
-            if (info.hbmMask !is 0) OS.DeleteObject(info.hbmMask);
+            if (info.hbmColor !is null) OS.DeleteObject(info.hbmColor);
+            if (info.hbmMask !is null) OS.DeleteObject(info.hbmMask);
             /* Construct and return the ImageData */
             ImageData imageData = new ImageData(width, height, depth, palette, 4, data);
             imageData.maskData = maskData;
@@ -1357,13 +1355,13 @@
         }
         case DWT.BITMAP: {
             /* Get the basic BITMAP information */
-            bm = new BITMAP();
-            OS.GetObject(handle, BITMAP.sizeof, bm);
+            bm = BITMAP.init;
+            OS.GetObject(handle, BITMAP.sizeof, &bm);
             depth = bm.bmPlanes * bm.bmBitsPixel;
             width = bm.bmWidth;
             height = bm.bmHeight;
             /* Find out whether this is a DIB or a DDB. */
-            bool isDib = (bm.bmBits !is 0);
+            bool isDib = (bm.bmBits !is null);
             /* Get the HDC for the device */
             auto hDC = device.internal_new_GC(null);
 
@@ -1372,7 +1370,7 @@
             * workaround is to create a temporary DIB from the DDB and use
             * the bmBits field of DIBSECTION to retrieve the image data.
             */
-            int handle = this.handle;
+            auto handle = this.handle;
             if (OS.IsWinCE) {
                 if (!isDib) {
                     bool mustRestore = false;
@@ -1380,9 +1378,9 @@
                         memGC.flush ();
                         mustRestore = true;
                         GCData data = memGC.data;
-                        if (data.hNullBitmap !is 0) {
+                        if (data.hNullBitmap !is null) {
                             OS.SelectObject(memGC.handle, data.hNullBitmap);
-                            data.hNullBitmap = 0;
+                            data.hNullBitmap = null;
                         }
                     }
                     handle = createDIBFromDDB(hDC, this.handle, width, height);
@@ -1393,10 +1391,9 @@
                     isDib = true;
                 }
             }
-            DIBSECTION dib = null;
+            DIBSECTION dib;
             if (isDib) {
-                dib = new DIBSECTION();
-                OS.GetObject(handle, DIBSECTION.sizeof, dib);
+                OS.GetObject(handle, DIBSECTION.sizeof, &dib);
             }
             /* Calculate number of colors */
             int numColors = 0;
@@ -1409,9 +1406,8 @@
             }
             /* Create the BITMAPINFO */
             byte[] bmi = null;
-            BITMAPINFOHEADER bmiHeader = null;
+            BITMAPINFOHEADER bmiHeader;
             if (!isDib) {
-                bmiHeader = new BITMAPINFOHEADER();
                 bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
                 bmiHeader.biWidth = width;
                 bmiHeader.biHeight = -height;
@@ -1419,17 +1415,17 @@
                 bmiHeader.biBitCount = cast(short)depth;
                 bmiHeader.biCompression = OS.BI_RGB;
                 bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4];
-                OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+                *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
             }
 
             /* Create the DC and select the bitmap */
             auto hBitmapDC = OS.CreateCompatibleDC(hDC);
             auto hOldBitmap = OS.SelectObject(hBitmapDC, handle);
             /* Select the palette if necessary */
-            int oldPalette = 0;
+            HPALETTE oldPalette;
             if (!isDib && depth <= 8) {
-                int hPalette = device.hPalette;
-                if (hPalette !is 0) {
+                auto hPalette = device.hPalette;
+                if (hPalette !is null) {
                     oldPalette = OS.SelectPalette(hBitmapDC, hPalette, false);
                     OS.RealizePalette(hBitmapDC);
                 }
@@ -1441,8 +1437,8 @@
             } else {
                 /* Call with null lpBits to get the image size */
                 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-                OS.GetDIBits(hBitmapDC, handle, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
-                OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof);
+                OS.GetDIBits(hBitmapDC, handle, 0, height, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+                bmiHeader = *cast(BITMAPINFOHEADER*)bmi.ptr;
                 imageSize = bmiHeader.biSizeImage;
             }
             byte[] data = new byte[imageSize];
@@ -1450,17 +1446,17 @@
             if (isDib) {
                 if (OS.IsWinCE && this.handle !is handle) {
                     /* get image data from the temporary DIB */
-                    OS.MoveMemory(data, dib.bmBits, imageSize);
+                    data[] = (cast(byte*)dib.bmBits)[ 0 .. imageSize ];
                 } else {
-                    OS.MoveMemory(data, bm.bmBits, imageSize);
+                    data[] = (cast(byte*)bm.bmBits)[ 0 .. imageSize ];
                 }
             } else {
-                int hHeap = OS.GetProcessHeap();
-                int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
-                if (lpvBits is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto hHeap = OS.GetProcessHeap();
+                auto lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+                if (lpvBits is null) DWT.error(DWT.ERROR_NO_HANDLES);
                 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-                OS.GetDIBits(hBitmapDC, handle, 0, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
-                OS.MoveMemory(data, lpvBits, imageSize);
+                OS.GetDIBits(hBitmapDC, handle, 0, height, lpvBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS);
+                data[] = (cast(byte*)lpvBits)[ 0 .. imageSize ];
                 OS.HeapFree(hHeap, 0, lpvBits);
             }
             /* Calculate the palette */
@@ -1476,13 +1472,12 @@
                         * RGB value.
                         */
                         int red = 0, green = 0, blue = 0;
-                        byte[] pBits = new byte[1];
-                        OS.MoveMemory(pBits, bm.bmBits, 1);
+                        byte* pBits = cast(byte*)bm.bmBits;
                         byte oldValue = pBits[0];
                         int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
                         for (int i = 0; i < numColors; i++) {
                             pBits[0] = cast(byte)((i << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
-                            OS.MoveMemory(bm.bmBits, pBits, 1);
+                            //OS.MoveMemory(bm.bmBits, pBits, 1);
                             int color = OS.GetPixel(hBitmapDC, 0, 0);
                             blue = (color & 0xFF0000) >> 16;
                             green = (color & 0xFF00) >> 8;
@@ -1490,10 +1485,10 @@
                             rgbs[i] = new RGB(red, green, blue);
                         }
                         pBits[0] = oldValue;
-                        OS.MoveMemory(bm.bmBits, pBits, 1);
+                        //OS.MoveMemory(bm.bmBits, pBits, 1);
                     } else {
                         byte[] colors = new byte[numColors * 4];
-                        OS.GetDIBColorTable(hBitmapDC, 0, numColors, colors);
+                        OS.GetDIBColorTable(hBitmapDC, 0, numColors, cast(RGBQUAD*)colors.ptr);
                         int colorIndex = 0;
                         for (int i = 0; i < rgbs.length; i++) {
                             rgbs[i] = new RGB(colors[colorIndex + 2] & 0xFF, colors[colorIndex + 1] & 0xFF, colors[colorIndex] & 0xFF);
@@ -1519,7 +1514,7 @@
             }
             /* Clean up */
             OS.SelectObject(hBitmapDC, hOldBitmap);
-            if (oldPalette !is 0) {
+            if (oldPalette !is null) {
                 OS.SelectPalette(hBitmapDC, oldPalette, false);
                 OS.RealizePalette(hBitmapDC);
             }
@@ -1598,7 +1593,7 @@
 }
 
 static HGDIOBJ createDIB(int width, int height, int depth) {
-    BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+    BITMAPINFOHEADER bmiHeader;
     bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
     bmiHeader.biWidth = width;
     bmiHeader.biHeight = -height;
@@ -1607,7 +1602,7 @@
     if (OS.IsWinCE) bmiHeader.biCompression = OS.BI_BITFIELDS;
     else bmiHeader.biCompression = OS.BI_RGB;
     byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + (OS.IsWinCE ? 12 : 0)];
-    OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+    *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
     /* Set the rgb colors into the bitmap info */
     if (OS.IsWinCE) {
         int redMask = 0xFF00;
@@ -1629,8 +1624,8 @@
         bmi[offset + 11] = cast(byte)((blueMask & 0xFF) >> 0);
     }
 
-    int[] pBits = new int[1];
-    return OS.CreateDIBSection(0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+    int pBits;
+    return OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0);
 }
 
 /**
@@ -1646,8 +1641,8 @@
  */
 static void GetIconInfo(Image image, ICONINFO* info) {
     int[] result = init(image.device, null, image.data);
-    info.hbmColor = result[0];
-    info.hbmMask = result[1];
+    info.hbmColor = cast(HBITMAP)result[0];
+    info.hbmMask = cast(HBITMAP)result[1];
 }
 
 static int[] init(Device device, Image image, ImageData i) {
@@ -1744,7 +1739,7 @@
     /* Construct bitmap info header by hand */
     RGB[] rgbs = i.palette.getRGBs();
     bool useBitfields = OS.IsWinCE && (i.depth is 16 || i.depth is 32);
-    BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
+    BITMAPINFOHEADER bmiHeader;
     bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
     bmiHeader.biWidth = i.width;
     bmiHeader.biHeight = -i.height;
@@ -1758,7 +1753,7 @@
         bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)];
     else
         bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4];
-    OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+    *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
     /* Set the rgb colors into the bitmap info */
     int offset = BITMAPINFOHEADER.sizeof;
     if (i.palette.isDirect) {
@@ -1808,15 +1803,15 @@
             offset += 4;
         }
     }
-    int[] pBits = new int[1];
-    int hDib = OS.CreateDIBSection(0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
-    if (hDib is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    int pBits;
+    auto hDib = OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, &pBits, null, 0);
+    if (hDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
     /* In case of a scanline pad other than 4, do the work to convert it */
     byte[] data = i.data;
     if (i.scanlinePad !is 4 && (i.bytesPerLine % 4 !is 0)) {
         data = ImageData.convertPad(data, i.width, i.height, i.depth, i.scanlinePad, 4);
     }
-    OS.MoveMemory(pBits[0], data, data.length);
+    //OS.MoveMemory(pBits[0], data, data.length);
 
     int[] result = null;
     if (i.getTransparencyType() is DWT.TRANSPARENCY_MASK) {
@@ -1826,8 +1821,8 @@
         /* Create the color bitmap */
         auto hdcSrc = OS.CreateCompatibleDC(hDC);
         OS.SelectObject(hdcSrc, hDib);
-        int hBitmap = OS.CreateCompatibleBitmap(hDC, i.width, i.height);
-        if (hBitmap is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto hBitmap = OS.CreateCompatibleBitmap(hDC, i.width, i.height);
+        if (hBitmap is null) DWT.error(DWT.ERROR_NO_HANDLES);
         auto hdcDest = OS.CreateCompatibleDC(hDC);
         OS.SelectObject(hdcDest, hBitmap);
         OS.BitBlt(hdcDest, 0, 0, i.width, i.height, hdcSrc, 0, 0, OS.SRCCOPY);
@@ -1837,8 +1832,8 @@
 
         /* Create the mask. Windows requires icon masks to have a scanline pad of 2. */
         byte[] maskData = ImageData.convertPad(i.maskData, i.width, i.height, 1, i.maskPad, 2);
-        int hMask = OS.CreateBitmap(i.width, i.height, 1, 1, maskData);
-        if (hMask is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto hMask = OS.CreateBitmap(i.width, i.height, 1, 1, maskData.ptr);
+        if (hMask is null) DWT.error(DWT.ERROR_NO_HANDLES);
         OS.SelectObject(hdcSrc, hMask);
         OS.PatBlt(hdcSrc, 0, 0, i.width, i.height, OS.DSTINVERT);
         OS.DeleteDC(hdcSrc);
@@ -1846,15 +1841,15 @@
         OS.DeleteObject(hDib);
 
         if (image is null) {
-            result = [hBitmap, hMask];
+            result = [ cast(int) hBitmap, cast(int) hMask];
         } else {
             /* Create the icon */
-            ICONINFO info = new ICONINFO();
+            ICONINFO info;
             info.fIcon = true;
             info.hbmColor = hBitmap;
             info.hbmMask = hMask;
-            int hIcon = OS.CreateIconIndirect(info);
-            if (hIcon is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto hIcon = OS.CreateIconIndirect(&info);
+            if (hIcon is null) DWT.error(DWT.ERROR_NO_HANDLES);
             OS.DeleteObject(hBitmap);
             OS.DeleteObject(hMask);
             image.handle = hIcon;
@@ -1863,7 +1858,7 @@
         }
     } else {
         if (image is null) {
-            result = [hDib];
+            result = [ cast(int) hDib];
         } else {
             image.handle = hDib;
             image.type = DWT.BITMAP;
@@ -1912,7 +1907,7 @@
             imageData = new ImageData(source.width, source.height, source.depth, new PaletteData(rgbs));
         } else {
             while (blackIndex < rgbs.length) {
-                if (rgbs[blackIndex].equals(black)) break;
+                if (rgbs[blackIndex] ==/*eq*/ black) break;
                 blackIndex++;
             }
             if (blackIndex is rgbs.length) {
@@ -1986,7 +1981,7 @@
     auto hDC = device.internal_new_GC(null);
     auto imageDC = OS.CreateCompatibleDC(hDC);
     device.internal_dispose_GC(hDC, null);
-    if (imageDC is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    if (imageDC is null) DWT.error(DWT.ERROR_NO_HANDLES);
 
     if (data !is null) {
         /* Set the GCData fields */
@@ -2082,20 +2077,20 @@
     auto hDC = device.internal_new_GC(null);
 
     /* Change the background color in the image */
-    BITMAP bm = new BITMAP();
-    OS.GetObject(handle, BITMAP.sizeof, bm);
+    BITMAP bm;
+    OS.GetObject(handle, BITMAP.sizeof, &bm);
     auto hdcMem = OS.CreateCompatibleDC(hDC);
     OS.SelectObject(hdcMem, handle);
     int maxColors = 1 << bm.bmBitsPixel;
     byte[] colors = new byte[maxColors * 4];
     if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-    int numColors = OS.GetDIBColorTable(hdcMem, 0, maxColors, colors);
+    int numColors = OS.GetDIBColorTable(hdcMem, 0, maxColors, cast(RGBQUAD*)colors.ptr);
     int offset = transparentPixel * 4;
     colors[offset] = cast(byte)color.getBlue();
     colors[offset + 1] = cast(byte)color.getGreen();
     colors[offset + 2] = cast(byte)color.getRed();
     if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
-    OS.SetDIBColorTable(hdcMem, 0, numColors, colors);
+    OS.SetDIBColorTable(hdcMem, 0, numColors, cast(RGBQUAD*)colors.ptr);
     OS.DeleteDC(hdcMem);
 
     /* Release the HDC for the device */
--- a/dwt/graphics/ImageData.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/ImageData.d	Sun Jan 27 17:43:55 2008 +0100
@@ -23,6 +23,7 @@
 import dwt.internal.CloneableCompatibility;
 
 public import dwt.dwthelper.InputStream;
+import dwt.dwthelper.System;
 
 
 /**
--- a/dwt/graphics/Region.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Region.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Region;
 
--- a/dwt/graphics/Transform.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/graphics/Transform.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.graphics.Transform;
 
@@ -47,7 +49,7 @@
      * platforms and should never be accessed from application code.
      * </p>
      */
-    public Matrix* handle;
+    public Gdip.Matrix* handle;
 
 /**
  * Constructs a new identity Transform.
@@ -316,7 +318,7 @@
 public void transform(float[] pointArray) {
     if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    Gdip.Matrix_TransformPoints(handle, cast(PointF*)pointArray.ptr, pointArray.length / 2);
+    Gdip.Matrix_TransformPoints(handle, cast(Gdip.PointF*)pointArray.ptr, pointArray.length / 2);
 }
 
 /**
--- a/dwt/internal/win32/OS.d	Sat Jan 26 19:05:32 2008 +0100
+++ b/dwt/internal/win32/OS.d	Sun Jan 27 17:43:55 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.internal.win32.OS;