Changeset 23:f5482da87ed8

Show
Ignore:
Timestamp:
01/27/08 11:43:55 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Image, ImageData?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/System.d

    r0 r23  
    1 /** 
     1/** 
    22 * Authors: Frank Benoit <keinfarbton@googlemail.com> 
    33 */ 
     
    1010        static void validCheck(uint SrcLen, uint DestLen, uint copyLen){ 
    1111            if(SrcLen < copyLen || DestLen < copyLen|| SrcLen < 0 || DestLen < 0){ 
    12                 Util.trace("Error : SimpleType.arraycopy(), out of bounds."); 
     12                //Util.trace("Error : SimpleType.arraycopy(), out of bounds."); 
    1313                assert(0); 
    1414            } 
  • dwt/dwthelper/utils.d

    r22 r23  
    9090 
    9191public void getChars( char[] src, int srcBegin, int srcEnd, char[] dst, int dstBegin){ 
    92     dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = str[ srcBegin .. srcEnd ]; 
     92    dst[ dstBegin .. dstBegin + srcEnd - srcBegin ] = src[ srcBegin .. srcEnd ]; 
    9393} 
    9494 
  • dwt/graphics/Color.d

    r18 r23  
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.Color; 
  • dwt/graphics/Device.d

    r19 r23  
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.Device; 
  • dwt/graphics/Font.d

    r15 r23  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2006 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.Font; 
     
    1921import dwt.graphics.Resource; 
    2022import dwt.graphics.FontData; 
    21 import dwt.graphics.Device;  
     23import dwt.graphics.Device; 
    2224 
    2325import tango.text.convert.Format; 
    24 //import tango.stdc.stringz;  
     26//import tango.stdc.stringz; 
    2527 
    2628/** 
     
    3032 * or a <code>FontData</code> object which encapsulates this data. 
    3133 * <p> 
    32  * Application code must explicitly invoke the <code>Font.dispose()</code>  
     34 * Application code must explicitly invoke the <code>Font.dispose()</code> 
    3335 * method to release the operating system resources managed by each instance 
    3436 * when those instances are no longer required. 
     
    3941 
    4042public final class Font : Resource { 
    41      
     43 
    4244    /** 
    4345     * the handle to the OS font resource 
     
    5153     */ 
    5254    public HFONT handle; 
    53      
     55 
    5456/** 
    5557 * Prevents uninitialized instances from being created outside the package. 
     
    5860} 
    5961 
    60 /**   
     62/** 
    6163 * Constructs a new font given a device and font data 
    6264 * which describes the desired font's appearance. 
    6365 * <p> 
    64  * You must dispose the font when it is no longer required.  
     66 * You must dispose the font when it is no longer required. 
    6567 * </p> 
    6668 * 
    6769 * @param device the device to create the font on 
    6870 * @param fd the FontData that describes the desired font (must not be null) 
    69  *  
     71 * 
    7072 * @exception IllegalArgumentException <ul> 
    7173 *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> 
     
    8082    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    8183    init(device, fd); 
    82     if (device.tracking) device.new_Object(this);    
    83 } 
    84  
    85 /**   
     84    if (device.tracking) device.new_Object(this); 
     85} 
     86 
     87/** 
    8688 * Constructs a new font given a device and an array 
    8789 * of font data which describes the desired font's 
    8890 * appearance. 
    8991 * <p> 
    90  * You must dispose the font when it is no longer required.  
     92 * You must dispose the font when it is no longer required. 
    9193 * </p> 
    9294 * 
    9395 * @param device the device to create the font on 
    9496 * @param fds the array of FontData that describes the desired font (must not be null) 
    95  *  
     97 * 
    9698 * @exception IllegalArgumentException <ul> 
    9799 *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> 
     
    103105 *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li> 
    104106 * </ul> 
    105  *  
     107 * 
    106108 * @since 2.1 
    107109 */ 
     
    115117    } 
    116118    init(device, fds[0]); 
    117     if (device.tracking) device.new_Object(this);    
    118 } 
    119  
    120 /**   
     119    if (device.tracking) device.new_Object(this); 
     120} 
     121 
     122/** 
    121123 * Constructs a new font given a device, a font name, 
    122124 * the height of the desired font in points, and a font 
    123125 * style. 
    124126 * <p> 
    125  * You must dispose the font when it is no longer required.  
     127 * You must dispose the font when it is no longer required. 
    126128 * </p> 
    127129 * 
     
    130132 * @param height the font height in points 
    131133 * @param style a bit or combination of NORMAL, BOLD, ITALIC 
    132  *  
     134 * 
    133135 * @exception IllegalArgumentException <ul> 
    134136 *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> 
     
    145147    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    146148    init(device, new FontData (name, height, style)); 
    147     if (device.tracking) device.new_Object(this);    
     149    if (device.tracking) device.new_Object(this); 
    148150} 
    149151 
     
    153155    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    154156    init(device, new FontData (name, height, style)); 
    155     if (device.tracking) device.new_Object(this);    
     157    if (device.tracking) device.new_Object(this); 
    156158} 
    157159 
     
    190192/** 
    191193 * Returns an array of <code>FontData</code>s representing the receiver. 
    192  * On Windows, only one FontData will be returned per font. On X however,  
    193  * a <code>Font</code> object <em>may</em> be composed of multiple X  
     194 * On Windows, only one FontData will be returned per font. On X however, 
     195 * a <code>Font</code> object <em>may</em> be composed of multiple X 
    194196 * fonts. To support this case, we return an array of font data objects. 
    195197 * 
     
    208210 
    209211/** 
    210  * Returns an integer hash code for the receiver. Any two  
    211  * objects that return <code>true</code> when passed to  
     212 * Returns an integer hash code for the receiver. Any two 
     213 * objects that return <code>true</code> when passed to 
    212214 * <code>equals</code> must return the same value for this 
    213215 * method. 
     
    257259} 
    258260 
    259 /**   
     261/** 
    260262 * Invokes platform specific functionality to allocate a new font. 
    261263 * <p> 
  • dwt/graphics/FontData.d

    r17 r23  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.FontData; 
     
    5355 
    5456public final class FontData { 
    55      
     57 
    5658    /** 
    5759     * A Win32 LOGFONT struct 
     
    6567     */ 
    6668    public LOGFONT data; 
    67      
     69 
    6870    /** 
    6971     * The height of the font data in points 
     
    8587    private static FontData s_this; 
    8688 
    87 /**   
     89/** 
    8890 * Constructs a new uninitialized font data. 
    8991 */ 
     
    99101 * Constructs a new font data given the Windows <code>LOGFONT</code> 
    100102 * that it should represent. 
    101  *  
     103 * 
    102104 * @param data the <code>LOGFONT</code> for the result 
    103105 */ 
     
    113115 * <p> 
    114116 * Note that the representation varies between platforms, 
    115  * and a FontData can only be created from a string that was  
     117 * and a FontData can only be created from a string that was 
    116118 * generated on the same platform. 
    117119 * </p> 
     
    133135    char[] version1 = string.substring(start, end); 
    134136    try { 
    135         if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);  
     137        if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
    136138    } catch (NumberFormatException e) { 
    137139        DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
    138140    } 
    139      
     141 
    140142    start = end + 1; 
    141143    end = string.indexOf('|', start); 
    142144    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
    143145    char[] name = string.substring(start, end); 
    144      
     146 
    145147    start = end + 1; 
    146148    end = string.indexOf('|', start); 
     
    152154        DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
    153155    } 
    154      
     156 
    155157    start = end + 1; 
    156158    end = string.indexOf('|', start); 
     
    247249} 
    248250 
    249 /**   
     251/** 
    250252 * Constructs a new font data given a font name, 
    251  * the height of the desired font in points,  
     253 * the height of the desired font in points, 
    252254 * and a font style. 
    253255 * 
     
    302304            * a FontData, lfHeight is not necessarily set.  Instead 
    303305            * we check the height field which is always set. 
    304             */  
     306            */ 
    305307    //      data.lfHeight is lf.lfHeight && 
    306308            height is fd.height && 
     
    383385 * locale will determine the character set. 
    384386 * </p> 
    385  *  
     387 * 
    386388 * @return the <code>String</code> representing a Locale object 
    387389 * @since 3.0 
     
    401403        buffer.append (variant); 
    402404    } 
    403      
     405 
    404406    char[] result = buffer.toString (); 
    405407    int length_ = result.length; 
     
    408410            result = result.substring (0, length_ - 1); 
    409411        } 
    410     }  
     412    } 
    411413    return result; 
    412414} 
     
    426428 
    427429/** 
    428  * Returns the style of the receiver which is a bitwise OR of  
     430 * Returns the style of the receiver which is a bitwise OR of 
    429431 * one or more of the <code>DWT</code> constants NORMAL, BOLD 
    430432 * and ITALIC. 
    431433 * 
    432434 * @return the style of this <code>FontData</code> 
    433  *  
     435 * 
    434436 * @see #setStyle 
    435437 */ 
     
    442444 
    443445/** 
    444  * Returns an integer hash code for the receiver. Any two  
    445  * objects that return <code>true</code> when passed to  
     446 * Returns an integer hash code for the receiver. Any two 
     447 * objects that return <code>true</code> when passed to 
    446448 * <code>equals</code> must return the same value for this 
    447449 * method. 
     
    470472 *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> 
    471473 * </ul> 
    472  *  
     474 * 
    473475 * @see #getHeight 
    474476 */ 
     
    496498 * locale will determine the character set. 
    497499 * </p> 
    498  *  
     500 * 
    499501 * @param locale the <code>String</code> representing a Locale object 
    500502 * @see java.util.Locale#toString 
    501503 */ 
    502 public void setLocale(char[] locale) {   
     504public void setLocale(char[] locale) { 
    503505    lang = country = variant = null; 
    504506    if (locale !is null) { 
     
    506508        int length_ = locale.length; 
    507509        int firstSep, secondSep; 
    508          
     510 
    509511        firstSep = locale.indexOf(sep); 
    510512        if (firstSep is -1) { 
     
    543545 * <p> 
    544546 * On platforms that do not support font foundries, only the face name 
    545  * (for example, "courier") is used in <code>setName()</code> and  
     547 * (for example, "courier") is used in <code>setName()</code> and 
    546548 * <code>getName()</code>. 
    547549 * </p> 
     
    566568/** 
    567569 * Sets the style of the receiver to the argument which must 
    568  * be a bitwise OR of one or more of the <code>DWT</code>  
     570 * be a bitwise OR of one or more of the <code>DWT</code> 
    569571 * constants NORMAL, BOLD and ITALIC.  All other style bits are 
    570572 * ignored. 
     
    589591/** 
    590592 * Returns a string representation of the receiver which is suitable 
    591  * for constructing an equivalent instance using the  
     593 * for constructing an equivalent instance using the 
    592594 * <code>FontData(String)</code> constructor. 
    593595 * 
     
    605607    buffer.append(to!(char[])(getStyle())); 
    606608    buffer.append("|"); //$NON-NLS-1$ 
    607     buffer.append("WINDOWS|1|"); //$NON-NLS-1$   
     609    buffer.append("WINDOWS|1|"); //$NON-NLS-1$ 
    608610    buffer.append(to!(char[])(data.lfHeight)); 
    609611    buffer.append("|"); //$NON-NLS-1$ 
     
    612614    buffer.append(to!(char[])(data.lfEscapement)); 
    613615    buffer.append("|"); //$NON-NLS-1$ 
    614     buffer.append(to!(char[])(data.lfOrientation));   
    615     buffer.append("|"); //$NON-NLS-1$ 
    616     buffer.append(to!(char[])(data.lfWeight));   
     616    buffer.append(to!(char[])(data.lfOrientation)); 
     617    buffer.append("|"); //$NON-NLS-1$ 
     618    buffer.append(to!(char[])(data.lfWeight)); 
    617619    buffer.append("|"); //$NON-NLS-1$ 
    618620    buffer.append(to!(char[])(data.lfItalic)); 
     
    620622    buffer.append(to!(char[])(data.lfUnderline)); 
    621623    buffer.append("|"); //$NON-NLS-1$ 
    622     buffer.append(to!(char[])(data.lfStrikeOut));   
    623     buffer.append("|"); //$NON-NLS-1$ 
    624     buffer.append(to!(char[])(data.lfCharSet));  
     624    buffer.append(to!(char[])(data.lfStrikeOut)); 
     625    buffer.append("|"); //$NON-NLS-1$ 
     626    buffer.append(to!(char[])(data.lfCharSet)); 
    625627    buffer.append("|"); //$NON-NLS-1$ 
    626628    buffer.append(to!(char[])(data.lfOutPrecision)); 
    627629    buffer.append("|"); //$NON-NLS-1$ 
    628     buffer.append(to!(char[])(data.lfClipPrecision));   
    629     buffer.append("|"); //$NON-NLS-1$ 
    630     buffer.append(to!(char[])(data.lfQuality));  
     630    buffer.append(to!(char[])(data.lfClipPrecision)); 
     631    buffer.append("|"); //$NON-NLS-1$ 
     632    buffer.append(to!(char[])(data.lfQuality)); 
    631633    buffer.append("|"); //$NON-NLS-1$ 
    632634    buffer.append(to!(char[])(data.lfPitchAndFamily)); 
     
    636638} 
    637639 
    638 /**   
     640/** 
    639641 * Invokes platform specific functionality to allocate a new font data. 
    640642 * <p> 
  • dwt/graphics/FontMetrics.d

    r16 r23  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2005 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.FontMetrics; 
     
    2325 * @see GC#getFontMetrics 
    2426 */ 
    25   
     27 
    2628public final class FontMetrics { 
    27      
     29 
    2830    /** 
    2931     * On Windows, handle is a Win32 TEXTMETRIC struct 
     
    3840     */ 
    3941    public TEXTMETRIC* handle; 
    40      
     42 
    4143/** 
    4244 * Prevents instances from being created outside the package. 
     
    8587/** 
    8688 * Returns the ascent of the font described by the receiver. A 
    87  * font's <em>ascent</em> is the distance from the baseline to the  
     89 * font's <em>ascent</em> is the distance from the baseline to the 
    8890 * top of actual characters, not including any of the leading area, 
    8991 * measured in pixels. 
     
    118120 
    119121/** 
    120  * Returns the height of the font described by the receiver,  
     122 * Returns the height of the font described by the receiver, 
    121123 * measured in pixels. A font's <em>height</em> is the sum of 
    122124 * its ascent, descent and leading area. 
     
    144146 
    145147/** 
    146  * Returns an integer hash code for the receiver. Any two  
    147  * objects that return <code>true</code> when passed to  
     148 * Returns an integer hash code for the receiver. Any two 
     149 * objects that return <code>true</code> when passed to 
    148150 * <code>equals</code> must return the same value for this 
    149151 * method. 
     
    163165} 
    164166 
    165 /**   
     167/** 
    166168 * Invokes platform specific functionality to allocate a new font metrics. 
    167169 * <p> 
  • dwt/graphics/GC.d

    r22 r23  
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.GC; 
    1214 
     15import dwt.graphics.GCData; 
     16import dwt.graphics.Image; 
     17import dwt.internal.win32.WINTYPES; 
     18 
    1319//PORTING_TYPE 
    1420class GC{ 
     21    void dispose(); 
     22    bool isDisposed(); 
     23    void flush (); 
     24    GCData data; 
     25    HDC handle; 
     26public void drawImage(Image image, int x, int y) ; 
     27public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) ; 
     28void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) ; 
    1529} 
    1630 
  • dwt/graphics/GCData.d

    r11 r23  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    1313module dwt.graphics.GCData; 
    1414 
    15   
     15 
    1616import dwt.DWT; 
    1717import dwt.internal.win32.WINTYPES; 
     18import dwt.graphics.Image; 
     19import dwt.graphics.Device; 
    1820 
    1921//PORTING_TYPE 
    2022class GCData { 
     23    HBITMAP hNullBitmap; 
     24    int style; 
     25    int layout; 
     26    Device device; 
     27    Image image; 
     28    HFONT hFont; 
    2129} 
    2230/+++ 
  • dwt/graphics/Image.d

    r22 r23  
    88 * Contributors: 
    99 *     IBM Corporation - initial API and implementation 
     10 * Port to the D programming language: 
     11 *     Frank Benoit <benoit@tionex.de> 
    1012 *******************************************************************************/ 
    1113module dwt.graphics.Image; 
     
    786788    if (isDirect) bmi = new byte[BITMAPINFOHEADER.sizeof + (useBitfields ? 12 : 0)]; 
    787789    else  bmi = new byte[BITMAPINFOHEADER.sizeof + rgbs.length * 4]; 
    788     bmi[ 0 .. BITMAPINFOHEADER.sizeof ] = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof ]; 
    789     //OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof); 
     790    *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader; 
    790791 
    791792    /* Set the rgb colors into the bitmap info */ 
     
    979980            int imgWidth = bm.bmWidth; 
    980981            int imgHeight = hBitmap is iconInfo.hbmMask ? bm.bmHeight / 2 : bm.bmHeight; 
    981             int img = 0, pixels = 0; 
     982            Gdip.Bitmap* img; 
     983            byte* pixels; 
    982984            if (imgWidth > imgHeight) { 
    983985                auto hDC = device.internal_new_GC(null); 
     
    993995                OS.SelectObject(memHdc, oldMemBitmap); 
    994996                OS.DeleteObject(memHdc); 
    995                 byte[] srcData = new byte[dibBM.bmWidthBytes * dibBM.bmHeight]; 
    996                 OS.MoveMemory(srcData, dibBM.bmBits, srcData.length); 
     997                byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. dibBM.bmWidthBytes * dibBM.bmHeight].dup; 
    997998                OS.DeleteObject(memDib); 
    998999                OS.SelectObject(srcHdc, iconInfo.hbmMask); 
     
    10101011                OS.DeleteObject(srcHdc); 
    10111012                device.internal_dispose_GC(hDC, null); 
    1012                 int hHeap = OS.GetProcessHeap(); 
    1013                 pixels = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length); 
    1014                 if (pixels is 0) DWT.error(DWT.ERROR_NO_HANDLES); 
    1015                 OS.MoveMemory(pixels, srcData, srcData.length)
     1013                auto hHeap = OS.GetProcessHeap(); 
     1014                pixels = cast(byte*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length); 
     1015                if (pixels is null) DWT.error(DWT.ERROR_NO_HANDLES); 
     1016                pixels[ 0 .. srcData.length ] = srcData[]
    10161017                img = Gdip.Bitmap_new(imgWidth, imgHeight, dibBM.bmWidthBytes, Gdip.PixelFormat32bppARGB, pixels); 
    10171018            } else { 
    10181019                img = Gdip.Bitmap_new(handle); 
    10191020            } 
    1020             if (iconInfo.hbmColor !is 0) OS.DeleteObject(iconInfo.hbmColor); 
    1021             if (iconInfo.hbmMask !is 0) OS.DeleteObject(iconInfo.hbmMask); 
    1022             return [img, pixels]; 
     1021            if (iconInfo.hbmColor !is null) OS.DeleteObject(iconInfo.hbmColor); 
     1022            if (iconInfo.hbmMask !is null) OS.DeleteObject(iconInfo.hbmMask); 
     1023            return [ cast(int)img, cast(int) pixels ]; 
    10231024        } 
    10241025        default: DWT.error(DWT.ERROR_INVALID_IMAGE); 
     
    10911092 
    10921093    /* Compute the background color */ 
    1093     BITMAP bm = new BITMAP()
    1094     OS.GetObject(handle, BITMAP.sizeof, bm); 
     1094    BITMAP bm
     1095    OS.GetObject(handle, BITMAP.sizeof, &bm); 
    10951096    auto hdcMem = OS.CreateCompatibleDC(hDC); 
    10961097    auto hOldObject = OS.SelectObject(hdcMem, handle); 
     
    10981099    if (bm.bmBitsPixel <= 8)  { 
    10991100        if (OS.IsWinCE) { 
    1100             byte[] pBits = new byte[1]
    1101             OS.MoveMemory(pBits, bm.bmBits, 1); 
     1101            byte* pBits = cast(byte*)bm.bmBits
     1102            //OS.MoveMemory(pBits, bm.bmBits, 1); 
    11021103            byte oldValue = pBits[0]; 
    11031104            int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF; 
    11041105            pBits[0] = cast(byte)((transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask)); 
    1105             OS.MoveMemory(bm.bmBits, pBits, 1); 
     1106            //OS.MoveMemory(bm.bmBits, bm.bmBits, 1); 
    11061107            int color = OS.GetPixel(hdcMem, 0, 0); 
    11071108            pBits[0] = oldValue; 
    1108             OS.MoveMemory(bm.bmBits, pBits, 1); 
     1109            //OS.MoveMemory(bm.bmBits, bm.bmBits, 1); 
    11091110            blue = (color & 0xFF0000) >> 16; 
    11101111            green = (color & 0xFF00) >> 8; 
    11111112            red = color & 0xFF; 
    11121113        } else { 
    1113             byte[] color = new byte[4]
    1114             OS.GetDIBColorTable(hdcMem, transparentPixel, 1, color); 
    1115             blue = color[0] & 0xFF
    1116             green = color[1] & 0xFF
    1117             red = color[2] & 0xFF
     1114            RGBQUAD color
     1115            OS.GetDIBColorTable(hdcMem, transparentPixel, 1, &color); 
     1116            blue = color.rgbBlue
     1117            green = color.rgbGreen
     1118            red = color.rgbRed
    11181119        } 
    11191120    } else { 
     
    11651166    switch (type) { 
    11661167        case DWT.BITMAP: 
    1167             BITMAP bm = new BITMAP()
    1168             OS.GetObject(handle, BITMAP.sizeof, bm); 
     1168            BITMAP bm
     1169            OS.GetObject(handle, BITMAP.sizeof, &bm); 
    11691170            return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight); 
    11701171        case DWT.ICON: 
     
    11721173                return new Rectangle(0, 0, width = data.width, height = data.height); 
    11731174            } else { 
    1174                 ICONINFO info = new ICONINFO()
    1175                 OS.GetIconInfo(handle, info); 
    1176                 int hBitmap = info.hbmColor; 
    1177                 if (hBitmap is 0) hBitmap = info.hbmMask; 
    1178                 bm = new BITMAP()
    1179                 OS.GetObject(hBitmap, BITMAP.sizeof, bm); 
     1175                ICONINFO info
     1176                OS.GetIconInfo(handle, &info); 
     1177                auto hBitmap = info.hbmColor; 
     1178                if (hBitmap is null) hBitmap = info.hbmMask; 
     1179                BITMAP bm
     1180                OS.GetObject(hBitmap, BITMAP.sizeof, &bm); 
    11801181                if (hBitmap is info.hbmMask) bm.bmHeight /= 2; 
    1181                 if (info.hbmColor !is 0) OS.DeleteObject(info.hbmColor); 
    1182                 if (info.hbmMask !is 0) OS.DeleteObject(info.hbmMask); 
     1182                if (info.hbmColor !is null) OS.DeleteObject(info.hbmColor); 
     1183                if (info.hbmMask !is null) OS.DeleteObject(info.hbmMask); 
    11831184                return new Rectangle(0, 0, width = bm.bmWidth, height = bm.bmHeight); 
    11841185            } 
     
    12101211        case DWT.ICON: { 
    12111212            if (OS.IsWinCE) return data; 
    1212             ICONINFO info = new ICONINFO()
     1213            ICONINFO info
    12131214            if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1214             OS.GetIconInfo(handle, info); 
     1215            OS.GetIconInfo(handle, &info); 
    12151216            /* Get the basic BITMAP information */ 
    1216             int hBitmap = info.hbmColor; 
    1217             if (hBitmap is 0) hBitmap = info.hbmMask; 
    1218             bm = new BITMAP(); 
    1219             OS.GetObject(hBitmap, BITMAP.sizeof, bm); 
     1217            auto hBitmap = info.hbmColor; 
     1218            if (hBitmap is null) hBitmap = info.hbmMask; 
     1219            OS.GetObject(hBitmap, BITMAP.sizeof, &bm); 
    12201220            depth = bm.bmPlanes * bm.bmBitsPixel; 
    12211221            width = bm.bmWidth; 
     
    12251225            if (depth <= 8) numColors = 1 << depth; 
    12261226            /* Create the BITMAPINFO */ 
    1227             BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER()
     1227            BITMAPINFOHEADER bmiHeader
    12281228            bmiHeader.biSize = BITMAPINFOHEADER.sizeof; 
    12291229            bmiHeader.biWidth = width; 
     
    12331233            bmiHeader.biCompression = OS.BI_RGB; 
    12341234            byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + numColors * 4]; 
    1235             OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof)
     1235            *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader
    12361236 
    12371237            /* Get the HDC for the device */ 
     
    12421242            auto hOldBitmap = OS.SelectObject(hBitmapDC, hBitmap); 
    12431243            /* Select the palette if necessary */ 
    1244             int oldPalette = 0
     1244            HPALETTE oldPalette
    12451245            if (depth <= 8) { 
    1246                 int hPalette = device.hPalette; 
    1247                 if (hPalette !is 0) { 
     1246                auto hPalette = device.hPalette; 
     1247                if (hPalette !is null) { 
    12481248                    oldPalette = OS.SelectPalette(hBitmapDC, hPalette, false); 
    12491249                    OS.RealizePalette(hBitmapDC); 
     
    12541254            /* Call with null lpBits to get the image size */ 
    12551255            if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1256             OS.GetDIBits(hBitmapDC, hBitmap, 0, height, 0, bmi, OS.DIB_RGB_COLORS); 
    1257             OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof)
     1256            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); 
     1257            bmiHeader = *cast(BITMAPINFOHEADER*)bmi.ptr
    12581258            imageSize = bmiHeader.biSizeImage; 
    1259             byte[] data = new byte[imageSize]; 
    12601259            /* Get the bitmap data */ 
    1261             int hHeap = OS.GetProcessHeap(); 
    1262             int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize); 
    1263             if (lpvBits is 0) DWT.error(DWT.ERROR_NO_HANDLES); 
     1260            auto hHeap = OS.GetProcessHeap(); 
     1261            auto lpvBits = cast(byte*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize); 
     1262            if (lpvBits is null) DWT.error(DWT.ERROR_NO_HANDLES); 
    12641263            if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1265             OS.GetDIBits(hBitmapDC, hBitmap, 0, height, lpvBits, bmi, OS.DIB_RGB_COLORS); 
    1266             OS.MoveMemory(data, lpvBits, imageSize); 
     1264            OS.GetDIBits(hBitmapDC, hBitmap, 0, height, lpvBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); 
     1265            byte[] data = lpvBits[ 0 .. imageSize].dup; /*PORTING_OPTIMIZE?*/ 
    12671266            /* Calculate the palette */ 
    12681267            PaletteData palette = null; 
     
    12871286            /* Do the mask */ 
    12881287            byte [] maskData = null; 
    1289             if (info.hbmColor is 0) { 
     1288            if (info.hbmColor is null) { 
    12901289                /* Do the bottom half of the mask */ 
    1291                 maskData = new byte[imageSize]; 
    12921290                if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1293                 OS.GetDIBits(hBitmapDC, hBitmap, height, height, lpvBits, bmi, OS.DIB_RGB_COLORS); 
    1294                 OS.MoveMemory(maskData, lpvBits, imageSize)
     1291                OS.GetDIBits(hBitmapDC, hBitmap, height, height, lpvBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); 
     1292                maskData = lpvBits[ 0 .. imageSize].dup
    12951293            } else { 
    12961294                /* Do the entire mask */ 
    12971295                /* Create the BITMAPINFO */ 
    1298                 bmiHeader = new BITMAPINFOHEADER()
     1296                bmiHeader = BITMAPINFOHEADER.init
    12991297                bmiHeader.biSize = BITMAPINFOHEADER.sizeof; 
    13001298                bmiHeader.biWidth = width; 
     
    13041302                bmiHeader.biCompression = OS.BI_RGB; 
    13051303                bmi = new byte[BITMAPINFOHEADER.sizeof + 8]; 
    1306                 OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof)
     1304                *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader
    13071305 
    13081306                /* First color black, second color white */ 
     
    13131311                /* Call with null lpBits to get the image size */ 
    13141312                if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1315                 OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, 0, bmi, OS.DIB_RGB_COLORS); 
    1316                 OS.MoveMemory(bmiHeader, bmi, BITMAPINFOHEADER.sizeof)
     1313                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); 
     1314                bmiHeader = *cast(BITMAPINFOHEADER*)bmi.ptr
    13171315                imageSize = bmiHeader.biSizeImage; 
    13181316                maskData = new byte[imageSize]; 
    1319                 int lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize); 
    1320                 if (lpvMaskBits is 0) DWT.error(DWT.ERROR_NO_HANDLES); 
     1317                auto lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize); 
     1318                if (lpvMaskBits is null) DWT.error(DWT.ERROR_NO_HANDLES); 
    13211319                if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 
    1322                 OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, lpvMaskBits, bmi, OS.DIB_RGB_COLORS); 
    1323                 OS.MoveMemory(maskData, lpvMaskBits, imageSize)
     1320                OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, lpvMaskBits, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS); 
     1321                maskData[] = (cast(byte*)lpvMaskBits)[ 0 .. imageSize ]
    13241322                OS.HeapFree(hHeap, 0, lpvMaskBits); 
    13251323                /* Loop to invert the mask */ 
     
    13391337            OS.HeapFree(hHeap, 0, lpvBits); 
    13401338            OS.SelectObject(hBitmapDC, hOldBitmap); 
    1341             if (oldPalette !is 0) { 
     1339            if (oldPalette !is null) { 
    13421340                OS.SelectPalette(hBitmapDC, oldPalette, false); 
    13431341                OS.RealizePalette(hBitmapDC); 
     
    13481346            device.internal_dispose_GC(hDC, null); 
    13491347 
    1350             if (info.hbmColor !is 0) OS.DeleteObject(info.hbmColor); 
    1351             if (info.hbmMask !is 0) OS.DeleteObject(info.hbmMask); 
     1348            if (info.hbmColor !is null) OS.DeleteObject(info.hbmColor); 
     1349            if (info.hbmMask !is null) OS.DeleteObject(info.hbmMask); 
    13521350            /* Construct and return the ImageData */ 
    13531351            ImageData imageData = new ImageData(width, height, depth, palette, 4, data); 
     
    13581356        case DWT.BITMAP: { 
    13591357            /* Get the basic BITMAP information */ 
    1360             bm = new BITMAP()
    1361             OS.GetObject(handle, BITMAP.sizeof, bm); 
     1358            bm = BITMAP.init
     1359            OS.GetObject(handle, BITMAP.sizeof, &bm); 
    13621360            depth = bm.bmPlanes * bm.bmBitsPixel; 
    13631361            width = bm.bmWidth; 
    13641362            height = bm.bmHeight; 
    13651363            /* Find out whether this is a DIB or a DDB. */ 
    1366             bool isDib = (bm.bmBits !is 0); 
     1364            bool isDib = (bm.bmBits !is null); 
    13671365            /* Get the HDC for the device */ 
    13681366            auto hDC = device.internal_new_GC(null); 
     
    13731371            * the bmBits field of DIBSECTION to retrieve the image data. 
    13741372            */ 
    1375             int handle = this.handle; 
     1373            auto handle = this.handle; 
    13761374            if (OS.IsWinCE) { 
    13771375                if (!isDib) { 
     
    13811379                        mustRestore = true; 
    13821380                        GCData data = memGC.data; 
    1383                         if (data.hNullBitmap !is 0) { 
     1381                        if (data.hNullBitmap !is null) { 
    13841382                            OS.SelectObject(memGC.handle, data.hNullBitmap); 
    1385                             data.hNullBitmap = 0
     1383                            data.hNullBitmap = null
    13861384                        } 
    13871385                    } 
     
    13941392                } 
    13951393            } 
    1396             DIBSECTION dib = null
     1394            DIBSECTION dib
    13971395            if (isDib) { 
    1398                 dib = new DIBSECTION(); 
    1399                 OS.GetObject(handle, DIBSECTION.sizeof, dib); 
     1396                OS.GetObject(handle, DIBSECTION.sizeof, &dib); 
    14001397            } 
    14011398            /* Calculate number of colors */ 
     
    14101407            /* Create the BITMAPINFO */ 
    14111408            byte[] bmi = null; 
    1412             BITMAPINFOHEADER bmiHeader = null
     1409            BITMAPINFOHEADER bmiHeader
    14131410            if (!isDib) { 
    1414                 bmiHeader = new BITMAPINFOHEADER(); 
    14151411                bmiHeader.biSize = BITMAPINFOHEADER.sizeof; 
    1416