# HG changeset patch # User John Reimer > 16) & 0xFF) | (foreground & 0xFF00) | ((foreground & 0xFF) << 16); auto color = Gdip.Color_new(data.alpha << 24 | rgb); - if (color is null) DWT.error(DWT.ERROR_NO_HANDLES); - brush = cast(Gdip.Brush*) Gdip.SolidBrush_new(color); + // if (color is null) DWT.error(DWT.ERROR_NO_HANDLES); + brush = cast(Gdip.Brush) Gdip.SolidBrush_new(color); if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); Gdip.Color_delete(color); - data.gdipFgBrush = cast(Gdip.SolidBrush*)brush; + data.gdipFgBrush = cast(Gdip.SolidBrush)brush; } if (pen !is null) { Gdip.Pen_SetBrush(pen, brush); @@ -276,7 +276,7 @@ } } if (dashes !is null) { - Gdip.Pen_SetDashPattern(pen, dashes.ptr, dashes.length); + Gdip.Pen_SetDashPattern(pen, dashes, dashes.length); Gdip.Pen_SetDashStyle(pen, Gdip.DashStyleCustom); Gdip.Pen_SetDashOffset(pen, dashOffset); } else { @@ -315,20 +315,20 @@ case Gdip.BrushTypeTextureFill: auto brush = Gdip.Brush_Clone(data.gdipBrush); if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); - Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend); + Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); data.gdipBrush = brush; - data.gdipBgBrush = cast(Gdip.SolidBrush*) brush; + data.gdipBgBrush = cast(Gdip.SolidBrush) brush; } } } else { auto background = data.background; int rgb = ((background >> 16) & 0xFF) | (background & 0xFF00) | ((background & 0xFF) << 16); auto color = Gdip.Color_new(data.alpha << 24 | rgb); - if (color is null) DWT.error(DWT.ERROR_NO_HANDLES); + // if (color is null) DWT.error(DWT.ERROR_NO_HANDLES); auto brush = Gdip.SolidBrush_new(color); if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES); Gdip.Color_delete(color); - data.gdipBrush = cast(Gdip.Brush*)brush; + data.gdipBrush = cast(Gdip.Brush)brush; data.gdipBgBrush = brush; } } @@ -343,7 +343,7 @@ auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0); float[6] elements; Gdip.Graphics_GetTransform(gdipGraphics, matrix); - Gdip.Matrix_GetElements(matrix, elements.ptr ); + Gdip.Matrix_GetElements(matrix, elements ); Gdip.Matrix_delete(matrix); float scaling = elements[0]; if (scaling < 0) scaling = -scaling; @@ -570,7 +570,7 @@ } } -static Gdip.Font* createGdipFont(HDC hDC, HFONT hFont) { +static Gdip.Font createGdipFont(HDC hDC, HFONT hFont) { auto font = Gdip.Font_new(hDC, hFont); if (font is null) DWT.error(DWT.ERROR_NO_HANDLES); if (!Gdip.Font_IsAvailable(font)) { @@ -604,20 +604,20 @@ return font; } -static void destroyGdipBrush(Gdip.Brush* brush) { +static void destroyGdipBrush(Gdip.Brush brush) { int type = Gdip.Brush_GetType(brush); switch (type) { case Gdip.BrushTypeSolidColor: - Gdip.SolidBrush_delete( cast(Gdip.SolidBrush*)brush); + Gdip.SolidBrush_delete( cast(Gdip.SolidBrush)brush); break; case Gdip.BrushTypeHatchFill: - Gdip.HatchBrush_delete(cast(Gdip.HatchBrush*)brush); + Gdip.HatchBrush_delete(cast(Gdip.HatchBrush)brush); break; case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush*)brush); + Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush)brush); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_delete(cast(Gdip.TextureBrush*)brush); + Gdip.TextureBrush_delete(cast(Gdip.TextureBrush)brush); break; } } @@ -678,8 +678,8 @@ void disposeGdip() { if (data.gdipPen !is null) Gdip.Pen_delete(data.gdipPen); - if (data.gdipBgBrush !is null) destroyGdipBrush(cast(Gdip.Brush*)data.gdipBgBrush); - if (data.gdipFgBrush !is null) destroyGdipBrush(cast(Gdip.Brush*)data.gdipFgBrush); + if (data.gdipBgBrush !is null) destroyGdipBrush(cast(Gdip.Brush)data.gdipBgBrush); + if (data.gdipFgBrush !is null) destroyGdipBrush(cast(Gdip.Brush)data.gdipFgBrush); if (data.gdipFont !is null) Gdip.Font_delete(data.gdipFont); if (data.gdipGraphics !is null) Gdip.Graphics_delete(data.gdipGraphics); data.gdipGraphics = null; @@ -841,7 +841,7 @@ Gdip.Graphics_GetTransform(gdipGraphics, matrix); if (!Gdip.Matrix_IsIdentity(matrix)) { gotElements = true; - Gdip.Matrix_GetElements(matrix, lpXform.ptr); + Gdip.Matrix_GetElements(matrix, lpXform); } Gdip.Matrix_delete(matrix); hdc = Gdip.Graphics_GetHDC(gdipGraphics); @@ -939,7 +939,7 @@ if (data.gdipGraphics !is null) { //TODO - cache bitmap int[] gdipImage = srcImage.createGdipImage(); - auto img = cast(Gdip.Image*) gdipImage[0]; + auto img = cast(Gdip.Image) gdipImage[0]; int imgWidth = Gdip.Image_GetWidth(img); int imgHeight = Gdip.Image_GetHeight(img); if (simple) { @@ -964,29 +964,37 @@ */ auto attrib = Gdip.ImageAttributes_new(); Gdip.ImageAttributes_SetWrapMode(attrib, Gdip.WrapModeTileFlipXY); - if (data.alpha !is 0xFF) { + if (data.alpha != 0xFF) { + + Gdip.ColorMatrix matrix = + { [ [1,0,0,0,0], + [0,1,0,0,0], + [0,0,1,0,0], + [0,0,0,data.alpha / cast(float)0xFF,0,], + [0,0,0,0,1] ] }; + /* float[] matrix = [ cast(float) 1,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,data.alpha / cast(float)0xFF,0, 0,0,0,0,1, - ]; - Gdip.ImageAttributes_SetColorMatrix(attrib, matrix.ptr, Gdip.ColorMatrixFlagsDefault, Gdip.ColorAdjustTypeBitmap); + ];*/ + Gdip.ImageAttributes_SetColorMatrix(attrib, matrix, Gdip.ColorMatrixFlagsDefault, Gdip.ColorAdjustTypeBitmap); } int gstate = 0; - if ((data.style & DWT.MIRRORED) !is 0) { + if ((data.style & DWT.MIRRORED) != 0) { gstate = Gdip.Graphics_Save(data.gdipGraphics); Gdip.Graphics_ScaleTransform(data.gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend); Gdip.Graphics_TranslateTransform(data.gdipGraphics, - 2 * destX - destWidth, 0, Gdip.MatrixOrderPrepend); } - Gdip.Graphics_DrawImage(data.gdipGraphics, img, &rect, srcX, srcY, srcWidth, srcHeight, Gdip.UnitPixel, attrib, null, null); - if ((data.style & DWT.MIRRORED) !is 0) { + Gdip.Graphics_DrawImage(data.gdipGraphics, img, rect, srcX, srcY, srcWidth, srcHeight, Gdip.UnitPixel, attrib, null, null); + if ((data.style & DWT.MIRRORED) != 0) { Gdip.Graphics_Restore(data.gdipGraphics, gstate); } Gdip.ImageAttributes_delete(attrib); - Gdip.Bitmap_delete( cast(Gdip.Bitmap*) img); - if (gdipImage[1] !is 0) { + Gdip.Bitmap_delete( cast(Gdip.Bitmap) img); + if (gdipImage[1] != 0) { auto hHeap = OS.GetProcessHeap (); OS.HeapFree(hHeap, 0, cast(void*)gdipImage[1]); } @@ -1793,14 +1801,14 @@ *
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
  • * */ -public void drawPolygon(int[] pointArray) { +public void drawPolygon( int[] pointArray) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); checkGC(DRAW); auto gdipGraphics = data.gdipGraphics; if (gdipGraphics !is null) { Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); - Gdip.Graphics_DrawPolygon(gdipGraphics, data.gdipPen, pointArray, pointArray.length / 2); + Gdip.Graphics_DrawPolygon(gdipGraphics, data.gdipPen, cast(Gdip.Point[])pointArray, pointArray.length/2); Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); return; } @@ -1811,7 +1819,7 @@ } } } - OS.Polygon(handle, cast(POINT*)pointArray.ptr, pointArray.length / 2); + OS.Polygon(handle, cast(POINT*)pointArray.ptr, pointArray.length/2); if ((data.style & DWT.MIRRORED) !is 0) { if (data.lineWidth !is 0 && data.lineWidth % 2 is 0) { for (int i = 0; i < pointArray.length; i+=2) { @@ -1845,7 +1853,7 @@ auto gdipGraphics = data.gdipGraphics; if (gdipGraphics !is null) { Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend); - Gdip.Graphics_DrawLines(gdipGraphics, data.gdipPen, cast(Gdip.Point*)pointArray.ptr, pointArray.length / 2); + Gdip.Graphics_DrawLines(gdipGraphics, data.gdipPen, cast(Gdip.Point[])pointArray, pointArray.length / 2); Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend); return; } @@ -2008,7 +2016,7 @@ } } -void drawRoundRectangleGdip (Gdip.Graphics* gdipGraphics, Gdip.Pen* pen, int x, int y, int width, int height, int arcWidth, int arcHeight) { +void drawRoundRectangleGdip (Gdip.Graphics gdipGraphics, Gdip.Pen pen, int x, int y, int width, int height, int arcWidth, int arcHeight) { int nx = x; int ny = y; int nw = width; @@ -2116,7 +2124,7 @@ Gdip.StringFormat_SetFormatFlags(format, formatFlags); if (!isTransparent) { Gdip.RectF bounds; - Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, &bounds); + Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.rndint(bounds.Width), Math.rndint(bounds.Height)); } int gstate = 0; @@ -2124,12 +2132,12 @@ if ((data.style & DWT.MIRRORED) !is 0) { switch (Gdip.Brush_GetType(brush)) { case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend); - Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush*)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); + Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); + Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend); - Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush*)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); + Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); + Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); break; } gstate = Gdip.Graphics_Save(gdipGraphics); @@ -2142,10 +2150,10 @@ if ((data.style & DWT.MIRRORED) !is 0) { switch (Gdip.Brush_GetType(brush)) { case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush*)brush); + Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush)brush); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush*)brush); + Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush)brush); break; } Gdip.Graphics_Restore(gdipGraphics, gstate); @@ -2308,13 +2316,13 @@ if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; Gdip.StringFormat_SetFormatFlags(format, formatFlags); float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [ cast(float) measureSpace(data.gdipFont, format) * 8] : new float[1]; - Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs.ptr); + Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs); int hotkeyPrefix = (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone; if ((flags & DWT.DRAW_MNEMONIC) !is 0 && (data.uiState & OS.UISF_HIDEACCEL) !is 0) hotkeyPrefix = Gdip.HotkeyPrefixHide; Gdip.StringFormat_SetHotkeyPrefix(format, hotkeyPrefix); if ((flags & DWT.DRAW_TRANSPARENT) is 0) { Gdip.RectF bounds; - Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, &bounds); + Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.rndint(bounds.Width), Math.rndint(bounds.Height)); } int gstate = 0; @@ -2322,12 +2330,12 @@ if ((data.style & DWT.MIRRORED) !is 0) { switch (Gdip.Brush_GetType(brush)) { case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend); - Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush*)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); + Gdip.LinearGradientBrush_ScaleTransform(cast(Gdip.LinearGradientBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); + Gdip.LinearGradientBrush_TranslateTransform(cast(Gdip.LinearGradientBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend); - Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush*)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); + Gdip.TextureBrush_ScaleTransform(cast(Gdip.TextureBrush)brush, -1, 1, Gdip.MatrixOrderPrepend); + Gdip.TextureBrush_TranslateTransform(cast(Gdip.TextureBrush)brush, - 2 * x, 0, Gdip.MatrixOrderPrepend); break; } gstate = Gdip.Graphics_Save(gdipGraphics); @@ -2340,10 +2348,10 @@ if ((data.style & DWT.MIRRORED) !is 0) { switch (Gdip.Brush_GetType(brush)) { case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush*)brush); + Gdip.LinearGradientBrush_ResetTransform(cast(Gdip.LinearGradientBrush)brush); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush*)brush); + Gdip.TextureBrush_ResetTransform(cast(Gdip.TextureBrush)brush); break; } Gdip.Graphics_Restore(gdipGraphics, gstate); @@ -2606,12 +2614,12 @@ } int rgb = ((fromRGB.red & 0xFF) << 16) | ((fromRGB.green & 0xFF) << 8) | (fromRGB.blue & 0xFF); auto fromGpColor = Gdip.Color_new(data.alpha << 24 | rgb); - if (fromGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); + //if (fromGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); rgb = ((toRGB.red & 0xFF) << 16) | ((toRGB.green & 0xFF) << 8) | (toRGB.blue & 0xFF); auto toGpColor = Gdip.Color_new(data.alpha << 24 | rgb); - if (toGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); + //if (toGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES); auto brush = Gdip.LinearGradientBrush_new(p1, p2, fromGpColor, toGpColor); - Gdip.Graphics_FillRectangle(data.gdipGraphics, cast(Gdip.Brush*)brush, x, y, width, height); + Gdip.Graphics_FillRectangle(data.gdipGraphics, cast(Gdip.Brush)brush, x, y, width, height); Gdip.LinearGradientBrush_delete(brush); Gdip.Color_delete(fromGpColor); Gdip.Color_delete(toGpColor); @@ -2758,7 +2766,7 @@ checkGC(FILL); if (data.gdipGraphics !is null) { int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; - Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, pointArray, pointArray.length / 2, mode); + Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, cast(Gdip.Point[])pointArray, pointArray.length / 2, mode); return; } if ((data.style & DWT.MIRRORED) !is 0) { @@ -2855,7 +2863,7 @@ OS.RoundRect(handle, x,y,x+width+1,y+height+1,arcWidth, arcHeight); } -void fillRoundRectangleGdip (Gdip.Graphics* gdipGraphics, Gdip.Brush* brush, int x, int y, int width, int height, int arcWidth, int arcHeight) { +void fillRoundRectangleGdip (Gdip.Graphics gdipGraphics, Gdip.Brush brush, int x, int y, int width, int height, int arcWidth, int arcHeight) { int nx = x; int ny = y; int nw = width; @@ -3224,8 +3232,8 @@ return csi.ciACP; } -Gdip.Brush* getFgBrush() { - return data.foregroundPattern !is null ? data.foregroundPattern.handle : cast(Gdip.Brush*)data.gdipFgBrush; +Gdip.Brush getFgBrush() { + return data.foregroundPattern !is null ? data.foregroundPattern.handle : cast(Gdip.Brush)data.gdipFgBrush; } /** @@ -3650,7 +3658,7 @@ } } -Gdip.Matrix* identity() { +Gdip.Matrix identity() { if ((data.style & DWT.MIRRORED) !is 0) { int width = 0; Image image = data.image; @@ -3770,10 +3778,10 @@ return handle is null; } -float measureSpace(Gdip.Font* font, Gdip.StringFormat* format) { +float measureSpace(Gdip.Font font, Gdip.StringFormat format) { Gdip.PointF pt; Gdip.RectF bounds; - Gdip.Graphics_MeasureString(data.gdipGraphics, (" "w).ptr, 1, font, pt, format, &bounds); + Gdip.Graphics_MeasureString(data.gdipGraphics, (" "w).ptr, 1, font, pt, format, bounds); return bounds.Width; } @@ -4693,7 +4701,7 @@ int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces; if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; Gdip.StringFormat_SetFormatFlags(format, formatFlags); - Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, &bounds); + Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); Gdip.StringFormat_delete(format); return new Point(length_ is 0 ? 0 : Math.rndint(bounds.Width), Math.rndint(bounds.Height)); } @@ -4787,9 +4795,9 @@ if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft; Gdip.StringFormat_SetFormatFlags(format, formatFlags); float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [measureSpace(data.gdipFont, format) * 8] : new float[1]; - Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs.ptr); + Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs); Gdip.StringFormat_SetHotkeyPrefix(format, (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone); - Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, &bounds); + Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds); Gdip.StringFormat_delete(format); return new Point(length_ is 0 ? 0 : Math.rndint(bounds.Width), Math.rndint(bounds.Height)); } diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/GCData.d --- a/dwt/graphics/GCData.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/GCData.d Sun Feb 03 15:48:14 2008 -0800 @@ -56,12 +56,12 @@ public HWND hwnd; public PAINTSTRUCT* ps; public int layout = -1; - public Gdip.Graphics* gdipGraphics; - public Gdip.Pen* gdipPen; - public Gdip.Brush* gdipBrush; - public Gdip.SolidBrush* gdipFgBrush; - public Gdip.SolidBrush* gdipBgBrush; - public Gdip.Font* gdipFont; + public Gdip.Graphics gdipGraphics; + public Gdip.Pen gdipPen; + public Gdip.Brush gdipBrush; + public Gdip.SolidBrush gdipFgBrush; + public Gdip.SolidBrush gdipBgBrush; + public Gdip.Font gdipFont; public float gdipXOffset, gdipYOffset; } diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/Image.d --- a/dwt/graphics/Image.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/Image.d Sun Feb 03 15:48:14 2008 -0800 @@ -607,18 +607,18 @@ auto bitmap = Gdip.Bitmap_new( .StrToWCHARz( filename ), false); if (bitmap !is null) { int error = DWT.ERROR_NO_HANDLES; - int status = Gdip.Image_GetLastStatus(cast(Gdip.Image*)bitmap); + int status = Gdip.Image_GetLastStatus(cast(Gdip.Image)bitmap); if (status is 0) { if (filename.toLowerCase().endsWith(".ico")) { this.type = DWT.ICON; HICON hicon; - Gdip.Bitmap_GetHICON(bitmap, &hicon); + Gdip.Bitmap_GetHICON(bitmap, hicon); this.handle = hicon; } else { this.type = DWT.BITMAP; - int width = Gdip.Image_GetWidth(cast(Gdip.Image*)bitmap); - int height = Gdip.Image_GetHeight(cast(Gdip.Image*)bitmap); - int pixelFormat = Gdip.Image_GetPixelFormat(cast(Gdip.Image*)bitmap); + int width = Gdip.Image_GetWidth(cast(Gdip.Image)bitmap); + int height = Gdip.Image_GetHeight(cast(Gdip.Image)bitmap); + int pixelFormat = Gdip.Image_GetPixelFormat(cast(Gdip.Image)bitmap); switch (pixelFormat) { case Gdip.PixelFormat16bppRGB555: case Gdip.PixelFormat16bppRGB565: @@ -650,7 +650,7 @@ Gdip.Rect rect; rect.Width = width; rect.Height = height; - status = Gdip.Graphics_DrawImage(graphics, cast(Gdip.Image*)bitmap, &rect, 0, 0, width, height, Gdip.UnitPixel, null, null, null); + status = Gdip.Graphics_DrawImage(graphics, cast(Gdip.Image)bitmap, rect, 0, 0, width, height, Gdip.UnitPixel, null, null, null); if (status !is 0) { error = DWT.ERROR_INVALID_IMAGE; OS.DeleteObject(handle); @@ -687,11 +687,11 @@ case Gdip.PixelFormat1bppIndexed: case Gdip.PixelFormat4bppIndexed: case Gdip.PixelFormat8bppIndexed: - int paletteSize = Gdip.Image_GetPaletteSize(cast(Gdip.Image*)bitmap); + int paletteSize = Gdip.Image_GetPaletteSize(cast(Gdip.Image)bitmap); auto hHeap = OS.GetProcessHeap(); auto palette = cast(Gdip.ColorPalette*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, paletteSize); if (palette is null) DWT.error(DWT.ERROR_NO_HANDLES); - Gdip.Image_GetPalette(cast(Gdip.Image*)bitmap, palette, paletteSize); + Gdip.Image_GetPalette(cast(Gdip.Image)bitmap, palette, paletteSize); Gdip.ColorPalette* colorPalette = palette; //Gdip.MoveMemory(colorPalette, palette, ColorPalette.sizeof); int[] entries = new int[colorPalette.Count]; @@ -864,6 +864,12 @@ return hDib; } +// FIXME: Potential crash site in D: createGdipImage casts pointers to int before +// returning them in an int[]. Since the D GC does not and cannot scan int's for +// pointers, there is potential that the pointer's object could be collected while still +// active, even though it might be unlikely given the short span of time that the +// function has them stored in the int array. + int[] createGdipImage() { switch (type) { case DWT.BITMAP: { @@ -883,10 +889,10 @@ OS.GetObject(memDib, BITMAP.sizeof, &dibBM); int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight; OS.BitBlt(memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY); - byte red = 0, green = 0, blue = 0; + ubyte red = 0, green = 0, blue = 0; if (transparentPixel !is -1) { if (bm.bmBitsPixel <= 8) { - byte[] color = new byte[4]; + ubyte[] color = new ubyte[4]; OS.GetDIBColorTable(srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr); blue = color[0]; green = color[1]; @@ -908,14 +914,14 @@ red = reds[(transparentPixel & redMask) >> redShift]; break; case 24: - blue = cast(byte)((transparentPixel & 0xFF0000) >> 16); - green = cast(byte)((transparentPixel & 0xFF00) >> 8); - red = cast(byte)(transparentPixel & 0xFF); + blue = cast(ubyte)((transparentPixel & 0xFF0000) >> 16); + green = cast(ubyte)((transparentPixel & 0xFF00) >> 8); + red = cast(ubyte)(transparentPixel & 0xFF); break; case 32: - blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24); - green = cast(byte)((transparentPixel & 0xFF0000) >> 16); - red = cast(byte)((transparentPixel & 0xFF00) >> 8); + blue = cast(ubyte)((transparentPixel & 0xFF000000) >>> 24); + green = cast(ubyte)((transparentPixel & 0xFF0000) >> 16); + red = cast(ubyte)((transparentPixel & 0xFF00) >> 8); break; } } @@ -924,13 +930,13 @@ OS.SelectObject(memHdc, oldMemBitmap); OS.DeleteObject(srcHdc); OS.DeleteObject(memHdc); - byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ].dup; + ubyte[] srcData = (cast(ubyte*)dibBM.bmBits)[ 0 .. sizeInBytes ].dup; OS.DeleteObject(memDib); device.internal_dispose_GC(hDC, null); if (alpha !is -1) { for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { - srcData[dp + 3] = cast(byte)alpha; + srcData[dp + 3] = cast(ubyte)alpha; dp += 4; } } @@ -945,19 +951,19 @@ for (int y = 0, dp = 0; y < imgHeight; ++y) { for (int x = 0; x < imgWidth; ++x) { if (srcData[dp] is blue && srcData[dp + 1] is green && srcData[dp + 2] is red) { - srcData[dp + 3] = cast(byte)0; + srcData[dp + 3] = cast(ubyte)0; } else { - srcData[dp + 3] = cast(byte)0xFF; + srcData[dp + 3] = cast(ubyte)0xFF; } dp += 4; } } } auto hHeap = OS.GetProcessHeap(); - auto pixels = cast(byte*)OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length); + auto pixels = cast(ubyte*)OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length); if (pixels is null) DWT.error(DWT.ERROR_NO_HANDLES); OS.MoveMemory(pixels, srcData.ptr, sizeInBytes); - return [ cast(int)Gdip.Bitmap_new(imgWidth, imgHeight, dibBM.bmWidthBytes, Gdip.PixelFormat32bppARGB, pixels), cast(int) pixels]; + return [ cast(int)(Gdip.Bitmap_new(imgWidth, imgHeight, dibBM.bmWidthBytes, Gdip.PixelFormat32bppARGB, pixels)), cast(int) pixels]; } return [cast(int)Gdip.Bitmap_new(handle, null), 0]; } @@ -979,8 +985,8 @@ OS.GetObject(hBitmap, BITMAP.sizeof, &bm); int imgWidth = bm.bmWidth; int imgHeight = hBitmap is iconInfo.hbmMask ? bm.bmHeight / 2 : bm.bmHeight; - Gdip.Bitmap* img; - byte* pixels; + Gdip.Bitmap img; + ubyte* pixels; if (imgWidth > imgHeight) { auto hDC = device.internal_new_GC(null); auto srcHdc = OS.CreateCompatibleDC(hDC); @@ -994,15 +1000,15 @@ 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 = (cast(byte*)dibBM.bmBits)[ 0 .. dibBM.bmWidthBytes * dibBM.bmHeight].dup; + ubyte[] srcData = (cast(ubyte*)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) { for (int x = 0; x < imgWidth; ++x) { if (OS.GetPixel(srcHdc, x, y) !is 0) { - srcData[dp + 3] = cast(byte)0; + srcData[dp + 3] = cast(ubyte)0; } else { - srcData[dp + 3] = cast(byte)0xFF; + srcData[dp + 3] = cast(ubyte)0xFF; } dp += 4; } @@ -1011,7 +1017,7 @@ OS.DeleteObject(srcHdc); device.internal_dispose_GC(hDC, null); auto hHeap = OS.GetProcessHeap(); - pixels = cast(byte*) OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, srcData.length); + pixels = cast(ubyte*) 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); diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/Path.d --- a/dwt/graphics/Path.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/Path.d Sun Feb 03 15:48:14 2008 -0800 @@ -59,7 +59,7 @@ * platforms and should never be accessed from application code. *

    */ - public Gdip.GraphicsPath* handle; + public Gdip.Path handle; Gdip.PointF currentPoint, startPoint; @@ -136,7 +136,7 @@ } if (width is 0 || height is 0 || arcAngle is 0) return; if (width is height) { - Gdip.GraphicsPath_AddArc(handle, x, y, width, height, -startAngle, -arcAngle); + Gdip.GraphicsPath_AddArcF(handle, x, y, width, height, -startAngle, -arcAngle); } else { auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate); if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); @@ -193,7 +193,7 @@ rect.Y = y; rect.Width = width; rect.Height = height; - Gdip.GraphicsPath_AddRectangle(handle, &rect); + Gdip.GraphicsPath_AddRectangle(handle, rect); currentPoint.X = x; currentPoint.Y = y; } @@ -400,7 +400,7 @@ byte[] gdipTypes = new byte[count]; float[] points = new float[count * 2]; Gdip.GraphicsPath_GetPathTypes(handle, gdipTypes, count); - Gdip.GraphicsPath_GetPathPoints(handle, points.ptr, count); + Gdip.GraphicsPath_GetPathPoints(handle, cast(Gdip.PointF[])points, count); byte[] types = new byte[count * 2]; int index = 0, typesIndex = 0; while (index < count) { diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/Pattern.d --- a/dwt/graphics/Pattern.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/Pattern.d Sun Feb 03 15:48:14 2008 -0800 @@ -53,7 +53,7 @@ * platforms and should never be accessed from application code. *

    */ - public Gdip.Brush* handle; + public Gdip.Brush handle; /** * Constructs a new Pattern given an image. Drawing with the resulting @@ -88,11 +88,11 @@ this.device = device; device.checkGDIP(); int[] gdipImage = image.createGdipImage(); - auto img = cast(Gdip.Image*)gdipImage[0]; + auto img = cast(Gdip.Image)gdipImage[0]; int width = Gdip.Image_GetWidth(img); int height = Gdip.Image_GetHeight(img); - handle = cast(Gdip.Brush*)Gdip.TextureBrush_new(img, Gdip.WrapModeTile, 0, 0, width, height); - Gdip.Bitmap_delete( cast(Gdip.Bitmap*)img); + handle = cast(Gdip.Brush)Gdip.TextureBrush_new(img, Gdip.WrapModeTile, 0, 0, width, height); + Gdip.Bitmap_delete( cast(Gdip.Bitmap)img); if (gdipImage[1] !is 0) { auto hHeap = OS.GetProcessHeap (); OS.HeapFree(hHeap, 0, cast(void*)gdipImage[1]); @@ -186,7 +186,7 @@ int rgb = ((colorRef1 >> 16) & 0xFF) | (colorRef1 & 0xFF00) | ((colorRef1 & 0xFF) << 16); auto foreColor = Gdip.Color_new((alpha1 & 0xFF) << 24 | rgb); if (x1 is x2 && y1 is y2) { - handle = cast(Gdip.Brush*)Gdip.SolidBrush_new(foreColor); + handle = cast(Gdip.Brush)Gdip.SolidBrush_new(foreColor); if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); } else { auto colorRef2 = color2.handle; @@ -198,23 +198,23 @@ Gdip.PointF p2; p2.X = x2; p2.Y = y2; - handle = cast(Gdip.Brush*)Gdip.LinearGradientBrush_new(p1, p2, foreColor, backColor); + handle = cast(Gdip.Brush)Gdip.LinearGradientBrush_new(p1, p2, foreColor, backColor); if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); - if (alpha1 !is 0xFF || alpha2 !is 0xFF) { + if (alpha1 != 0xFF || alpha2 !is 0xFF) { int a = cast(int)((alpha1 & 0xFF) * 0.5f + (alpha2 & 0xFF) * 0.5f); int r = cast(int)(((colorRef1 & 0xFF) >> 0) * 0.5f + ((colorRef2 & 0xFF) >> 0) * 0.5f); int g = cast(int)(((colorRef1 & 0xFF00) >> 8) * 0.5f + ((colorRef2 & 0xFF00) >> 8) * 0.5f); int b = cast(int)(((colorRef1 & 0xFF0000) >> 16) * 0.5f + ((colorRef2 & 0xFF0000) >> 16) * 0.5f); auto midColor = Gdip.Color_new(a << 24 | r << 16 | g << 8 | b); - Gdip.Color[3] c; - c[0] = *foreColor; - c[1] = *midColor; - c[2] = *backColor; + Gdip.ARGB[3] c; + c[0] = foreColor; + c[1] = midColor; + c[2] = backColor; float[3] f; f[0] = 0; f[1] = 0.5f; f[2] = 1; - Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush*)handle, c.ptr, f.ptr, 3); + Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush)handle, c, f, 3); Gdip.Color_delete(midColor); } Gdip.Color_delete(backColor); @@ -234,16 +234,16 @@ int type = Gdip.Brush_GetType(handle); switch (type) { case Gdip.BrushTypeSolidColor: - Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)handle); + Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)handle); break; case Gdip.BrushTypeHatchFill: - Gdip.HatchBrush_delete(cast(Gdip.HatchBrush*)handle); + Gdip.HatchBrush_delete(cast(Gdip.HatchBrush)handle); break; case Gdip.BrushTypeLinearGradient: - Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush*)handle); + Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush)handle); break; case Gdip.BrushTypeTextureFill: - Gdip.TextureBrush_delete(cast(Gdip.TextureBrush*)handle); + Gdip.TextureBrush_delete(cast(Gdip.TextureBrush)handle); break; } handle = null; diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/TextLayout.d --- a/dwt/graphics/TextLayout.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/TextLayout.d Sun Feb 03 15:48:14 2008 -0800 @@ -583,7 +583,7 @@ Gdip.Matrix_delete(identity_); if (!Gdip.Matrix_IsIdentity(matrix)) { lpXform = new float[6]; - Gdip.Matrix_GetElements(matrix, lpXform.ptr); + Gdip.Matrix_GetElements(matrix, lpXform); } Gdip.Matrix_delete(matrix); if ((data.style & DWT.MIRRORED) !is 0 && lpXform !is null) { @@ -601,7 +601,7 @@ hdc = Gdip.Graphics_GetHDC(gdipGraphics); } } - Gdip.Brush* foregroundBrush; + Gdip.Brush foregroundBrush; int state = 0; if (gdip) { gc.checkGC(GC.FOREGROUND); @@ -645,7 +645,7 @@ argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16); color = Gdip.Color_new(argb); selBrushFg = Gdip.SolidBrush_new(color); - selPen = Gdip.Pen_new( cast(Gdip.Brush*)selBrushFg, 1); + selPen = Gdip.Pen_new( cast(Gdip.Brush)selBrushFg, 1); Gdip.Color_delete(color); } else { selBrush = OS.CreateSolidBrush(selectionBackground.handle); @@ -682,7 +682,7 @@ width = (lineHeight - lineSpacing) / 3; } if (gdip) { - Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing); + Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing); } else { OS.SelectObject(hdc, selBrush); OS.PatBlt(hdc, drawX + lineWidth[line], drawY, width, lineHeight - lineSpacing, OS.PATCOPY); @@ -706,7 +706,7 @@ bool fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end; if (fullSelection) { if (gdip) { - Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, drawX, drawY, run.width, lineHeight - lineSpacing); + Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, drawX, drawY, run.width, lineHeight - lineSpacing); } else { OS.SelectObject(hdc, selBrush); OS.PatBlt(hdc, drawX, drawY, run.width, lineHeight - lineSpacing, OS.PATCOPY); @@ -719,7 +719,7 @@ int argb = ((alpha & 0xFF) << 24) | ((bg >> 16) & 0xFF) | (bg & 0xFF00) | ((bg & 0xFF) << 16); auto color = Gdip.Color_new(argb); auto brush = Gdip.SolidBrush_new(color); - Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)brush, drawX, drawRunY, run.width, run.ascent + run.descent); + Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)brush, drawX, drawRunY, run.width, run.ascent + run.descent); Gdip.Color_delete(color); Gdip.SolidBrush_delete(brush); } else { @@ -747,7 +747,7 @@ rect.right = drawX + runX; rect.bottom = drawY + lineHeight - lineSpacing; if (gdip) { - Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush*)selBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); + Gdip.Graphics_FillRectangle(gdipGraphics, cast(Gdip.Brush)selBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } else { OS.SelectObject(hdc, selBrush); OS.PatBlt(hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); @@ -806,17 +806,17 @@ if ((type & OS.PT_CLOSEFIGURE) !is 0) newType |= Gdip.PathPointTypeCloseSubpath; types[typeIndex] = cast(byte)newType; } - auto path = Gdip.GraphicsPath_new(cast(Gdip.Point*)points.ptr, cast(byte*)types.ptr, count, Gdip.FillModeAlternate); + auto path = Gdip.GraphicsPath_new(cast(Gdip.Point[])points, types, count, Gdip.FillModeAlternate); if (path is null) DWT.error(DWT.ERROR_NO_HANDLES); auto brush = foregroundBrush; if (fullSelection) { - brush = cast(Gdip.Brush*)selBrushFg; + brush = cast(Gdip.Brush)selBrushFg; } else { if (run.style !is null && run.style.foreground !is null) { auto fg = run.style.foreground.handle; int argb = ((alpha & 0xFF) << 24) | ((fg >> 16) & 0xFF) | (fg & 0xFF00) | ((fg & 0xFF) << 16); auto color = Gdip.Color_new(argb); - brush = cast(Gdip.Brush*)Gdip.SolidBrush_new(color); + brush = cast(Gdip.Brush)Gdip.SolidBrush_new(color); Gdip.Color_delete(color); } } @@ -852,7 +852,7 @@ } Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias); if (run.style !is null && (run.style.underline || run.style.strikeout)) { - auto newPen = hasSelection ? cast(Gdip.Pen*)selPen : Gdip.Pen_new(brush, 1); + auto newPen = hasSelection ? cast(Gdip.Pen)selPen : Gdip.Pen_new(brush, 1); Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); if (run.style.underline) { int underlineY = drawY + baseline + 1 - run.style.rise; @@ -862,7 +862,7 @@ int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2; Gdip.Graphics_DrawLine(gdipGraphics, newPen, drawX, strikeoutY, drawX + run.width, strikeoutY); } - if (newPen !is selPen) Gdip.Pen_delete(newPen); + if (cast(void*)newPen !is selPen) Gdip.Pen_delete(newPen); Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); } if (partialSelection) { @@ -870,30 +870,31 @@ gstate = Gdip.Graphics_Save(gdipGraphics); Gdip.Graphics_SetClip(gdipGraphics, &gdipRect, Gdip.CombineModeIntersect); Gdip.Graphics_SetSmoothingMode(gdipGraphics, textAntialias); - Gdip.Graphics_FillPath(gdipGraphics, cast(Gdip.Brush*)selBrushFg, path); + Gdip.Graphics_FillPath(gdipGraphics, cast(Gdip.Brush)selBrushFg, path); Gdip.Graphics_SetSmoothingMode(gdipGraphics, antialias); if (run.style !is null && (run.style.underline || run.style.strikeout)) { Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone); if (run.style.underline) { int underlineY = drawY + baseline + 1 - run.style.rise; - Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen*)selPen, rect.left, underlineY, rect.right, underlineY); + Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, underlineY, rect.right, underlineY); } if (run.style.strikeout) { int strikeoutY = drawRunY + run.leading + (run.ascent - run.style.rise) / 2; - Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen*)selPen, rect.left, strikeoutY, rect.right, strikeoutY); + Gdip.Graphics_DrawLine(gdipGraphics, cast(Gdip.Pen)selPen, rect.left, strikeoutY, rect.right, strikeoutY); } Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf); } Gdip.Graphics_Restore(gdipGraphics, gstate); } Gdip.GraphicsPath_delete(path); - if (brush !is selBrushFg && brush !is foregroundBrush) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)brush); - } else { - int fg = foreground; - if (fullSelection) { - fg = selectionForeground.handle; - } else { - if (run.style !is null && run.style.foreground !is null) fg = run.style.foreground.handle; + if ( brush !is cast(Gdip.Brush)selBrushFg && brush !is cast(Gdip.Brush)foregroundBrush) + Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)brush); + } else { + int fg = foreground; + if (fullSelection) { + fg = selectionForeground.handle; + } else { + if (run.style !is null && run.style.foreground !is null) fg = run.style.foreground.handle; } OS.SetTextColor(hdc, fg); OS.ScriptTextOut(hdc, run.psc, drawX + offset, drawRunY, 0, null, &run.analysis , null, 0, run.glyphs, run.glyphCount, run.advances, run.justify, run.goffsets); @@ -938,9 +939,9 @@ } } if (gdip) { - if (selBrush !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)selBrush); - if (selBrushFg !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush*)selBrushFg); - if (selPen !is null) Gdip.Pen_delete(cast(Gdip.Pen*)selPen); + if (selBrush !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrush); + if (selBrushFg !is null) Gdip.SolidBrush_delete(cast(Gdip.SolidBrush)selBrushFg); + if (selPen !is null) Gdip.Pen_delete(cast(Gdip.Pen)selPen); } else { OS.RestoreDC(hdc, state); if (gdipGraphics !is null) Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc); diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/graphics/Transform.d --- a/dwt/graphics/Transform.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/graphics/Transform.d Sun Feb 03 15:48:14 2008 -0800 @@ -49,7 +49,7 @@ * platforms and should never be accessed from application code. *

    */ - public Gdip.Matrix* handle; + public Gdip.Matrix handle; /** * Constructs a new identity Transform. @@ -183,7 +183,7 @@ if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); if (elements is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (elements.length < 6) DWT.error(DWT.ERROR_INVALID_ARGUMENT); - Gdip.Matrix_GetElements(handle, elements.ptr); + Gdip.Matrix_GetElements(handle, elements); } /** @@ -318,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(Gdip.PointF*)pointArray.ptr, pointArray.length / 2); + Gdip.Matrix_TransformPoints(handle, cast(Gdip.PointF[])pointArray, pointArray.length / 2); } /** diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/internal/gdip/Gdip.d --- a/dwt/internal/gdip/Gdip.d Sun Feb 03 05:06:44 2008 +0100 +++ b/dwt/internal/gdip/Gdip.d Sun Feb 03 15:48:14 2008 -0800 @@ -6,573 +6,2308 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * D Port: + * John Reimer + * Frank Benoit *******************************************************************************/ + module dwt.internal.gdip.Gdip; +import dwt.internal.gdip.native; + import dwt.internal.Library; import dwt.internal.Platform; -import dwt.internal.win32.OS; - - - -alias extern(Windows) void function(int level, char *message) DebugEventProc; -struct GdiplusStartupInput { - uint GdiplusVersion; - DebugEventProc DebugEventCallback; - int SuppressBackgroundThread; - int SuppressExternalCodecs; -} -alias extern(Windows) int function(uint* token) NotificationHookProc; -alias extern(Windows) void function(uint* token) NotificationUnhookProc; -struct GdiplusStartupOutput { - NotificationHookProc NotificationHook; - NotificationUnhookProc NotificationUnhook; -}; - -struct API { - static extern(Windows) int GdiplusStartup( - uint** token, - GdiplusStartupInput *input, - GdiplusStartupOutput *output - ); - static extern(Windows) void GdiplusShutdown( - uint** token - ); - -} - - -public class Gdip : Platform { - - /** GdiPlus constants */ - public static const int BrushTypeSolidColor = 0; - public static const int BrushTypeHatchFill = 1; - public static const int BrushTypeTextureFill = 2; - public static const int BrushTypePathGradient = 3; - public static const int BrushTypeLinearGradient = 4; - public static const int ColorAdjustTypeBitmap = 1; - public static const int ColorMatrixFlagsDefault = 0; - public static const int CombineModeReplace = 0; - public static const int CombineModeIntersect = 1; - public static const int CombineModeUnion = 2; - public static const int CombineModeXor = 3; - public static const int CombineModeExclude = 4; - public static const int CombineModeComplement = 5; - public static const int FillModeAlternate = 0; - public static const int FillModeWinding = 1; - public static const int DashCapFlat = 0; - public static const int DashCapRound = 2; - public static const int DashCapTriangle = 3; - public static const int DashStyleSolid = 0; - public static const int DashStyleDash = 1; - public static const int DashStyleDot = 2; - public static const int DashStyleDashDot = 3; - public static const int DashStyleDashDotDot = 4; - public static const int DashStyleCustom = 5; - public static const int FontStyleRegular = 0; - public static const int FontStyleBold = 1; - public static const int FontStyleItalic = 2; - public static const int FontStyleBoldItalic = 3; - public static const int FontStyleUnderline = 4; - public static const int FontStyleStrikeout = 8; - public static const int PaletteFlagsHasAlpha = 0x0001; - public static const int FlushIntentionFlush = 0; - public static const int FlushIntentionSync = 1; - public static const int HotkeyPrefixNone = 0; - public static const int HotkeyPrefixShow = 1; - public static const int HotkeyPrefixHide = 2; - public static const int LineJoinMiter = 0; - public static const int LineJoinBevel = 1; - public static const int LineJoinRound = 2; - public static const int LineCapFlat = 0; - public static const int LineCapSquare = 1; - public static const int LineCapRound = 2; - public static const int MatrixOrderPrepend = 0; - public static const int MatrixOrderAppend = 1; - public static const int QualityModeDefault = 0; - public static const int QualityModeLow = 1; - public static const int QualityModeHigh = 2; - public static const int InterpolationModeDefault = QualityModeDefault; - public static const int InterpolationModeLowQuality = QualityModeLow; - public static const int InterpolationModeHighQuality = QualityModeHigh; - public static const int InterpolationModeBilinear = QualityModeHigh + 1; - public static const int InterpolationModeBicubic = QualityModeHigh + 2; - public static const int InterpolationModeNearestNeighbor = QualityModeHigh + 3; - public static const int InterpolationModeHighQualityBilinear = QualityModeHigh + 4; - public static const int InterpolationModeHighQualityBicubic = QualityModeHigh + 5; - public static const int PathPointTypeStart = 0; - public static const int PathPointTypeLine = 1; - public static const int PathPointTypeBezier = 3; - public static const int PathPointTypePathTypeMask = 0x7; - public static const int PathPointTypePathDashMode = 0x10; - public static const int PathPointTypePathMarker = 0x20; - public static const int PathPointTypeCloseSubpath = 0x80; - public static const int PathPointTypeBezier3 = 3; - public static const int PixelFormatIndexed = 0x00010000; - public static const int PixelFormatGDI = 0x00020000; - public static const int PixelFormatAlpha = 0x00040000; - public static const int PixelFormatPAlpha = 0x00080000; - public static const int PixelFormatExtended = 0x00100000; - public static const int PixelFormatCanonical = 0x00200000; - public static const int PixelFormat1bppIndexed = (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI); - public static const int PixelFormat4bppIndexed = (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI); - public static const int PixelFormat8bppIndexed = (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI); - public static const int PixelFormat16bppGrayScale = (4 | (16 << 8) | PixelFormatExtended); - public static const int PixelFormat16bppRGB555 = (5 | (16 << 8) | PixelFormatGDI); - public static const int PixelFormat16bppRGB565 = (6 | (16 << 8) | PixelFormatGDI); - public static const int PixelFormat16bppARGB1555 = (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI); - public static const int PixelFormat24bppRGB = (8 | (24 << 8) | PixelFormatGDI); - public static const int PixelFormat32bppRGB = (9 | (32 << 8) | PixelFormatGDI); - public static const int PixelFormat32bppARGB = (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical); - public static const int PixelFormat32bppPARGB = (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI); - public static const int PixelFormat48bppRGB = (12 | (48 << 8) | PixelFormatExtended); - public static const int PixelFormat64bppARGB = (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended); - public static const int PixelFormat64bppPARGB = (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended); - public static const int PixelFormatMax = 15; - public static const int PixelOffsetModeNone = QualityModeHigh + 1; - public static const int PixelOffsetModeHalf = QualityModeHigh + 2; - public static const int SmoothingModeDefault = QualityModeDefault; - public static const int SmoothingModeHighSpeed = QualityModeLow; - public static const int SmoothingModeHighQuality = QualityModeHigh; - public static const int SmoothingModeNone = 3; - public static const int SmoothingModeAntiAlias8x4 = 4; - public static const int SmoothingModeAntiAlias = SmoothingModeAntiAlias8x4; - public static const int SmoothingModeAntiAlias8x8 = 5; - public static const int StringFormatFlagsDirectionRightToLeft = 0x00000001; - public static const int StringFormatFlagsDirectionVertical = 0x00000002; - public static const int StringFormatFlagsNoFitBlackBox = 0x00000004; - public static const int StringFormatFlagsDisplayFormatControl = 0x00000020; - public static const int StringFormatFlagsNoFontFallback = 0x00000400; - public static const int StringFormatFlagsMeasureTrailingSpaces = 0x00000800; - public static const int StringFormatFlagsNoWrap = 0x00001000; - public static const int StringFormatFlagsLineLimit = 0x00002000; - public static const int StringFormatFlagsNoClip = 0x00004000; - public static const int TextRenderingHintSystemDefault = 0; - public static const int TextRenderingHintSingleBitPerPixelGridFit = 1; - public static const int TextRenderingHintSingleBitPerPixel = 2; - public static const int TextRenderingHintAntiAliasGridFit = 3; - public static const int TextRenderingHintAntiAlias = 4; - public static const int TextRenderingHintClearTypeGridFit = 5; - public static const int UnitPixel = 2; - public static const int WrapModeTile = 0; - public static const int WrapModeTileFlipX = 1; - public static const int WrapModeTileFlipY = 2; - public static const int WrapModeTileFlipXY = 3; - public static const int WrapModeClamp = 4; - - -public struct RectF { - public float X; - public float Y; - public float Width; - public float Height; -} - -public struct Rect { - public int X; - public int Y; - public int Width; - public int Height; -} -public struct Point { - public int X; - public int Y; -} -public struct PointF { - public float X; - public float Y; -} - -public struct ColorPalette { - public int Flags; - public int Count; - public int[1] Entries; -} -public struct BitmapData { - public int Width; - public int Height; - public int Stride; - public int PixelFormat; - public void* Scan0; - public int Reserved; +import dwt.internal.win32.WINTYPES; +import dwt.internal.win32.WINAPI; + + +alias dwt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput; +alias dwt.internal.gdip.native.GdiplusStartupOutput GdiplusStartupOutput; + +/****************************************************************************** + + Gdip Class: provides access to the Gdi+ interface + +/*****************************************************************************/ + +public class Gdip : Platform +{ + + /************************************************************************** + + **************************************************************************/ + +private: + + static FontFamily GenericSansSerifFontFamily = null; + static FontFamily GenericSerifFontFamily = null; + static FontFamily GenericMonospaceFontFamily = null; + + /************************************************************************** + + **************************************************************************/ + + struct FontFamily_T + { + Handle nativeFamily; + Status lastResult; + } + + struct StringFormat_T + { + + StringFormat format; + Status lastError; + } + + static ubyte GenericTypographicStringFormatBuffer[StringFormat_T.sizeof] = 0; + static ubyte GenericDefaultStringFormatBuffer [StringFormat_T.sizeof] = 0; + static ubyte GenericSansSerifFontFamilyBuffer [FontFamily_T.sizeof] = 0; + static ubyte GenericSerifFontFamilyBuffer [FontFamily_T.sizeof] = 0; + static ubyte GenericMonospaceFontFamilyBuffer [FontFamily_T.sizeof] = 0; + + /************************************************************************** + + **************************************************************************/ + +public: + + alias GpPoint Point; + alias GpPointF PointF; + alias GpRect Rect; + alias GpRectF RectF; + alias GpBitmapData BitmapData; + alias GpColorPalette ColorPalette; + alias GpDrawImageAbort DrawImageAbort; + alias GpColorMatrix ColorMatrix; + + alias GpFontFamily FontFamily; + alias GpImage Image; + alias GpBrush Brush; + alias GpFont Font; + alias GpFontCollection FontCollection; + alias GpGraphics Graphics; + alias GpGraphicsPath GraphicsPath; + alias GpImageAttributes ImageAttributes; + alias GpHatchBrush HatchBrush; + alias GpLinearGradientBrush LinearGradientBrush; + alias GpMatrix Matrix; + alias GpPen Pen; + alias GpRegion Region; + alias GpSolidBrush SolidBrush; + alias GpStringFormat StringFormat; + alias GpTextureBrush TextureBrush; + alias GpPath Path; + + alias Image Bitmap; + + alias uint ARGB; + + alias dwt.internal.gdip.native.GdiplusStartupInput GdiplusStartupInput; + alias dwt.internal.gdip.native.GdiplusStartupOutput GdiplusStartupOutput; + + /************************************************************************** + + Gdi+ Constants + + **************************************************************************/ + + enum { + BrushTypeSolidColor = 0, + BrushTypeHatchFill = 1, + BrushTypeTextureFill = 2, + BrushTypePathGradient = 3, + BrushTypeLinearGradient = 4, + // ColorAdjustTypeBitmap = 1, + ColorMatrixFlagsDefault = 0, + CombineModeReplace = 0, + CombineModeIntersect = 1, + CombineModeUnion = 2, + CombineModeXor = 3, + CombineModeExclude = 4, + CombineModeComplement = 5, + FillModeAlternate = 0, + FillModeWinding = 1, + DashCapFlat = 0, + DashCapRound = 2, + DashCapTriangle = 3, + DashStyleSolid = 0, + DashStyleDash = 1, + DashStyleDot = 2, + DashStyleDashDot = 3, + DashStyleDashDotDot = 4, + DashStyleCustom = 5, + FontStyleRegular = 0, + FontStyleBold = 1, + FontStyleItalic = 2, + FontStyleBoldItalic = 3, + FontStyleUnderline = 4, + FontStyleStrikeout = 8, + PaletteFlagsHasAlpha = 0x0001, + FlushIntentionFlush = 0, + FlushIntentionSync = 1, + HotkeyPrefixNone = 0, + HotkeyPrefixShow = 1, + HotkeyPrefixHide = 2, + LineJoinMiter = 0, + LineJoinBevel = 1, + LineJoinRound = 2, + LineCapFlat = 0, + LineCapSquare = 1, + LineCapRound = 2, + MatrixOrderPrepend = 0, + MatrixOrderAppend = 1, + QualityModeDefault = 0, + QualityModeLow = 1, + QualityModeHigh = 2, + InterpolationModeInvalid = -1, + InterpolationModeDefault = QualityModeDefault, + InterpolationModeLowQuality = QualityModeLow, + InterpolationModeHighQuality = QualityModeHigh, + InterpolationModeBilinear = QualityModeHigh + 1, + InterpolationModeBicubic = QualityModeHigh + 2, + InterpolationModeNearestNeighbor = QualityModeHigh + 3, + InterpolationModeHighQualityBilinear = QualityModeHigh + 4, + InterpolationModeHighQualityBicubic = QualityModeHigh + 5, + PathPointTypeStart = 0, + PathPointTypeLine = 1, + PathPointTypeBezier = 3, + PathPointTypePathTypeMask = 0x7, + PathPointTypePathDashMode = 0x10, + PathPointTypePathMarker = 0x20, + PathPointTypeCloseSubpath = 0x80, + PathPointTypeBezier3 = 3, + PixelFormatIndexed = 0x00010000, + PixelFormatGDI = 0x00020000, + PixelFormatAlpha = 0x00040000, + PixelFormatPAlpha = 0x00080000, + PixelFormatExtended = 0x00100000, + PixelFormatCanonical = 0x00200000, + PixelFormat1bppIndexed = (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI), + PixelFormat4bppIndexed = (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI), + PixelFormat8bppIndexed = (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI), + PixelFormat16bppGrayScale = (4 | (16 << 8) | PixelFormatExtended), + PixelFormat16bppRGB555 = (5 | (16 << 8) | PixelFormatGDI), + PixelFormat16bppRGB565 = (6 | (16 << 8) | PixelFormatGDI), + PixelFormat16bppARGB1555 = (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI), + PixelFormat24bppRGB = (8 | (24 << 8) | PixelFormatGDI), + PixelFormat32bppRGB = (9 | (32 << 8) | PixelFormatGDI), + PixelFormat32bppARGB = (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical), + PixelFormat32bppPARGB = (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI), + PixelFormat48bppRGB = (12 | (48 << 8) | PixelFormatExtended), + PixelFormat64bppARGB = (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended), + PixelFormat64bppPARGB = (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended), + PixelFormatMax = 15, + PixelOffsetModeNone = QualityModeHigh + 1, + PixelOffsetModeHalf = QualityModeHigh + 2, + SmoothingModeInvalid = -1, + SmoothingModeDefault = QualityModeDefault, + SmoothingModeHighSpeed = QualityModeLow, + SmoothingModeHighQuality = QualityModeHigh, + SmoothingModeNone = 3, + SmoothingModeAntiAlias8x4 = 4, + SmoothingModeAntiAlias = SmoothingModeAntiAlias8x4, + SmoothingModeAntiAlias8x8 = 5, + StringFormatFlagsDirectionRightToLeft = 0x00000001, + StringFormatFlagsDirectionVertical = 0x00000002, + StringFormatFlagsNoFitBlackBox = 0x00000004, + StringFormatFlagsDisplayFormatControl = 0x00000020, + StringFormatFlagsNoFontFallback = 0x00000400, + StringFormatFlagsMeasureTrailingSpaces = 0x00000800, + StringFormatFlagsNoWrap = 0x00001000, + StringFormatFlagsLineLimit = 0x00002000, + StringFormatFlagsNoClip = 0x00004000, + TextRenderingHintSystemDefault = 0, + TextRenderingHintSingleBitPerPixelGridFit = 1, + TextRenderingHintSingleBitPerPixel = 2, + TextRenderingHintAntiAliasGridFit = 3, + TextRenderingHintAntiAlias = 4, + TextRenderingHintClearTypeGridFit = 5, + // UnitPixel = 2, + WrapModeTile = 0, + WrapModeTileFlipX = 1, + WrapModeTileFlipY = 2, + WrapModeTileFlipXY = 3, + WrapModeClamp = 4 + } + + enum + { + PenTypeSolidColor = BrushTypeSolidColor, + PenTypeHatchFill = BrushTypeHatchFill, + PenTypeTextureFill = BrushTypeTextureFill, + PenTypePathGradient = BrushTypePathGradient, + PenTypeLinearGradient = BrushTypeLinearGradient, + PenTypeUnknown = -1 + } + + enum + { + UnitWorld, // 0 -- World coordinate (non-physical unit) + UnitDisplay, // 1 -- Variable -- for PageTransform only + UnitPixel, // 2 -- Each unit is one device pixel. + UnitPoint, // 3 -- Each unit is a printer's point, or 1/72 inch. + UnitInch, // 4 -- Each unit is 1 inch. + UnitDocument, // 5 -- Each unit is 1/300 inch. + UnitMillimeter // 6 -- Each unit is 1 millimeter. + } + + enum + { + AliceBlue = 0xFFF0F8FF, + AntiqueWhite = 0xFFFAEBD7, + Aqua = 0xFF00FFFF, + Aquamarine = 0xFF7FFFD4, + Azure = 0xFFF0FFFF, + Beige = 0xFFF5F5DC, + Bisque = 0xFFFFE4C4, + Black = 0xFF000000, + BlanchedAlmond = 0xFFFFEBCD, + Blue = 0xFF0000FF, + BlueViolet = 0xFF8A2BE2, + Brown = 0xFFA52A2A, + BurlyWood = 0xFFDEB887, + CadetBlue = 0xFF5F9EA0, + Chartreuse = 0xFF7FFF00, + Chocolate = 0xFFD2691E, + Coral = 0xFFFF7F50, + CornflowerBlue = 0xFF6495ED, + Cornsilk = 0xFFFFF8DC, + Crimson = 0xFFDC143C, + Cyan = 0xFF00FFFF, + DarkBlue = 0xFF00008B, + DarkCyan = 0xFF008B8B, + DarkGoldenrod = 0xFFB8860B, + DarkGray = 0xFFA9A9A9, + DarkGreen = 0xFF006400, + DarkKhaki = 0xFFBDB76B, + DarkMagenta = 0xFF8B008B, + DarkOliveGreen = 0xFF556B2F, + DarkOrange = 0xFFFF8C00, + DarkOrchid = 0xFF9932CC, + DarkRed = 0xFF8B0000, + DarkSalmon = 0xFFE9967A, + DarkSeaGreen = 0xFF8FBC8B, + DarkSlateBlue = 0xFF483D8B, + DarkSlateGray = 0xFF2F4F4F, + DarkTurquoise = 0xFF00CED1, + DarkViolet = 0xFF9400D3, + DeepPink = 0xFFFF1493, + DeepSkyBlue = 0xFF00BFFF, + DimGray = 0xFF696969, + DodgerBlue = 0xFF1E90FF, + Firebrick = 0xFFB22222, + FloralWhite = 0xFFFFFAF0, + ForestGreen = 0xFF228B22, + Fuchsia = 0xFFFF00FF, + Gainsboro = 0xFFDCDCDC, + GhostWhite = 0xFFF8F8FF, + Gold = 0xFFFFD700, + Goldenrod = 0xFFDAA520, + Gray = 0xFF808080, + Green = 0xFF008000, + GreenYellow = 0xFFADFF2F, + Honeydew = 0xFFF0FFF0, + HotPink = 0xFFFF69B4, + IndianRed = 0xFFCD5C5C, + Indigo = 0xFF4B0082, + Ivory = 0xFFFFFFF0, + Khaki = 0xFFF0E68C, + Lavender = 0xFFE6E6FA, + LavenderBlush = 0xFFFFF0F5, + LawnGreen = 0xFF7CFC00, + LemonChiffon = 0xFFFFFACD, + LightBlue = 0xFFADD8E6, + LightCoral = 0xFFF08080, + LightCyan = 0xFFE0FFFF, + LightGoldenrodYellow = 0xFFFAFAD2, + LightGray = 0xFFD3D3D3, + LightGreen = 0xFF90EE90, + LightPink = 0xFFFFB6C1, + LightSalmon = 0xFFFFA07A, + LightSeaGreen = 0xFF20B2AA, + LightSkyBlue = 0xFF87CEFA, + LightSlateGray = 0xFF778899, + LightSteelBlue = 0xFFB0C4DE, + LightYellow = 0xFFFFFFE0, + Lime = 0xFF00FF00, + LimeGreen = 0xFF32CD32, + Linen = 0xFFFAF0E6, + Magenta = 0xFFFF00FF, + Maroon = 0xFF800000, + MediumAquamarine = 0xFF66CDAA, + MediumBlue = 0xFF0000CD, + MediumOrchid = 0xFFBA55D3, + MediumPurple = 0xFF9370DB, + MediumSeaGreen = 0xFF3CB371, + MediumSlateBlue = 0xFF7B68EE, + MediumSpringGreen = 0xFF00FA9A, + MediumTurquoise = 0xFF48D1CC, + MediumVioletRed = 0xFFC71585, + MidnightBlue = 0xFF191970, + MintCream = 0xFFF5FFFA, + MistyRose = 0xFFFFE4E1, + Moccasin = 0xFFFFE4B5, + NavajoWhite = 0xFFFFDEAD, + Navy = 0xFF000080, + OldLace = 0xFFFDF5E6, + Olive = 0xFF808000, + OliveDrab = 0xFF6B8E23, + Orange = 0xFFFFA500, + OrangeRed = 0xFFFF4500, + Orchid = 0xFFDA70D6, + PaleGoldenrod = 0xFFEEE8AA, + PaleGreen = 0xFF98FB98, + PaleTurquoise = 0xFFAFEEEE, + PaleVioletRed = 0xFFDB7093, + PapayaWhip = 0xFFFFEFD5, + PeachPuff = 0xFFFFDAB9, + Peru = 0xFFCD853F, + Pink = 0xFFFFC0CB, + Plum = 0xFFDDA0DD, + PowderBlue = 0xFFB0E0E6, + Purple = 0xFF800080, + Red = 0xFFFF0000, + RosyBrown = 0xFFBC8F8F, + RoyalBlue = 0xFF4169E1, + SaddleBrown = 0xFF8B4513, + Salmon = 0xFFFA8072, + SandyBrown = 0xFFF4A460, + SeaGreen = 0xFF2E8B57, + SeaShell = 0xFFFFF5EE, + Sienna = 0xFFA0522D, + Silver = 0xFFC0C0C0, + SkyBlue = 0xFF87CEEB, + SlateBlue = 0xFF6A5ACD, + SlateGray = 0xFF708090, + Snow = 0xFFFFFAFA, + SpringGreen = 0xFF00FF7F, + SteelBlue = 0xFF4682B4, + Tan = 0xFFD2B48C, + Teal = 0xFF008080, + Thistle = 0xFFD8BFD8, + Tomato = 0xFFFF6347, + Transparent = 0x00FFFFFF, + Turquoise = 0xFF40E0D0, + Violet = 0xFFEE82EE, + Wheat = 0xFFF5DEB3, + White = 0xFFFFFFFF, + WhiteSmoke = 0xFFF5F5F5, + Yellow = 0xFFFFFF00, + YellowGreen = 0xFF9ACD32 + } + + // Shift count and bit mask for A, R, G, B components + + enum + { + AlphaShift = 24, + RedShift = 16, + GreenShift = 8, + BlueShift = 0 + } + + enum + { + AlphaMask = 0xff000000, + RedMask = 0x00ff0000, + GreenMask = 0x0000ff00, + BlueMask = 0x000000ff + } + + enum + { + ColorAdjustTypeDefault, + ColorAdjustTypeBitmap, + ColorAdjustTypeBrush, + ColorAdjustTypePen, + ColorAdjustTypeText, + ColorAdjustTypeCount, + ColorAdjustTypeAny // Reserved + } + + static ARGB MakeARGB( ubyte a, + ubyte r, + ubyte g, + ubyte b ) + { + return ((cast(ARGB) (b) << Gdip.BlueShift) | + (cast(ARGB) (g) << Gdip.GreenShift) | + (cast(ARGB) (r) << Gdip.RedShift) | + (cast(ARGB) (a) << Gdip.AlphaShift)); + } + +/************************************************************************** + + Error Status control + +**************************************************************************/ + + private static Status SetStatus( Status status ) + { + if (status != Status.OK) + return ( lastResult = status ); + else + return status; + } + + private static Status lastResult; + +/************************************************************************** + + GDI+ Bitmap Wrap Interface + +**************************************************************************/ + +public: + + static void BitmapData_delete (BitmapData* bitmapdata) + { + delete bitmapdata; + } + + /************************************************************************** + + **************************************************************************/ + + static BitmapData* BitmapData_new() + { + return new BitmapData; + } + + /************************************************************************** + + **************************************************************************/ + + static int Bitmap_GetHBITMAP( Bitmap bitmap, ARGB colorBackground, + out HBITMAP hbmReturn ) + { + return SetStatus( GdipCreateHBITMAPFromBitmap( bitmap, hbmReturn, + colorBackground ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Bitmap_GetHICON( Bitmap bitmap, out HICON hIconReturn) + { + return SetStatus( GdipCreateHICONFromBitmap( bitmap, hIconReturn ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Bitmap_LockBits( Bitmap bitmap, Rect* rect, + uint flags, PixelFormat pixelFormat, + BitmapData* lockedBitmapData ) + { + return SetStatus( GdipBitmapLockBits( bitmap, rect, flags, + pixelFormat, lockedBitmapData ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Bitmap_UnlockBits( Bitmap bitmap, BitmapData* lockedBitmapData ) + { + return SetStatus( GdipBitmapUnlockBits( bitmap, lockedBitmapData ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static void Bitmap_delete( Bitmap bitmap ) + { + GdipDisposeImage( bitmap ); + } + + /************************************************************************** + + **************************************************************************/ + + static Bitmap Bitmap_new( HICON hicon ) + { + Bitmap bitmap; + Gdip.lastResult = GdipCreateBitmapFromHICON( hicon, bitmap ); + return bitmap; + } + + /************************************************************************** + + **************************************************************************/ + + static Bitmap Bitmap_new( HBITMAP hbm, HPALETTE hpal ) + { + Bitmap bitmap; + Gdip.lastResult = GdipCreateBitmapFromHBITMAP( hbm, hpal, bitmap ); + return bitmap; + } + + /************************************************************************** + + **************************************************************************/ + + static Bitmap Bitmap_new( int width, int height, int stride, + PixelFormat format, ubyte* scan0 ) + { + Bitmap bitmap; + Gdip.lastResult = GdipCreateBitmapFromScan0( width, height, stride, + format, scan0, + bitmap ); + return bitmap; + } + + /************************************************************************** + + **************************************************************************/ + + static Bitmap Bitmap_new( wchar* filename, bool useIcm ) + { + Bitmap bitmap; + if (useIcm) { + Gdip.lastResult = GdipCreateBitmapFromFileICM( filename, bitmap ); + } else { + Gdip.lastResult = GdipCreateBitmapFromFile( filename, bitmap ); + } + return bitmap; + } + + +/************************************************************************** + + Gdi+ Image Wrap Interface + +**************************************************************************/ + + static Status Image_GetLastStatus( Image image ) + { + Status lastStatus = Gdip.lastResult; + Gdip.lastResult = Status.OK; + return lastStatus; + } + + /************************************************************************** + + **************************************************************************/ + + static PixelFormat Image_GetPixelFormat( Image image ) + { + PixelFormat format; + SetStatus( GdipGetImagePixelFormat( image, format ) ); + return format; + } + + /************************************************************************** + + **************************************************************************/ + + static uint Image_GetWidth( Image image ) + { + uint width = 0; + SetStatus( GdipGetImageWidth( image, width ) ); + return width; + } + + /************************************************************************** + + **************************************************************************/ + + static uint Image_GetHeight( Image image ) + { + uint height = 0; + SetStatus( GdipGetImageHeight( image, height ) ); + return height; + } + + /************************************************************************** + + **************************************************************************/ + + static Status Image_GetPalette( Image image, ColorPalette* palette, int size ) + { + return SetStatus( GdipGetImagePalette( image, palette, size ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Image_GetPaletteSize( Image image ) + { + int size = 0; + SetStatus( GdipGetImagePaletteSize( image, size ) ); + return size; + } + +/************************************************************************** + + Gdi+ ImageAttributes Wrap Interface + +**************************************************************************/ + + static ImageAttributes ImageAttributes_new() + { + ImageAttributes ImageAttr = null; + Gdip.lastResult = GdipCreateImageAttributes( ImageAttr ); + return ImageAttr; + } + + /************************************************************************** + + **************************************************************************/ + + static void ImageAttributes_delete( ImageAttributes attrib ) + { + GdipDisposeImageAttributes( attrib ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status ImageAttributes_SetWrapMode( ImageAttributes attrib, + WrapMode wrap, + ARGB color = Gdip.Black, + bool clamp = false ) + { + return SetStatus(GdipSetImageAttributesWrapMode( + attrib, wrap, color, clamp)); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status ImageAttributes_SetColorMatrix( ImageAttributes attrib, + ref ColorMatrix matrix, + ColorMatrixFlag mode = Gdip.ColorMatrixFlagsDefault, + ColorAdjustType type = Gdip.ColorAdjustTypeDefault ) + { + return SetStatus( GdipSetImageAttributesColorMatrix( + attrib, + type, + true, + &matrix, + null, + mode)); + } + + +/************************************************************************** + + Gdi+ Brush Wrap Interface + +**************************************************************************/ + + static Brush Brush_Clone( Brush brush ) + { + Brush cloneBrush; + SetStatus( GdipCloneBrush( brush, cloneBrush ) ); + return cloneBrush; + } + + /************************************************************************** + + **************************************************************************/ + + static BrushType Brush_GetType( Brush brush ) + { + BrushType brushType = -1; + SetStatus( GdipGetBrushType( brush, brushType ) ); + return brushType; + } + +/************************************************************************** + + Gdi+ HatchedBrush Wrap Interface + +**************************************************************************/ + + static void HatchBrush_delete( HatchBrush brush ) + { + GdipDeleteBrush(brush); + } + + /************************************************************************** + + **************************************************************************/ + + static HatchBrush HatchBrush_new( HatchStyle hatchStyle, + ARGB foreColor, ARGB backColor ) + { + HatchBrush brush = null; + + Gdip.lastResult = GdipCreateHatchBrush( hatchStyle, + foreColor, + backColor, + brush ); + return brush; + } + +/************************************************************************** + + Gdi+ LinearGradientBrush Wrap Interface + +**************************************************************************/ + + static LinearGradientBrush LinearGradientBrush_new( ref PointF point1, ref PointF point2, + ARGB color1, ARGB color2 ) + { + LinearGradientBrush brush = null; + + lastResult = GdipCreateLineBrush(point1, point2, + color1, color2, + WrapModeTile, brush); + return brush; + + } + + /************************************************************************** + + **************************************************************************/ + + static void LinearGradientBrush_delete( LinearGradientBrush brush ) + { + GdipDeleteBrush(brush); + } + + /************************************************************************** + + **************************************************************************/ + + static Status LinearGradientBrush_SetInterpolationColors( LinearGradientBrush brush, + ARGB[] presetColors, float[] blendPositions, int count ) + { + if ((count <= 0) || presetColors is null) + return SetStatus(Status.InvalidParameter); + + return SetStatus(GdipSetLinePresetBlend(brush, presetColors.ptr, + blendPositions.ptr, + count ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status LinearGradientBrush_SetWrapMode( LinearGradientBrush brush, WrapMode wrapMode ) + { + return SetStatus(GdipSetLineWrapMode( brush, wrapMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status LinearGradientBrush_ResetTransform(LinearGradientBrush brush ) + { + return SetStatus(GdipResetLineTransform(brush)); + } + + /************************************************************************** + + **************************************************************************/ + + static int LinearGradientBrush_ScaleTransform( LinearGradientBrush brush, + float sx, float sy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipScaleLineTransform(brush, sx, sy, order)); + } + + /************************************************************************** + + **************************************************************************/ + + static int LinearGradientBrush_TranslateTransform( LinearGradientBrush brush, + float dx, float dy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipTranslateLineTransform(brush, dx, dy, order)); + } + + +/************************************************************************** + + GDI+ TextureBrush Wrap Interface + +**************************************************************************/ + + static TextureBrush TextureBrush_new( Image image, WrapMode wrapMode, + float dstX, float dstY, + float dstWidth, float dstHeight ) + { + TextureBrush brush = null; + + Gdip.lastResult = GdipCreateTexture2( image, + wrapMode, + dstX, dstY, + dstWidth, dstHeight, + brush ); + return brush; + + } + + /************************************************************************** + + **************************************************************************/ + + static void TextureBrush_delete( TextureBrush brush ) + { + GdipDeleteBrush( brush ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status TextureBrush_SetTransform( TextureBrush brush, Matrix matrix ) + { + return SetStatus(GdipSetTextureTransform(brush, matrix)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status TextureBrush_ResetTransform( TextureBrush brush ) + { + return SetStatus(GdipResetTextureTransform(brush)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status TextureBrush_ScaleTransform( TextureBrush brush, + float sx, float sy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipScaleTextureTransform(brush, sx, sy, order)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status TextureBrush_TranslateTransform( TextureBrush brush, + float dx, float dy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipTranslateTextureTransform(brush, dx, dy, order)); + } + + +/************************************************************************** + + GDI+ Pen Wrap Interface + +**************************************************************************/ + + static SolidBrush SolidBrush_new( ARGB color ) + { + SolidBrush brush = null; + + Gdip.lastResult = GdipCreateSolidFill( color, brush ); + + return brush; + } + + /************************************************************************** + + **************************************************************************/ + + static void SolidBrush_delete( SolidBrush brush ) + { + GdipDeleteBrush(brush); + } + +/************************************************************************** + + GDI+ Pen Wrap Interface + +**************************************************************************/ + + static Pen Pen_new( Brush brush, float width ) + { + Unit unit = UnitWorld; + Pen pen = null; + Gdip.lastResult = GdipCreatePen2(brush, width, unit, pen); + return pen; + } + + /************************************************************************** + + **************************************************************************/ + + static void Pen_delete( Pen pen ) + { + GdipDeletePen(pen); + } + + /************************************************************************** + + **************************************************************************/ + + static PenType Pen_GetPenType( Pen pen ) + { + PenType type; + SetStatus(GdipGetPenFillType( pen, type )); + return type; + } + + /************************************************************************** + + **************************************************************************/ + + static Brush Pen_GetBrush( Pen pen ) + { + Brush brush; + SetStatus(GdipGetPenBrushFill(pen, brush)); + return brush; + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetBrush( Pen pen, Brush brush ) + { + return SetStatus(GdipSetPenBrushFill(pen, brush)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetDashOffset( Pen pen, float dashOffset ) + { + return SetStatus(GdipSetPenDashOffset(pen, dashOffset)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetDashPattern( Pen pen, float[] dashArray, int count ) + { + return SetStatus(GdipSetPenDashArray(pen, dashArray.ptr, count)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetDashStyle( Pen pen, DashStyle dashStyle ) + { + return SetStatus(GdipSetPenDashStyle(pen, dashStyle)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetLineCap( Pen pen, LineCap startCap, LineCap endCap, DashCap dashCap ) + { + return SetStatus(GdipSetPenLineCap197819(pen, startCap, endCap, dashCap)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetLineJoin( Pen pen, LineJoin lineJoin ) + { + return SetStatus(GdipSetPenLineJoin(pen, lineJoin)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetMiterLimit( Pen pen, float miterLimit ) + { + return SetStatus(GdipSetPenMiterLimit(pen, miterLimit)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Pen_SetWidth( Pen pen, float width ) + { + return SetStatus(GdipSetPenWidth(pen, width)); + } + + +/************************************************************************** + + GDI+ Color Wrap Interface + +**************************************************************************/ + + // The following two color functions appear to serve little use + // and should probably be replaced with an actual ARGB type assignment + // wherever they are used. + + // I'm guessing they are being used in case of future adoption of the + // gdi+ Color class functionality in Swt. + + static void Color_delete( ARGB color ) + { + // no op + } + + /************************************************************************** + + **************************************************************************/ + + static ARGB Color_new( ARGB color ) + { + return color; + } + +/************************************************************************** + + GDI+ FontFamily Wrap Interface + +**************************************************************************/ + + static int FontFamily_GetFamilyName( FontFamily family, wchar* name, int language ) + { + return SetStatus( GdipGetFamilyName( family, name, language ) ); + } + + /************************************************************************** + + **************************************************************************/ + + // CAUTION: Next two methods need to be tested - JJR + + static void FontFamily_delete( FontFamily family ) + { + if (family !is null) + GdipDeleteFontFamily( family ); + } + + /************************************************************************** + + FontFamily_new() returns a null because flat Gdi+ FontFamily is + internally assigned a null until it is associated with a font + (see gdi+ C++ wrapper for details). + + **************************************************************************/ + + static FontFamily FontFamily_new() + { + return null; + } + +/************************************************************************** + + GDI+ Font Wrap Interface + +**************************************************************************/ + + + static int Font_GetFamily( Font font, ref FontFamily family ) + { + return SetStatus( GdipGetFamily( font, family ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static float Font_GetSize( Font font ) + { + float size; + SetStatus( GdipGetFontSize( font, size ) ); + return size; + } + + /************************************************************************** + + **************************************************************************/ + + static int Font_GetStyle( Font font ) + { + int style; + SetStatus( GdipGetFontStyle( font, style ) ); + return style; + } + + /************************************************************************** + + **************************************************************************/ + + static bool Font_IsAvailable( Font font ) + { + return (font !is null); + } + + /************************************************************************** + + **************************************************************************/ + + static void Font_delete( Font font ) + { + GdipDeleteFont( font ); + } + + /************************************************************************** + + **************************************************************************/ + + static Font Font_new( HDC hdc, HFONT hfont ) + { + Font font = null; + + if (hfont is null) { + Gdip.lastResult = GdipCreateFontFromDC( hdc, font ); + } else { + LOGFONTA logfont; + if (GetObjectA( hfont, LOGFONTA.sizeof, &logfont )) + Gdip.lastResult = GdipCreateFontFromLogfontA(hdc, logfont, font); + else + Gdip.lastResult = GdipCreateFontFromDC(hdc, font); + } + + return font; + } + + + /************************************************************************** + + **************************************************************************/ + + static Font Font_new( wchar* familyName, float emSize, int style, uint unit, + FontCollection fontCollection ) + { + Font nativeFont = null; + FontFamily nativeFamily = null; + + Gdip.lastResult = GdipCreateFontFamilyFromName( familyName, fontCollection, nativeFamily ); + + if (Gdip.lastResult != Status.OK) + { + if (GenericSansSerifFontFamily != null) + { + nativeFamily = GenericSansSerifFontFamily; + } + //TODO: access buffer via "ptr" property? + GenericSansSerifFontFamily = cast(FontFamily) GenericSansSerifFontFamilyBuffer; + Gdip.lastResult = GdipGetGenericFontFamilySansSerif( GenericSansSerifFontFamily ); + + nativeFamily = GenericSansSerifFontFamily; + + if (Gdip.lastResult != Status.OK) + return null; + } + + Gdip.lastResult = GdipCreateFont( nativeFamily, emSize, style, unit, nativeFont ); + + if (Gdip.lastResult != Status.OK) + { + if (GenericSansSerifFontFamily != null) + { + nativeFamily = GenericSansSerifFontFamily; + } + + GenericSansSerifFontFamily = cast(FontFamily) GenericSansSerifFontFamilyBuffer; + Gdip.lastResult = GdipGetGenericFontFamilySansSerif( GenericSansSerifFontFamily ); + + nativeFamily = GenericSansSerifFontFamily; + + if (Gdip.lastResult != Status.OK) + return null; + + Gdip.lastResult = GdipCreateFont( nativeFamily, emSize, style, + unit, nativeFont ); + } + + return nativeFont; + } + +/************************************************************************** + + GDI+ Startup and Shutdown Wrap Interface + +**************************************************************************/ + + alias .GdiplusShutdown GdiplusShutdown; + + /************************************************************************** + + **************************************************************************/ + + alias .GdiplusStartup GdiplusStartup; + + +/************************************************************************** + + GDI+ Graphics Path Wrap Interface + +**************************************************************************/ + + static Path GraphicsPath_new( FillMode fillMode = FillModeAlternate ) + { + Path path = null; + lastResult = GdipCreatePath(fillMode, path); + return path; + } + + /************************************************************************** + + **************************************************************************/ + + static Path GraphicsPath_new( Point[] points, ubyte[] types, int count, + FillMode fillMode = FillModeAlternate ) + { + Path path = null; + lastResult = GdipCreatePath2I(points.ptr, types.ptr, count, fillMode, path); + return path; + } + + /************************************************************************** + + **************************************************************************/ + + static void GraphicsPath_delete( Path path ) + { + GdipDeletePath(path); + } + + + static Status GraphicsPath_AddArcF( Path path, float x, float y, + float width, float height, + float startAngle, float sweepAngle ) + { + return SetStatus( GdipAddPathArc( path, x, y, width, + height, startAngle, sweepAngle) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddArc( Path path, int x, int y, + int width, int height, + float startAngle, float sweepAngle ) + { + return SetStatus(GdipAddPathArcI( path, + x, + y, + width, + height, + startAngle, + sweepAngle)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddBezier( Path path, float x1, float y1, + float x2, float y2, + float x3, float y3, + float x4, float y4 ) + { + return SetStatus( GdipAddPathBezier( path, x1, y1, x2, y2, + x3, y3, x4, y4 ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddLine( Path path, float x1, float y1, + float x2, float y2 ) + { + return SetStatus( GdipAddPathLine( path, x1, y1, x2, y2 ) ); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddPath( Path path, Path addingPath, bool connect ) + { + return SetStatus( GdipAddPathPath( path, addingPath, connect ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddRectangle( Path path, RectF rect ) + { + return SetStatus( GdipAddPathRectangle( path, + rect.X, + rect.Y, + rect.Width, + rect.Height ) ); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_AddString( Path path, wchar* string, + int length, FontFamily family, + int style, float emSize, + ref PointF origin, StringFormat format ) + { + RectF rect = { origin.X, origin.Y, 0.0f, 0.0f }; + + return SetStatus( GdipAddPathString( path, string, length, family, + style, emSize, rect, format ) ); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_CloseFigure( Path path ) + { + return SetStatus( GdipClosePathFigure(path) ); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_Flatten( Path path, Matrix matrix, float flatness ) + { + return SetStatus( GdipFlattenPath( path, matrix, flatness ) ); + } + + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_GetBounds( Path path, ref RectF bounds, + Matrix matrix, Pen pen ) + { + + return SetStatus( GdipGetPathWorldBounds( path, bounds, + matrix, pen ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_GetLastPoint( Path path, out PointF lastPoint ) + { + return SetStatus( GdipGetPathLastPoint( path, lastPoint) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_GetPathTypes( Path path, byte[] types, int count ) + { + return SetStatus( GdipGetPathTypes( path, types.ptr, count) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status GraphicsPath_GetPathPoints( Path path, PointF[] points, int count) + { + return SetStatus(GdipGetPathPoints(path, points.ptr, count)); + } + + + /************************************************************************** + + **************************************************************************/ + + static int GraphicsPath_GetPointCount( Path path ) + { + int count = 0; + + SetStatus(GdipGetPointCount(path, count)); + + return count; + } + + /************************************************************************** + + **************************************************************************/ + + static bool GraphicsPath_IsOutlineVisible( Path path, + float x, float y, Pen pen, Graphics g = null ) + { + int booln = false; + SetStatus( GdipIsOutlineVisiblePathPoint( path, x, y, + pen, g, + booln ) ); + return (booln == true); + } + + /************************************************************************** + + **************************************************************************/ + + static bool GraphicsPath_IsVisible( Path path, float x, float y, Graphics graphics ) + { + int booln = false; + + SetStatus(GdipIsVisiblePathPoint(path, x, y, graphics, booln)); + + return (booln == true); + } + + /************************************************************************** + + **************************************************************************/ + + static int GraphicsPath_SetFillMode( Path path, FillMode fillmode ) + { + return SetStatus( GdipSetPathFillMode(path, fillmode) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int GraphicsPath_StartFigure( Path path ) + { + return SetStatus(GdipStartPathFigure(path)); + } + + /************************************************************************** + + **************************************************************************/ + + static int GraphicsPath_Transform( Path path, Matrix matrix ) + { + if(matrix) + return SetStatus( GdipTransformPath(path, matrix)); + else + return Status.OK; + + } + + +/************************************************************************** + + GDI+ Graphics Wrap Interface + +**************************************************************************/ + + static Graphics Graphics_new( HDC hdc ) + { + + Graphics graphics = null; + + Gdip.lastResult = GdipCreateFromHDC(hdc, graphics); + + return graphics; + } + + /************************************************************************** + + **************************************************************************/ + + static void Graphics_delete( Graphics graphics) + { + GdipDeleteGraphics(graphics); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawArc( Graphics graphics, Pen pen, + int x, int y, int width, int height, + float startAngle, float sweepAngle ) + { + return SetStatus(GdipDrawArcI(graphics, pen, + x, y, width, height, + startAngle, sweepAngle)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawEllipse(Graphics graphics, Pen pen, + int x, int y, + int width, int height) + { + return SetStatus(GdipDrawEllipseI(graphics, pen, + x, y, width, height)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawImage(Graphics graphics, Image image, int x, int y) + { + return SetStatus(GdipDrawImageI(graphics,image, x, y)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawImage( Graphics graphics, Image image, ref Rect destRect, + int srcx, int srcy, int srcwidth, int srcheight, + Unit srcUnit, ImageAttributes imageAttributes = null, + DrawImageAbort callback = null, void* callbackData = null ) + { + return SetStatus(GdipDrawImageRectRectI(graphics, image, + destRect.X, destRect.Y, + destRect.Width, destRect.Height, + srcx, srcy, + srcwidth, srcheight, + srcUnit, imageAttributes, + callback, callbackData)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawLine( Graphics graphics, Pen pen, + int x1, int y1, int x2, int y2 ) + { + return SetStatus(GdipDrawLineI(graphics, pen, x1, y1, x2, y2)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawLines( Graphics graphics, Pen pen, Point[] points, uint count ) + { + return SetStatus(GdipDrawLinesI(graphics, pen, points.ptr, count)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawPath( Graphics graphics, Pen pen, Path path ) + { + return SetStatus(GdipDrawPath(graphics, pen, path)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawPolygon(Graphics graphics, Pen pen, Point[] points, uint count ) + { + return SetStatus(GdipDrawPolygonI(graphics, pen, points.ptr, count)); + + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawRectangle( Graphics graphics, Pen pen, int x, int y, + int width, int height ) + { + return SetStatus(GdipDrawRectangleI(graphics, pen, x, y, width, height)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawString( Graphics graphics, wchar* string, int length, + Font font, ref PointF origin, Brush brush ) + { + RectF rect = {origin.X, origin.Y, 0.0f, 0.0f}; + + return SetStatus(GdipDrawString(graphics,string,length, font, rect, null, brush)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_DrawString( Graphics graphics, wchar* string, int length, + Font font, ref PointF origin, + StringFormat format, Brush brush ) + { + RectF rect = { origin.X, origin.Y, 0.0f, 0.0f }; + + return SetStatus(GdipDrawString(graphics, string, length, font, rect, format, brush)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_FillEllipse( Graphics graphics, Brush brush, + int x, int y, + int width, int height ) + { + return SetStatus(GdipFillEllipseI(graphics, brush, x,y, width, height)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_FillPath( Graphics graphics, Brush brush, Path path ) + { + return SetStatus(GdipFillPath(graphics,brush,path)); + } + + /************************************************************************** + + **************************************************************************/ + + static void Graphics_Flush( Graphics graphics, FlushIntention intention = FlushIntentionFlush ) + { + GdipFlush(graphics, intention); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_FillPie( Graphics graphics, Brush brush, + int x, int y, + int width, int height, + float startAngle, float sweepAngle ) + { + return SetStatus(GdipFillPieI(graphics, brush, + x, y, width, height, + startAngle, sweepAngle)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_FillPolygon( Graphics graphics, Brush brush, + Point[] points, int count, FillMode fillMode ) + { + return SetStatus(GdipFillPolygonI(graphics, brush, points.ptr, count, fillMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_FillRectangle( Graphics graphics, Brush brush, + int x, int y, + int width, int height ) + { + return SetStatus(GdipFillRectangleI(graphics, brush, + x, y, + width, height)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_GetClipBounds( Graphics graphics, out RectF rect ) + { + return SetStatus(GdipGetClipBounds(graphics, rect)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_GetClipBounds( Graphics graphics, out Rect rect ) + { + return SetStatus(GdipGetClipBoundsI(graphics, rect)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_GetClip( Graphics graphics, Region region ) + { + return SetStatus(GdipGetClip(graphics, region)); + } + + /************************************************************************** + + **************************************************************************/ + + static HDC Graphics_GetHDC(Graphics graphics) + { + HDC hdc = null; + + SetStatus(GdipGetDC(graphics, hdc)); + + return hdc; + } + + /************************************************************************** + + **************************************************************************/ + + static void Graphics_ReleaseHDC(Graphics graphics, HDC hdc) + { + SetStatus(GdipReleaseDC(graphics, hdc)); + } + + /************************************************************************** + + **************************************************************************/ + + static InterpolationMode Graphics_GetInterpolationMode( Graphics graphics ) + { + InterpolationMode mode = InterpolationModeInvalid; + + SetStatus(GdipGetInterpolationMode(graphics, mode)); + + return mode; + } + + /************************************************************************** + + **************************************************************************/ + + static SmoothingMode Graphics_GetSmoothingMode( Graphics graphics ) + { + SmoothingMode smoothingMode = SmoothingModeInvalid; + + SetStatus(GdipGetSmoothingMode(graphics, smoothingMode)); + + return smoothingMode; + } + + /************************************************************************** + + **************************************************************************/ + + static TextRenderingHint Graphics_GetTextRenderingHint( Graphics graphics ) + { + TextRenderingHint hint; + + SetStatus(GdipGetTextRenderingHint(graphics, hint)); + + return hint; + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_GetTransform( Graphics graphics, Matrix matrix ) + { + return SetStatus(GdipGetWorldTransform(graphics, matrix)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_GetVisibleClipBounds( Graphics graphics, out Rect rect ) + { + + return SetStatus(GdipGetVisibleClipBoundsI(graphics, rect)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_MeasureString( Graphics graphics, wchar* string, int length, + Font font, ref PointF origin, + ref RectF boundingBox ) + { + RectF rect = {origin.X, origin.Y, 0.0f, 0.0f}; + + return SetStatus(GdipMeasureString( + graphics, + string, + length, + font, + rect, + null, + boundingBox, + null, + null + )); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_MeasureString( Graphics graphics, wchar* string, int length, + Font font, ref PointF origin, + StringFormat format, ref RectF boundingBox ) + { + RectF rect = {origin.X, origin.Y, 0.0f, 0.0f}; + + return SetStatus(GdipMeasureString( + graphics, + string, + length, + font, + rect, + format, + boundingBox, + null, + null + )); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_ResetClip( Graphics graphics ) + { + return SetStatus(GdipResetClip(graphics)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_Restore( Graphics graphics, GraphicsState gstate ) + { + return SetStatus(GdipRestoreGraphics(graphics, gstate)); + } + + /************************************************************************** + + **************************************************************************/ + + static GraphicsState Graphics_Save( Graphics graphics ) + { + GraphicsState gstate; + + SetStatus(GdipSaveGraphics(graphics, gstate)); + + return gstate; + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_ScaleTransform( Graphics graphics, float sx, float sy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipScaleWorldTransform(graphics, sx, sy, order)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetClip( Graphics graphics, HRGN hrgn, + CombineMode combineMode = CombineModeReplace ) + { + return SetStatus(GdipSetClipHrgn(graphics, hrgn, combineMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetClip( Graphics graphics, Path path, + CombineMode combineMode = CombineModeReplace ) + { + return SetStatus(GdipSetClipPath(graphics, path, combineMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetClip( Graphics graphics, ref Rect rect, + CombineMode combineMode = CombineModeReplace ) + { + return SetStatus( GdipSetClipRectI( graphics, + rect.X, rect.Y, + rect.Width, rect.Height, + combineMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetCompositingQuality( Graphics graphics, + CompositingQuality compositingQuality ) + { + return SetStatus(GdipSetCompositingQuality(graphics, compositingQuality)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetPageUnit( Graphics graphics, Unit unit ) + { + return SetStatus(GdipSetPageUnit(graphics, unit)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetPixelOffsetMode( Graphics graphics, + PixelOffsetMode pixelOffsetMode ) + { + return SetStatus(GdipSetPixelOffsetMode(graphics, pixelOffsetMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetSmoothingMode( Graphics graphics, + SmoothingMode smoothingMode ) + { + return SetStatus(GdipSetSmoothingMode(graphics, smoothingMode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetTransform( Graphics graphics, Matrix matrix ) + { + return SetStatus(GdipSetWorldTransform(graphics, matrix)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetInterpolationMode( Graphics graphics, + InterpolationMode mode ) + { + return SetStatus(GdipSetInterpolationMode(graphics, mode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_SetTextRenderingHint( Graphics graphics, TextRenderingHint mode ) + { + return SetStatus(GdipSetTextRenderingHint(graphics, mode)); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Graphics_TranslateTransform( Graphics graphics, float dx, float dy, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus(GdipTranslateWorldTransform(graphics, dx, dy, order)); + } + +/************************************************************************** + + Gdi+ Region Wrap Interface + +**************************************************************************/ + + static Region Region_new( HRGN hRgn ) + { + Region region = null; + + Gdip.lastResult = GdipCreateRegionHrgn( hRgn, region); + + return region; + } + + /************************************************************************** + + **************************************************************************/ + + static Region Region_new() + { + Region region = null; + + Gdip.lastResult = GdipCreateRegion(region); + + return region; + } + + /************************************************************************** + + **************************************************************************/ + + static void Region_delete( Region region ) + { + GdipDeleteRegion(region); + } + + /************************************************************************** + + **************************************************************************/ + + static HRGN Region_GetHRGN( Region region, Graphics graphics ) + { + HRGN hrgn; + + SetStatus(GdipGetRegionHRgn(region, graphics, hrgn)); + + return hrgn; + } + + /************************************************************************** + + **************************************************************************/ + + static int Region_IsInfinite( Region region, Graphics graphics ) + { + int booln = false; + + SetStatus(GdipIsInfiniteRegion(region, graphics, booln)); + + return booln; + } + +/************************************************************************** + + Gdi+ Matrix Wrap Interface + +**************************************************************************/ + + static Matrix Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy) + { + Matrix matrix = null; + + Gdip.lastResult = GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, matrix); + + return matrix; + } + + /************************************************************************** + + **************************************************************************/ + + static void Matrix_delete( Matrix matrix ) + { + GdipDeleteMatrix( matrix ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_GetElements( Matrix matrix, float[] m ) + { + return SetStatus( GdipGetMatrixElements( matrix, m.ptr ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_Invert( Matrix matrix ) + { + return SetStatus( GdipInvertMatrix( matrix ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Matrix_IsIdentity( Matrix matrix ) + { + int result = false; + + SetStatus(GdipIsMatrixIdentity( matrix, result ) ); + + return result; + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_Multiply( Matrix nativeMatrix, Matrix matrix, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus( GdipMultiplyMatrix( nativeMatrix, matrix, order) ); + } + + /************************************************************************** + + **************************************************************************/ + + static int Matrix_Rotate( Matrix matrix, float angle, MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus( GdipRotateMatrix( matrix, angle, order ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_Scale( Matrix matrix, float scaleX , float scaleY, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus( GdipScaleMatrix(matrix, scaleX, scaleY, order) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_SetElements( Matrix matrix, float m11, float m12, + float m21, float m22, + float dx, float dy ) + { + return SetStatus( GdipSetMatrixElements( matrix, m11, m12, m21, m22, dx, dy ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_TransformPoints( Matrix matrix, PointF[] pts, int count = 1 ) + { + return SetStatus( GdipTransformMatrixPoints( matrix, pts.ptr, count ) ); + } + + /************************************************************************** + + **************************************************************************/ + + static Status Matrix_Translate( Matrix matrix, float offsetX, float offsetY, + MatrixOrder order = MatrixOrderPrepend ) + { + return SetStatus( GdipTranslateMatrix( matrix, offsetX, offsetY, order ) ); + } + + +/************************************************************************** + + Gdi+ StringFromat Wrap Interface + +**************************************************************************/ + + static void StringFormat_delete( StringFormat format ) + { + GdipDeleteStringFormat( format ); + } + + /************************************************************************** + + **************************************************************************/ + + static StringFormat StringFormat_Clone( StringFormat format ) + { + StringFormat clonedStringFormat = null; + + Gdip.lastResult = GdipCloneStringFormat( format, clonedStringFormat ); + + if (Gdip.lastResult == Status.OK) + return clonedStringFormat; + else + return null; + } + + /************************************************************************** + + **************************************************************************/ + + static StringFormat StringFormat_GenericDefault() + { + // TODO: do we need to access buffer through "ptr" property? + StringFormat genericDefaultStringFormat = + cast(StringFormat) GenericDefaultStringFormatBuffer; + + Gdip.lastResult = GdipStringFormatGetGenericDefault( genericDefaultStringFormat ); + + return genericDefaultStringFormat; + } + + /************************************************************************** + + **************************************************************************/ + + static StringFormat StringFormat_GenericTypographic() + { + // TODO: do we need to access buffer through "ptr" property? + StringFormat genericTypographicStringFormat = + cast(StringFormat) GenericTypographicStringFormatBuffer; + + Gdip.lastResult = GdipStringFormatGetGenericTypographic( + genericTypographicStringFormat ); + + return genericTypographicStringFormat; + } + + /************************************************************************** + + **************************************************************************/ + + // TODO: StringFormat class in Gdi+ maintains it's own lastError status + // Right now all lastError and lastResult status for dwt's gdip objects + // are combined in one Gdip SetStatus method and lastResult member. + // Consider if there is a need to maintain per object lastResult + // monitoring. For now, this /should/ work as is. + + static int StringFormat_GetFormatFlags(StringFormat format) + { + int flags; + SetStatus( GdipGetStringFormatFlags(format, flags)); + return flags; + } + + /************************************************************************** + + **************************************************************************/ + + static int StringFormat_SetHotkeyPrefix( StringFormat format, int hotkeyPrefix ) + { + return SetStatus(GdipSetStringFormatHotkeyPrefix(format, hotkeyPrefix)); + } + + /************************************************************************** + + **************************************************************************/ + + static int StringFormat_SetFormatFlags( StringFormat format, int flags ) + { + return SetStatus(GdipSetStringFormatFlags(format, flags)); + } + + /************************************************************************** + + **************************************************************************/ + + static int StringFormat_SetTabStops( StringFormat format, float firstTabOffset, + int count, float[] tabStops) + { + return SetStatus( GdipSetStringFormatTabStops( format, firstTabOffset, + count, tabStops.ptr ) ); + } + + /************************************************************************** + + **************************************************************************/ } - -struct Bitmap{} -struct Brush{} -struct Color{} -struct Font{} -struct FontCollection{} -struct FontFamily{} -struct Graphics{} -struct GraphicsPath{} -struct Image{} -struct ImageAttributes{} -struct HatchBrush{} -struct LinearGradientBrush{} -struct Matrix{} -struct Pen{} -struct Region{} -struct SolidBrush{} -struct StringFormat{} -struct TextureBrush{} -alias extern(Windows) int function(void*) ImageAbort; -alias ImageAbort DrawImageAbort; - - public alias API.GdiplusStartup GdiplusStartup; - public alias API.GdiplusShutdown GdiplusShutdown; - - public static extern(Windows) { - Matrix* Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy); - void Matrix_delete(Matrix*); - int Matrix_GetElements(Matrix*,float* m); - int Matrix_Invert(Matrix*); - int Matrix_IsIdentity(Matrix*); - int Matrix_Multiply(Matrix*,Matrix*,int); - int Matrix_Rotate(Matrix*,float,int); - int Matrix_Scale(Matrix*,float,float,int); - int Matrix_SetElements(Matrix*,float m11, float m12, float m21, float m22, float dx, float dy); - int Matrix_TransformPoints(Matrix*,PointF*, int); - int Matrix_Translate(Matrix*,float, float, float); - - Bitmap* Bitmap_new(HBITMAP hbm, HPALETTE hpal); - Bitmap* Bitmap_new(HICON hicon); - Bitmap* Bitmap_new(int width, int height, int stride, int format, byte* scan0); - Bitmap* Bitmap_new(wchar* filename, int useIcm); - void Bitmap_delete(Bitmap* bitmap); - // colorBackground is C++ &-reference Color - int Bitmap_GetHBITMAP(Bitmap*bitmap, void* colorBackground, HBITMAP* hbmReturn); - int Bitmap_GetHICON(Bitmap* bitmap, HICON* hicon); - int Bitmap_LockBits(Bitmap* bitmap, Rect* rect, int flags, int pixelFormat, BitmapData* lockedBitmapData); - int Bitmap_UnlockBits(Bitmap* bitmap, BitmapData* lockedBitmapData); - - BitmapData* BitmapData_new(); - void BitmapData_delete(BitmapData* bitmapData); - - int Image_GetLastStatus(Image* image); - int Image_GetPixelFormat(Image* image); - uint Image_GetWidth(Image* image); - uint Image_GetHeight(Image* image); - int Image_GetPalette(Image* image, ColorPalette* palette, int size); - int Image_GetPaletteSize(Image* image); - - Graphics* Graphics_new(HDC hdc); - void Graphics_delete(Graphics* graphics); - int Graphics_DrawArc(Graphics* graphics, Pen* pen, int x, int y, int width, int height, float startAngle, float sweepAngle); - int Graphics_DrawEllipse(Graphics* graphics, Pen* pen, int x, int y, int width, int height); - int Graphics_DrawImage(Graphics* graphics, Image* image, int x, int y); - int Graphics_DrawImage(Graphics* graphics, Image* image, Rect* destRect, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, ImageAttributes* imageAttributes, DrawImageAbort callback, void* callbackData); - int Graphics_DrawLine(Graphics* graphics, Pen* pen, int x1, int y1, int x2, int y2); - int Graphics_DrawLines(Graphics* graphics, Pen* pen, Point* points, int count); - int Graphics_DrawPath(Graphics* graphics, Pen* pen, GraphicsPath* path); - int Graphics_DrawPolygon(Graphics* graphics, Pen* pen, int[] points, int count); - int Graphics_DrawRectangle(Graphics* graphics, Pen* pen, int x, int y, int width, int height); - int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, Brush* brush); - int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, Brush* brush); - int Graphics_FillEllipse(Graphics* graphics, Brush* brush, int x, int y, int width, int height); - int Graphics_FillPath(Graphics* graphics, Brush* brush, GraphicsPath* path); - void Graphics_Flush(Graphics* graphics, int intention); - int Graphics_FillPie(Graphics* graphics, Brush* brush, int x, int y, int width, int height, float startAngle, float sweepAngle); - int Graphics_FillPolygon(Graphics* graphics, Brush* brush, int[] points, int count, int fillMode); - int Graphics_FillRectangle(Graphics* graphics, Brush* brush, int x, int y, int width, int height); - int Graphics_GetClipBounds(Graphics* graphics, RectF rect); - int Graphics_GetClipBounds(Graphics* graphics, Rect rect); - int Graphics_GetClip(Graphics* graphics, Region* region); - HDC Graphics_GetHDC(Graphics* graphics); - void Graphics_ReleaseHDC(Graphics* graphics, HDC hdc); - int Graphics_GetInterpolationMode(Graphics* graphics); - int Graphics_GetSmoothingMode(Graphics* graphics); - int Graphics_GetTextRenderingHint(Graphics* graphics); - int Graphics_GetTransform(Graphics* graphics, Matrix* matrix); - int Graphics_GetVisibleClipBounds(Graphics* graphics, Rect rect); - int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, RectF* boundingBox); - int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, RectF* boundingBox); - int Graphics_ResetClip(Graphics* graphics); - int Graphics_Restore(Graphics* graphics, int gstate); - int Graphics_Save(Graphics* graphics); - int Graphics_ScaleTransform(Graphics* graphics, float sx, float sy, int order); - int Graphics_SetClip(Graphics* graphics, HRGN hrgn, int combineMode); - int Graphics_SetClip(Graphics* graphics, GraphicsPath* path); - int Graphics_SetClip(Graphics* graphics, Rect rect, int combineMode); - int Graphics_SetCompositingQuality(Graphics* graphics, int compositingQuality); - int Graphics_SetPageUnit(Graphics* graphics, int unit); - int Graphics_SetPixelOffsetMode(Graphics* graphics, int pixelOffsetMode); - int Graphics_SetSmoothingMode(Graphics* graphics, int smoothingMode); - int Graphics_SetTransform(Graphics* graphics, Matrix* matrix); - int Graphics_SetInterpolationMode(Graphics* graphics, int mode); - int Graphics_SetTextRenderingHint(Graphics* graphics, int mode); - int Graphics_TranslateTransform(Graphics* graphics, float dx, float dy, int order); - - SolidBrush* SolidBrush_new(Color* color); - void SolidBrush_delete(SolidBrush* brush); - - Brush* Brush_Clone(Brush* brush); - int Brush_GetType(Brush* brush); - - TextureBrush* TextureBrush_new(Image* image, int wrapMode, float dstX, float dstY, float dstWidth, float dstHeight); - void TextureBrush_delete(TextureBrush* brush); - int TextureBrush_SetTransform(TextureBrush* brush, Matrix* matrix); - int TextureBrush_ResetTransform(TextureBrush* brush); - int TextureBrush_ScaleTransform(TextureBrush* brush, float sx, float sy, int order); - int TextureBrush_TranslateTransform(TextureBrush* brush, float dx, float dy, int order); - - Color* Color_new(int argb); - void Color_delete(Color* color); - - - Pen* Pen_new(Brush* brush, float width); - void Pen_delete(Pen* pen); - Brush* Pen_GetBrush(Pen* pen); - int Pen_SetBrush(Pen* pen, Brush* brush); - int Pen_SetDashOffset(Pen* pen, float dashOffset); - int Pen_SetDashPattern(Pen* pen, float* dashArray, int count); - int Pen_SetDashStyle(Pen* pen, int dashStyle); - int Pen_SetLineCap(Pen* pen, int startCap, int endCap, int dashCap); - int Pen_SetLineJoin(Pen* pen, int lineJoin); - int Pen_SetMiterLimit(Pen* pen, float miterLimit); - int Pen_SetWidth(Pen* pen, float width); - - Font* Font_new(HDC hdc, HFONT hfont); - Font* Font_new(wchar* familyName, float emSize, int style, int unit, FontCollection* fontCollection); - void Font_delete(Font* font); - int Font_GetFamily(Font* font, FontFamily* family); - float Font_GetSize(Font* font); - int Font_GetStyle(Font* font); - bool Font_IsAvailable(Font* font); - - - void HatchBrush_delete(HatchBrush* brush); - - LinearGradientBrush* LinearGradientBrush_new(PointF point1, PointF point2, Color* color1, Color* color2); - void LinearGradientBrush_delete(LinearGradientBrush* brush); - int LinearGradientBrush_SetInterpolationColors(LinearGradientBrush* brush, Color* presetColors, float* blendPositions, int count); - int LinearGradientBrush_SetWrapMode(LinearGradientBrush* brush, int wrapMode); - int LinearGradientBrush_ResetTransform(LinearGradientBrush* brush); - int LinearGradientBrush_ScaleTransform(LinearGradientBrush* brush, float sx, float sy, int order); - int LinearGradientBrush_TranslateTransform(LinearGradientBrush* brush, float dx, float dy, int order); - - GraphicsPath* GraphicsPath_new(int fillMode); - GraphicsPath* GraphicsPath_new(Point* points, byte* types, int count, int fillMode); - void GraphicsPath_delete(GraphicsPath* path); - int GraphicsPath_AddArc(GraphicsPath* path, float x, float y, float width, float height, float startAngle, float sweepAngle); - int GraphicsPath_AddBezier(GraphicsPath* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); - int GraphicsPath_AddLine(GraphicsPath* path, float x1, float y1, float x2, float y2); - int GraphicsPath_AddPath(GraphicsPath* path, GraphicsPath* addingPath, bool connect); - int GraphicsPath_AddRectangle(GraphicsPath* path, RectF* rect); - int GraphicsPath_AddString(GraphicsPath* path, wchar* string, int length, FontFamily* family, int style, float emSize, PointF origin, StringFormat* format); - int GraphicsPath_CloseFigure(GraphicsPath* path); - int GraphicsPath_Flatten(GraphicsPath* path, Matrix* matrix, float flatness); - int GraphicsPath_GetBounds(GraphicsPath* path, RectF bounds, Matrix* matrix, Pen* pen); - int GraphicsPath_GetLastPoint(GraphicsPath* path, PointF lastPoint); - int GraphicsPath_GetPathPoints(GraphicsPath* path, float* points, int count); - int GraphicsPath_GetPathTypes(GraphicsPath* path, byte[] types, int count); - int GraphicsPath_GetPointCount(GraphicsPath* path); - bool GraphicsPath_IsOutlineVisible(GraphicsPath* path, float x, float y, Pen* pen, Graphics* g); - bool GraphicsPath_IsVisible(GraphicsPath* path, float x, float y, Graphics* g); - int GraphicsPath_SetFillMode(GraphicsPath* path, int fillmode); - int GraphicsPath_StartFigure(GraphicsPath* path); - int GraphicsPath_Transform(GraphicsPath* path, Matrix* matrix); - - Region* Region_new(HRGN hRgn); - Region* Region_new(); - void Region_delete(Region* region); - HRGN Region_GetHRGN(Region* region, Graphics* graphics); - bool Region_IsInfinite(Region* region, Graphics* graphics); - - ImageAttributes* ImageAttributes_new(); - void ImageAttributes_delete(ImageAttributes* attrib); - int ImageAttributes_SetWrapMode(ImageAttributes* attrib, int wrap); - int ImageAttributes_SetColorMatrix(ImageAttributes* attrib, float* matrix, int mode, int type); - - void StringFormat_delete(StringFormat* format); - StringFormat* StringFormat_Clone(StringFormat* format); - StringFormat* StringFormat_GenericDefault(); - StringFormat* StringFormat_GenericTypographic(); - int StringFormat_GetFormatFlags(StringFormat* format); - int StringFormat_SetHotkeyPrefix(StringFormat* format, int hotkeyPrefix); - int StringFormat_SetFormatFlags(StringFormat* format, int flags); - int StringFormat_SetTabStops(StringFormat* format, float firstTabOffset, int count, float* tabStops); - - FontFamily* FontFamily_new(); - void FontFamily_delete(FontFamily* family); - int FontFamily_GetFamilyName(FontFamily* family, wchar* name, wchar language); - } - - - -/++ -/** 64 bit */ -public static final native int ColorPalette_sizeof(); -public static final native int GdiplusStartupInput_sizeof(); - -/** GdiPlus natives */ -public static final native int GdiplusStartup(int /*long*/[] token, GdiplusStartupInput input, int /*long*/ output); -public static final native void GdiplusShutdown(int /*long*/ token); -public static final native int /*long*/ Bitmap_new(int /*long*/ hbm, int /*long*/ hpal); -public static final native int /*long*/ Bitmap_new(int /*long*/ hicon); -public static final native int /*long*/ Bitmap_new(int width, int height, int stride, int format, int /*long*/ scan0); -public static final native int /*long*/ Bitmap_new(char[] filename, bool useIcm); -public static final native void Bitmap_delete(int /*long*/ bitmap); -public static final native int Bitmap_GetHBITMAP(int /*long*/ bitmap, int /*long*/ colorBackground, int /*long*/[] hbmReturn); -public static final native int Bitmap_GetHICON(int /*long*/ bitmap, int /*long*/[] hicon); -public static final native int /*long*/ BitmapData_new(); -public static final native void BitmapData_delete(int /*long*/ bitmapData); -public static final native int Bitmap_LockBits(int /*long*/ bitmap, int /*long*/ rect, int flags, int pixelFormat, int /*long*/ lockedBitmapData); -public static final native int Bitmap_UnlockBits(int /*long*/ bitmap, int /*long*/ lockedBitmapData); -public static final native int /*long*/ Brush_Clone(int /*long*/ brush); -public static final native int Brush_GetType(int /*long*/ brush); -public static final native int /*long*/ Color_new(int argb); -public static final native void Color_delete(int /*long*/ color); -public static final native int /*long*/ Font_new(int /*long*/ hdc, int /*long*/ hfont); -public static final native int /*long*/ Font_new(char[] familyName, float emSize, int style, int unit, int /*long*/ fontCollection); -public static final native void Font_delete(int /*long*/ font); -public static final native int Font_GetFamily(int /*long*/ font, int /*long*/ family); -public static final native float Font_GetSize(int /*long*/ font); -public static final native int Font_GetStyle(int /*long*/ font); -public static final native bool Font_IsAvailable(int /*long*/ font); -public static final native int /*long*/ FontFamily_new(); -public static final native void FontFamily_delete(int /*long*/ family); -public static final native int FontFamily_GetFamilyName(int /*long*/ family, char[] name, char language); -public static final native int /*long*/ Graphics_new(int /*long*/ hdc); -public static final native void Graphics_delete(int /*long*/ graphics); -public static final native int Graphics_DrawArc(int /*long*/ graphics, int /*long*/ pen, int x, int y, int width, int height, float startAngle, float sweepAngle); -public static final native int Graphics_DrawEllipse(int /*long*/ graphics, int /*long*/ pen, int x, int y, int width, int height); -public static final native int Graphics_DrawImage(int /*long*/ graphics, int /*long*/ image, int x, int y); -public static final native int Graphics_DrawImage(int /*long*/ graphics, int /*long*/ image, Rect destRect, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, int /*long*/ imageAttributes, int /*long*/ callback, int /*long*/ callbackData); -public static final native int Graphics_DrawLine(int /*long*/ graphics, int /*long*/ pen, int x1, int y1, int x2, int y2); -public static final native int Graphics_DrawLines(int /*long*/ graphics, int /*long*/ pen, int[] points, int count); -public static final native int Graphics_DrawPath(int /*long*/ graphics, int /*long*/ pen, int /*long*/ path); -public static final native int Graphics_DrawPolygon(int /*long*/ graphics, int /*long*/ pen, int[] points, int count); -public static final native int Graphics_DrawRectangle(int /*long*/ graphics, int /*long*/ pen, int x, int y, int width, int height); -public static final native int Graphics_DrawString(int /*long*/ graphics, char[] string, int length, int /*long*/ font, PointF origin, int /*long*/ brush); -public static final native int Graphics_DrawString(int /*long*/ graphics, char[] string, int length, int /*long*/ font, PointF origin, int /*long*/ format, int /*long*/ brush); -public static final native int Graphics_FillEllipse(int /*long*/ graphics, int /*long*/ brush, int x, int y, int width, int height); -public static final native int Graphics_FillPath(int /*long*/ graphics, int /*long*/ brush, int /*long*/ path); -public static final native void Graphics_Flush(int /*long*/ graphics, int intention); -public static final native int Graphics_FillPie(int /*long*/ graphics, int /*long*/ brush, int x, int y, int width, int height, float startAngle, float sweepAngle); -public static final native int Graphics_FillPolygon(int /*long*/ graphics, int /*long*/ brush, int[] points, int count, int fillMode); -public static final native int Graphics_FillRectangle(int /*long*/ graphics, int /*long*/ brush, int x, int y, int width, int height); -public static final native int Graphics_GetClipBounds(int /*long*/ graphics, RectF rect); -public static final native int Graphics_GetClipBounds(int /*long*/ graphics, Rect rect); -public static final native int Graphics_GetClip(int /*long*/ graphics, int /*long*/ region); -public static final native int /*long*/ Graphics_GetHDC(int /*long*/ graphics); -public static final native void Graphics_ReleaseHDC(int /*long*/ graphics, int /*long*/ hdc); -public static final native int Graphics_GetInterpolationMode(int /*long*/ graphics); -public static final native int Graphics_GetSmoothingMode(int /*long*/ graphics); -public static final native int Graphics_GetTextRenderingHint(int /*long*/ graphics); -public static final native int Graphics_GetTransform(int /*long*/ graphics, int /*long*/ matrix); -public static final native int Graphics_GetVisibleClipBounds(int /*long*/ graphics, Rect rect); -public static final native int Graphics_MeasureString(int /*long*/ graphics, char[] string, int length, int /*long*/ font, PointF origin, RectF boundingBox); -public static final native int Graphics_MeasureString(int /*long*/ graphics, char[] string, int length, int /*long*/ font, PointF origin, int /*long*/ format, RectF boundingBox); -public static final native int Graphics_ResetClip(int /*long*/ graphics); -public static final native int Graphics_Restore(int /*long*/ graphics, int gstate); -public static final native int Graphics_Save(int /*long*/ graphics); -public static final native int Graphics_ScaleTransform(int /*long*/ graphics, float sx, float sy, int order); -public static final native int Graphics_SetClip(int /*long*/ graphics, int /*long*/ hrgn, int combineMode); -public static final native int Graphics_SetClip(int /*long*/ graphics, int /*long*/ path); -public static final native int Graphics_SetClip(int /*long*/ graphics, Rect rect, int combineMode); -public static final native int Graphics_SetCompositingQuality(int /*long*/ graphics, int compositingQuality); -public static final native int Graphics_SetPageUnit(int /*long*/ graphics, int unit); -public static final native int Graphics_SetPixelOffsetMode(int /*long*/ graphics, int pixelOffsetMode); -public static final native int Graphics_SetSmoothingMode(int /*long*/ graphics, int smoothingMode); -public static final native int Graphics_SetTransform(int /*long*/ graphics, int /*long*/ matrix); -public static final native int Graphics_SetInterpolationMode(int /*long*/ graphics, int mode); -public static final native int Graphics_SetTextRenderingHint(int /*long*/ graphics, int mode); -public static final native int Graphics_TranslateTransform(int /*long*/ graphics, float dx, float dy, int order); -public static final native int /*long*/ GraphicsPath_new(int fillMode); -public static final native int /*long*/ GraphicsPath_new(int[] points, byte[] types, int count, int fillMode); -public static final native void GraphicsPath_delete(int /*long*/ path); -public static final native int GraphicsPath_AddArc(int /*long*/ path, float x, float y, float width, float height, float startAngle, float sweepAngle); -public static final native int GraphicsPath_AddBezier(int /*long*/ path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); -public static final native int GraphicsPath_AddLine(int /*long*/ path, float x1, float y1, float x2, float y2); -public static final native int GraphicsPath_AddPath(int /*long*/ path, int /*long*/ addingPath, bool connect); -public static final native int GraphicsPath_AddRectangle(int /*long*/ path, RectF rect); -public static final native int GraphicsPath_AddString(int /*long*/ path, char[] string, int length, int /*long*/ family, int style, float emSize, PointF origin, int /*long*/ format); -public static final native int GraphicsPath_CloseFigure(int /*long*/ path); -public static final native int GraphicsPath_Flatten(int /*long*/ path, int /*long*/ matrix, float flatness); -public static final native int GraphicsPath_GetBounds(int /*long*/ path, RectF bounds, int /*long*/ matrix, int /*long*/ pen); -public static final native int GraphicsPath_GetLastPoint(int /*long*/ path, PointF lastPoint); -public static final native int GraphicsPath_GetPathPoints(int /*long*/ path, float[] points, int count); -public static final native int GraphicsPath_GetPathTypes(int /*long*/ path, byte[] types, int count); -public static final native int GraphicsPath_GetPointCount(int /*long*/ path); -public static final native bool GraphicsPath_IsOutlineVisible(int /*long*/ path, float x, float y, int /*long*/ pen, int /*long*/ g); -public static final native bool GraphicsPath_IsVisible(int /*long*/ path, float x, float y, int /*long*/ g); -public static final native int GraphicsPath_SetFillMode(int /*long*/ path, int fillmode); -public static final native int GraphicsPath_StartFigure(int /*long*/ path); -public static final native int GraphicsPath_Transform(int /*long*/ path, int /*long*/ matrix); -public static final native int /*long*/ HatchBrush_new(int hatchStyle, int /*long*/ foreColor, int /*long*/ backColor); -public static final native int Image_GetLastStatus(int /*long*/ image); -public static final native int Image_GetPixelFormat(int /*long*/ image); -public static final native int Image_GetWidth(int /*long*/ image); -public static final native int Image_GetHeight(int /*long*/ image); -public static final native int Image_GetPalette(int /*long*/ image, int /*long*/ palette, int size); -public static final native int Image_GetPaletteSize(int /*long*/ image); -public static final native int /*long*/ ImageAttributes_new(); -public static final native void ImageAttributes_delete(int /*long*/ attrib); -public static final native int ImageAttributes_SetWrapMode(int /*long*/ attrib, int wrap); -public static final native int ImageAttributes_SetColorMatrix(int /*long*/ attrib, float[] matrix, int mode, int type); -public static final native void HatchBrush_delete(int /*long*/ brush); -public static final native int /*long*/ LinearGradientBrush_new(PointF point1, PointF point2, int /*long*/ color1, int /*long*/ color2); -public static final native void LinearGradientBrush_delete(int /*long*/ brush); -public static final native int LinearGradientBrush_SetInterpolationColors(int /*long*/ brush, int /*long*/[] presetColors, float[] blendPositions, int count); -public static final native int LinearGradientBrush_SetWrapMode(int /*long*/ brush, int wrapMode); -public static final native int LinearGradientBrush_ResetTransform(int /*long*/ brush); -public static final native int LinearGradientBrush_ScaleTransform(int /*long*/ brush, float sx, float sy, int order); -public static final native int LinearGradientBrush_TranslateTransform(int /*long*/ brush, float dx, float dy, int order); -public static final native int /*long*/ Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy); -public static final native void Matrix_delete(int /*long*/ matrix); -public static final native int Matrix_GetElements(int /*long*/ matrix, float[] m); -public static final native int Matrix_Invert(int /*long*/ matrix); -public static final native bool Matrix_IsIdentity(int /*long*/ matrix); -public static final native int Matrix_Multiply(int /*long*/ matrix, int /*long*/ matrix1, int order); -public static final native int Matrix_Rotate(int /*long*/ matrix, float angle, int order); -public static final native int Matrix_Scale(int /*long*/ matrix, float scaleX, float scaleY, int order); -public static final native int Matrix_Shear(int /*long*/ matrix, float shearX, float shearY, int order); -public static final native int Matrix_TransformPoints(int /*long*/ matrix, PointF pts, int count); -public static final native int Matrix_TransformPoints(int /*long*/ matrix, float[] pts, int count); -public static final native int Matrix_Translate(int /*long*/ matrix, float offsetX, float offsetY, int order); -public static final native int Matrix_SetElements(int /*long*/ matrix, float m11, float m12, float m21, float m22, float dx, float dy); -public static final native void MoveMemory(ColorPalette Destination, int /*long*/ SourcePtr, int Length); -public static final native void MoveMemory(BitmapData Destination, int /*long*/ SourcePtr); -public static final native int /*long*/ PathGradientBrush_new(int /*long*/ path); -public static final native void PathGradientBrush_delete(int /*long*/ brush); -public static final native int PathGradientBrush_SetCenterColor(int /*long*/ brush, int /*long*/ color); -public static final native int PathGradientBrush_SetCenterPoint(int /*long*/ brush, PointF pt); -public static final native int PathGradientBrush_SetSurroundColors(int /*long*/ brush, int /*long*/[] colors, int[] count); -public static final native int PathGradientBrush_SetGraphicsPath(int /*long*/ brush, int /*long*/ path); -public static final native int /*long*/ Pen_new(int /*long*/ brush, float width); -public static final native void Pen_delete(int /*long*/ pen); -public static final native int /*long*/ Pen_GetBrush(int /*long*/ pen); -public static final native int Pen_SetBrush(int /*long*/ pen, int /*long*/ brush); -public static final native int Pen_SetDashOffset(int /*long*/ pen, float dashOffset); -public static final native int Pen_SetDashPattern(int /*long*/ pen, float[] dashArray, int count); -public static final native int Pen_SetDashStyle(int /*long*/ pen, int dashStyle); -public static final native int Pen_SetLineCap(int /*long*/ pen, int startCap, int endCap, int dashCap); -public static final native int Pen_SetLineJoin(int /*long*/ pen, int lineJoin); -public static final native int Pen_SetMiterLimit(int /*long*/ pen, float miterLimit); -public static final native int Pen_SetWidth(int /*long*/ pen, float width); -public static final native int /*long*/ Point_new(int x, int y); -public static final native void Point_delete(int /*long*/ point); -public static final native int /*long*/ Region_new(int /*long*/ hRgn); -public static final native int /*long*/ Region_new(); -public static final native void Region_delete(int /*long*/ region); -public static final native int /*long*/ Region_GetHRGN(int /*long*/ region, int /*long*/ graphics); -public static final native bool Region_IsInfinite(int /*long*/ region, int /*long*/ graphics); -public static final native int /*long*/ SolidBrush_new(int /*long*/ color); -public static final native void SolidBrush_delete(int /*long*/ brush); -public static final native void StringFormat_delete(int /*long*/ format); -public static final native int /*long*/ StringFormat_Clone(int /*long*/ format); -public static final native int /*long*/ StringFormat_GenericDefault(); -public static final native int /*long*/ StringFormat_GenericTypographic(); -public static final native int StringFormat_GetFormatFlags(int /*long*/ format); -public static final native int StringFormat_SetHotkeyPrefix(int /*long*/ format, int hotkeyPrefix); -public static final native int StringFormat_SetFormatFlags(int /*long*/ format, int flags); -public static final native int StringFormat_SetTabStops(int /*long*/ format, float firstTabOffset, int count, float[] tabStops); -public static final native int /*long*/ TextureBrush_new(int /*long*/ image, int wrapMode, float dstX, float dstY, float dstWidth, float dstHeight); -public static final native void TextureBrush_delete(int /*long*/ brush); -public static final native int TextureBrush_SetTransform(int /*long*/ brush, int /*long*/ matrix); -public static final native int TextureBrush_ResetTransform(int /*long*/ brush); -public static final native int TextureBrush_ScaleTransform(int /*long*/ brush, float sx, float sy, int order); -public static final native int TextureBrush_TranslateTransform(int /*long*/ brush, float dx, float dy, int order); -++/ -} diff -r 0553f4e8ed93 -r 0405e18fec7f dwt/internal/gdip/native.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dwt/internal/gdip/native.d Sun Feb 03 15:48:14 2008 -0800 @@ -0,0 +1,743 @@ +/****************************************************************************** + + module: + + Based on D version created by John Chapman for the Juno Project + see: www.dsource.org/projects/juno + + Changes and Additions for DWT: + John Reimer + +******************************************************************************/ + +module dwt.internal.gdip.native; + +private import dwt.internal.win32.WINTYPES; +// private import tango.core.Memory; + +extern(Windows): + +/****************************************************************************** + + +******************************************************************************/ + +enum DebugEventLevel { + Fatal, + Warning +} + +alias void function(DebugEventLevel level, char* message) DebugEventProc; + +alias int function(out uint token) NotificationHookProc; +alias void function(uint token) NotificationUnhookProc; + + +/****************************************************************************** + + +******************************************************************************/ + + +struct GdiplusStartupInput { + uint GdiplusVersion; + DebugEventProc DebugEventCallback; + int SuppressBackgroundThread; + int SuppressExternalCodecs; +} + +struct GdiplusStartupOutput { + NotificationHookProc NotificationHook; + NotificationUnhookProc NotificationUnhook; +} + +struct GpBitmapData { + int Width; + int Height; + int Stride; + int PixelFormat; + void* Scan0; + int Reserved; +} + +struct GpColorMatrix { + float[5][5] m; +} + +struct GpPropertyItem { + int id; + int length; + short type; + void* value; +} + +struct GpColorPalette { + int Flags; + int Count; + int[1] Entries; +} + +public struct GpRectF { + public float X; + public float Y; + public float Width; + public float Height; +} + +public struct GpRect { + public int X; + public int Y; + public int Width; + public int Height; +} +public struct GpPoint { + public int X; + public int Y; +} +public struct GpPointF { + public float X; + public float Y; +} + +alias int function(void*) GpDrawImageAbort; +alias GpDrawImageAbort GpGetThumbnailImageAbort; + +/****************************************************************************** + + +******************************************************************************/ + +enum Status { + OK, + GenericError, + InvalidParameter, + OutOfMemory, + ObjectBusy, + InsufficientBuffer, + NotImplemented, + Win32Error, + WrongState, + Aborted, + FileNotFound, + ValueOverflow, + AccessDenied, + UnknownImageFormat, + FontFamilyNotFound, + FontStyleNotFound, + NotTrueTypeFont, + UnsupportedGdiplusVersion, + GdiplusNotInitialized, + PropertyNotFound, + PropertyNotSupported +} + +/************************************************************************** + + Opaque types managed by Gdi+ + +**************************************************************************/ +typedef GpImage GpBitmap; + +// alias uint ARGB; +typedef Handle GpFontFamily; +typedef Handle GpImage; +typedef Handle GpBrush; +typedef Handle GpFont; +typedef Handle GpFontCollection; +typedef Handle GpGraphics; +typedef Handle GpGraphicsPath; +typedef Handle GpImageAttributes; +typedef Handle GpHatchBrush; +typedef Handle GpLinearGradientBrush; +typedef Handle GpMatrix; +typedef Handle GpPen; +typedef Handle GpRegion; +typedef Handle GpSolidBrush; +typedef Handle GpStringFormat; +typedef Handle GpTextureBrush; +typedef Handle GpPath; + +alias void* Handle; + +alias int BrushType; +alias int CombineMode; +alias int FlushIntention; +alias int MatrixOrder; +alias int GraphicsUnit; +alias int QualityMode; +alias int SmoothingMode; +alias int InterpolationMode; +alias int CompositingMode; +alias int CompositingQuality; +alias int PixelOffsetMode; +alias int PixelFormat; +alias int RotateFlipType; +alias int CoordinateSpace; +alias int WarpMode; +alias int WrapMode; +alias int FillMode; +alias int LineJoin; +alias int LineCap; +alias int DashCap; +alias int DashStyle; +alias int PenAlignment; +alias int ColorMatrixFlag; +alias int ColorAdjustType; +alias int ColorChannelFlag; +alias int ImageLockMode; +alias int ImageCodecFlags; +alias int EncoderParameterValueType; +alias int GenericFontFamilies; +alias int FontStyle; +alias int HatchStyle; +alias int StringFormatFlags; +alias int StringAlignment; +alias int StringTrimming; +alias int TextRenderingHint; +alias int PenType; +alias int LinearGradientMode; +alias int KnownColor; +alias int Unit; + +alias uint GraphicsState; + +/****************************************************************************** + + Flat GDI+ Exports (C Interface) + +******************************************************************************/ + +extern (Windows): + +Status GdiplusStartup( uint* token, GdiplusStartupInput* input, GdiplusStartupOutput* output); +void GdiplusShutdown(uint token); +Status GdipCreateFromHDC(Handle hdc, out Handle graphics); +Status GdipCreateFromHDC2(Handle hdc, Handle hDevice, out Handle graphics); +Status GdipCreateFromHWND(Handle hwnd, out Handle graphics); +Status GdipGetImageGraphicsContext(Handle image, out Handle graphics); +Status GdipDeleteGraphics(Handle graphics); +Status GdipGetDC(Handle graphics, out Handle hdc); +Status GdipReleaseDC(Handle graphics, Handle hdc); +Status GdipSetClipGraphics(Handle graphics, Handle srcgraphics, CombineMode combineMode); +Status GdipSetClipRectI(Handle graphics, int x, int y, int width, int height, CombineMode combineMode); +Status GdipSetClipRect(Handle graphics, float x, float y, float width, float height, CombineMode combineMode); +Status GdipSetClipPath(Handle graphics, Handle path, CombineMode combineMode); +Status GdipSetClipRegion(Handle graphics, Handle region, CombineMode combineMode); +Status GdipSetClipHrgn(Handle graphics, HRGN hRgn, CombineMode combineMode); + +Status GdipGetClip(Handle graphics, out Handle region); +Status GdipResetClip(Handle graphics); +Status GdipSaveGraphics(Handle graphics, out uint state); +Status GdipRestoreGraphics(Handle graphics, int state); +Status GdipFlush(Handle graphics, FlushIntention intention); +Status GdipScaleWorldTransform(Handle graphics, float sx, float sy, MatrixOrder order); +Status GdipRotateWorldTransform(Handle graphics, float angle, MatrixOrder order); +Status GdipTranslateWorldTransform(Handle graphics, float dx, float dy, MatrixOrder order); +Status GdipMultiplyWorldTransform(Handle graphics, Handle matrix, MatrixOrder order); +Status GdipResetWorldTransform(Handle graphics); +Status GdipBeginContainer(Handle graphics, ref GpRectF dstrect, ref GpRectF srcrect, GraphicsUnit unit, out int state); +Status GdipBeginContainerI(Handle graphics, ref GpRect dstrect, ref GpRect srcrect, GraphicsUnit unit, out int state); +Status GdipBeginContainer2(Handle graphics, out int state); +Status GdipEndContainer(Handle graphics, int state); +Status GdipGetDpiX(Handle graphics, out float dpi); +Status GdipGetDpiY(Handle graphics, out float dpi); +Status GdipGetPageUnit(Handle graphics, out GraphicsUnit unit); +Status GdipSetPageUnit(Handle graphics, GraphicsUnit unit); +Status GdipGetPageScale(Handle graphics, out float scale); +Status GdipSetPageScale(Handle graphics, float scale); +Status GdipGetWorldTransform(Handle graphics, Handle matrix); // out not necessary? +Status GdipSetWorldTransform(Handle graphics, Handle matrix); +Status GdipGetCompositingMode(Handle graphics, out CompositingMode compositingMode); +Status GdipSetCompositingMode(Handle graphics, CompositingMode compositingMode); +Status GdipGetCompositingQuality(Handle graphics, out CompositingQuality compositingQuality); +Status GdipSetCompositingQuality(Handle graphics, CompositingQuality compositingQuality); +Status GdipGetInterpolationMode(Handle graphics, out InterpolationMode interpolationMode); +Status GdipSetInterpolationMode(Handle graphics, InterpolationMode interpolationMode); +Status GdipGetSmoothingMode(Handle graphics, out SmoothingMode smoothingMode); +Status GdipSetSmoothingMode(Handle graphics, SmoothingMode smoothingMode); +Status GdipGetPixelOffsetMode(Handle graphics, out PixelOffsetMode pixelOffsetMode); +Status GdipSetPixelOffsetMode(Handle graphics, PixelOffsetMode pixelOffsetMode); +Status GdipGetTextContrast(Handle graphics, out uint textContrast); +Status GdipSetTextContrast(Handle graphics, uint textContrast); +Status GdipGraphicsClear(Handle graphics, int color); +Status GdipDrawLine(Handle graphics, Handle pen, float x1, float y1, float x2, float y2); +Status GdipDrawLines(Handle graphics, Handle pen, GpPointF* points, int count); +Status GdipDrawLineI(Handle graphics, Handle pen, int x1, int y1, int x2, int y2); +Status GdipDrawLinesI(Handle graphics, Handle pen, GpPoint* points, int count); +Status GdipDrawArc(Handle graphics, Handle pen, float x, float y, float width, float height, float startAngle, float sweepAngle); +Status GdipDrawArcI(Handle graphics, Handle pen, int x, int y, int width, int height, float startAngle, float sweepAngle); +Status GdipDrawBezier(Handle graphics, Handle pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); +Status GdipDrawBeziers(Handle graphics, Handle pen, GpPointF* points, int count); +Status GdipDrawBezierI(Handle graphics, Handle pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); +Status GdipDrawBeziersI(Handle graphics, Handle pen, GpPoint* points, int count); +Status GdipDrawRectangle(Handle graphics, Handle pen, float x, float y, float width, float height); +Status GdipDrawRectangles(Handle graphics, Handle pen, GpRectF* rects, int count); +Status GdipDrawRectangleI(Handle graphics, Handle pen, int x, int y, int width, int height); +Status GdipDrawRectanglesI(Handle graphics, Handle pen, GpRect* rects, int count); +Status GdipDrawEllipse(Handle graphics, Handle pen, float x, float y, float width, float height); +Status GdipDrawEllipseI(Handle graphics, Handle pen, int x, int y, int width, int height); +Status GdipDrawPie(Handle graphics, Handle pen, float x, float y, float width, float height, float startAngle, float sweepAngle); +Status GdipDrawPieI(Handle graphics, Handle pen, int x, int y, int width, int height, float startAngle, float sweepAngle); +Status GdipDrawPolygon(Handle graphics, Handle pen, GpPointF* points, int count); +Status GdipDrawPolygonI(Handle graphics, Handle pen, GpPoint* points, int count); +Status GdipDrawCurve(Handle graphics, Handle pen, GpPointF* points, int count); +Status GdipDrawCurve2(Handle graphics, Handle pen, GpPointF* points, int count, float tension); +Status GdipDrawCurve3(Handle graphics, Handle pen, GpPointF* points, int count, int offset, int numberOfSegments, float tension); +Status GdipDrawCurveI(Handle graphics, Handle pen, GpPoint* points, int count); +Status GdipDrawCurve2I(Handle graphics, Handle pen, GpPoint* points, int count, float tension); +Status GdipDrawCurve3I(Handle graphics, Handle pen, GpPoint* points, int count, int offset, int numberOfSegments, float tension); +Status GdipDrawClosedCurve(Handle graphics, Handle pen, GpPointF* points, int count); +Status GdipDrawClosedCurve2(Handle graphics, Handle pen, GpPointF* points, int count, float tension); +Status GdipDrawClosedCurveI(Handle graphics, Handle pen, GpPoint* points, int count); +Status GdipDrawClosedCurve2I(Handle graphics, Handle pen, GpPoint* points, int count, float tension); +Status GdipFillRectangleI(Handle graphics, Handle brush, int x, int y, int width, int height); +Status GdipFillRectangle(Handle graphics, Handle brush, float x, float y, float width, float height); +Status GdipFillRectanglesI(Handle graphics, Handle brush, GpRect* rects, int count); +Status GdipFillRectangles(Handle graphics, Handle brush, GpRectF* rects, int count); +Status GdipFillPolygon(Handle graphics, Handle brush, GpPointF* rects, int count, FillMode fillMode); +Status GdipFillPolygonI(Handle graphics, Handle brush, GpPoint* rects, int count, FillMode fillMode); +Status GdipFillEllipse(Handle graphics, Handle brush, float x, float y, float width, float height); +Status GdipFillEllipseI(Handle graphics, Handle brush, int x, int y, int width, int height); +Status GdipFillPie(Handle graphics, Handle brush, float x, float y, float width, float height, float startAngle, float sweepAngle); +Status GdipFillPieI(Handle graphics, Handle brush, int x, int y, int width, int height, float startAngle, float sweepAngle); +Status GdipFillPath(Handle graphics, Handle brush, Handle path); +Status GdipFillClosedCurve(Handle graphics, Handle brush, GpPointF* points, int count); +Status GdipFillClosedCurveI(Handle graphics, Handle brush, GpPoint* points, int count); +Status GdipFillClosedCurve2(Handle graphics, Handle brush, GpPointF* points, int count, FillMode fillMode, float tension); +Status GdipFillClosedCurve2I(Handle graphics, Handle brush, GpPoint* points, int count, FillMode fillMode, float tension); +Status GdipFillRegion(Handle graphics, Handle brush, Handle region); +Status GdipDrawString(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, Handle brush); +Status GdipMeasureString(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, ref GpRectF boundingBox, int* codepointsFitted, int* linesFitted); +Status GdipGetStringFormatMeasurableCharacterRangeCount(Handle format, out int count); +Status GdipCloneStringFormat(Handle format, out Handle newFormat); + +Status GdipMeasureCharacterRanges(Handle graphics, wchar* string, int length, Handle font, ref GpRectF layoutRect, Handle stringFormat, int regionCount, Handle* regions); +Status GdipDrawImage(Handle graphics, Handle image, float x, float y); +Status GdipDrawImageI(Handle graphics, Handle image, int x, int y); +Status GdipDrawImageRect(Handle graphics, Handle image, float x, float y, float width, float height); +Status GdipDrawImageRectI(Handle graphics, Handle image, int x, int y, int width, int height); +Status GdipDrawImagePointRect(Handle graphics, Handle image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit); +Status GdipDrawImagePointRectI(Handle graphics, Handle image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit); +Status GdipDrawImageRectRect(Handle graphics, Handle image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData); +Status GdipDrawImageRectRectI(Handle graphics, Handle image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData); +Status GdipDrawImagePoints(Handle graphics, Handle image, GpPointF* dstpoints, int count); +Status GdipDrawImagePointsI(Handle graphics, Handle image, GpPoint* dstpoints, int count); +Status GdipDrawImagePointsRect(Handle graphics, Handle image, GpPointF* dstpoints, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData); +Status GdipDrawImagePointsRectI(Handle graphics, Handle image, GpPoint* dstpoints, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcUnit, Handle imageAttributes, GpDrawImageAbort callback, void* callbakcData); +Status GdipIsVisiblePoint(Handle graphics, float x, float y, out int result); +Status GdipIsVisiblePointI(Handle graphics, int x, int y, out int result); +Status GdipIsVisibleRect(Handle graphics, float x, float y, float width, float height, out int result); +Status GdipIsVisibleRectI(Handle graphics, int x, int y, int width, int height, out int result); +Status GdipGetTextRenderingHint(Handle graphics, out TextRenderingHint mode); +Status GdipSetTextRenderingHint(Handle graphics, TextRenderingHint mode); +Status GdipGetClipBounds(Handle graphics, out GpRectF rect); +Status GdipGetClipBoundsI(Handle graphics, out GpRect rect); +Status GdipGetVisibleClipBounds(Handle graphics, out GpRectF rect); +Status GdipGetVisibleClipBoundsI(Handle graphics, out GpRect rect); +Status GdipIsClipEmpty(Handle graphics, out int result); +Status GdipIsVisibleClipEmpty(Handle graphics, out int result); +Status GdipGetRenderingOrigin(Handle graphics, out int x, out int y); +Status GdipSetRenderingOrigin(Handle graphics, int x, int y); +Status GdipGetNearestColor(Handle graphics, ref int argb); +Status GdipComment(Handle graphics, uint sizeData, ubyte* data); +Status GdipTransformPoints(Handle graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, GpPointF* points, int count); +Status GdipTransformPointsI(Handle graphics, CoordinateSpace destSpace, CoordinateSpace srcSpace, GpPoint* points, int count); + +Status GdipCreateMatrix(out Handle matrix); +Status GdipCreateMatrix2(float m11, float m12, float m21, float m22, float dx, float dy, out Handle matrix); +Status GdipCreateMatrix3(ref GpRectF rect, GpPointF* dstplg, out Handle matrix); +Status GdipCreateMatrix3I(ref GpRect rect, GpPoint* dstplg, out Handle matrix); +Status GdipDeleteMatrix(Handle matrix); +Status GdipCloneMatrix(Handle matrix, out Handle cloneMatrix); +Status GdipGetMatrixElements(Handle matrix, float* matrixOut); +Status GdipSetMatrixElements(Handle matrix, float m11, float m12, float m21, float m22, float xy, float dy); +Status GdipInvertMatrix(Handle matrix); +Status GdipMultiplyMatrix(Handle matrix, Handle matrix2, MatrixOrder order); +Status GdipScaleMatrix(Handle matrix, float scaleX, float scaleY, MatrixOrder order); +Status GdipShearMatrix(Handle matrix, float shearX, float shearY, MatrixOrder order); +Status GdipRotateMatrix(Handle matrix, float angle, MatrixOrder order); +Status GdipTranslateMatrix(Handle matrix, float offsetX, float offsetY, MatrixOrder order); +Status GdipIsMatrixIdentity(Handle matrix, out int result); +Status GdipIsMatrixInvertible(Handle matrix, out int result); +Status GdipTransformMatrixPoints(Handle matrix, GpPointF *pts, int count); + +Status GdipGetBrushType(Handle brush, out BrushType type ); +Status GdipCloneBrush(Handle brush, out Handle cloneBrush); +Status GdipDeleteBrush(Handle brush); + +Status GdipCreateSolidFill(int color, out Handle brush); +Status GdipGetSolidFillColor(Handle brush, out int color); +Status GdipSetSolidFillColor(Handle brush, int color); + +Status GdipCreateTexture(Handle image, WrapMode wrapMode, out Handle texture); +Status GdipCreateTexture2(Handle image, WrapMode wrapMode, float x, float y, float width, float height, out Handle texture); +Status GdipCreateTexture2I(Handle image, WrapMode wrapMode, int x, int y, int width, int height, out Handle texture); +Status GdipGetTextureImage(Handle brush, out Handle image); +Status GdipGetTextureTransform(Handle brush, out Handle matrix); +Status GdipSetTextureTransform(Handle brush, Handle matrix); +Status GdipGetTextureWrapMode(Handle brush, out WrapMode wrapmode); +Status GdipSetTextureWrapMode(Handle brush, WrapMode wrapmode); + +Status GdipCreateHatchBrush(HatchStyle hatchstyle, int forecol, int backcol, out Handle brush); +Status GdipGetHatchStyle(Handle brush, out HatchStyle hatchstyle); +Status GdipGetHatchForegroundColor(Handle brush, out int forecol); +Status GdipGetHatchBackgroundColor(Handle brush, out int backcol); + +Status GdipCreateLineBrushI(ref GpPoint point1, ref GpPoint point2, int color1, int color2, WrapMode wrapMode, out Handle lineGradient); +Status GdipCreateLineBrush(ref GpPointF point1, ref GpPointF point2, int color1, int color2, WrapMode wrapMode, out Handle lineGradient); +Status GdipCreateLineBrushFromRectI(ref GpRect rect, int color1, int color2, LinearGradientMode mode, WrapMode wrapMode, out Handle lineGradient); +Status GdipCreateLineBrushFromRect(ref GpRectF rect, int color1, int color2, LinearGradientMode mode, WrapMode wrapMode, out Handle lineGradient); +Status GdipCreateLineBrushFromRectWithAngleI(ref GpRect rect, int color1, int color2, float angle, int isAngleScalable, WrapMode wrapMode, out Handle lineGradient); +Status GdipCreateLineBrushFromRectWithAngle(ref GpRectF rect, int color1, int color2, float angle, int isAngleScalable, WrapMode wrapMode, out Handle lineGradient); +Status GdipGetLineBlendCount(Handle brush, out int count); +Status GdipGetLineBlend(Handle brush, float* blend, float* positions, int count); +Status GdipSetLineBlend(Handle brush, float* blend, float* positions, int count); +Status GdipGetLinePresetBlendCount(Handle brush, out int count); +Status GdipGetLinePresetBlend(Handle brush, uint* blend, float* positions, int count); +Status GdipSetLinePresetBlend(Handle brush, uint* blend, float* positions, int count); +Status GdipGetLineWrapMode(Handle brush, out WrapMode wrapmode); +Status GdipSetLineWrapMode(Handle brush, WrapMode wrapmode); +Status GdipGetLineRect(Handle brush, out GpRectF rect); +Status GdipGetLineColors(Handle brush, int* colors); +Status GdipSetLineColors(Handle brush, int color1, int color2); +Status GdipGetLineGammaCorrection(Handle brush, out int useGammaCorrection); +Status GdipSetLineGammaCorrection(Handle brush, int useGammaCorrection); +Status GdipSetLineSigmaBlend(Handle brush, float focus, float scale); +Status GdipSetLineLinearBlend(Handle brush, float focus, float scale); +Status GdipGetLineTransform(Handle brush, out Handle matrix); +Status GdipSetLineTransform(Handle brush, Handle matrix); +Status GdipResetLineTransform(Handle brush); +Status GdipMultiplyLineTransform(Handle brush, Handle matrix, MatrixOrder order); +Status GdipTranslateLineTransform(Handle brush, float dx, float dy, MatrixOrder order); +Status GdipScaleLineTransform(Handle brush, float sx, float sy, MatrixOrder order); +Status GdipRotateLineTransform(Handle brush, float angle, MatrixOrder order); + +Status GdipCreatePen1(int argb, float width, GraphicsUnit unit, out Handle pen); +Status GdipCreatePen2(Handle brush, float width, GraphicsUnit unit, out Handle pen); +Status GdipDeletePen(Handle pen); +Status GdipClonePen(Handle pen, out Handle clonepen); +Status GdipSetPenLineCap197819(Handle pen, LineCap startCap, LineCap endCap, DashCap dashCap); +Status GdipGetPenStartCap(Handle pen, out LineCap startCap); +Status GdipSetPenStartCap(Handle pen, LineCap startCap); +Status GdipGetPenEndCap(Handle pen, out LineCap endCap); +Status GdipSetPenEndCap(Handle pen, LineCap endCap); +Status GdipGetPenDashCap197819(Handle pen, out DashCap endCap); +Status GdipSetPenDashCap197819(Handle pen, DashCap endCap); +Status GdipGetPenLineJoin(Handle pen, out LineJoin lineJoin); +Status GdipSetPenLineJoin(Handle pen, LineJoin lineJoin); +Status GdipGetPenMiterLimit(Handle pen, out float miterLimit); +Status GdipSetPenMiterLimit(Handle pen, float miterLimit); +Status GdipGetPenMode(Handle pen, out PenAlignment penMode); +Status GdipSetPenMode(Handle pen, PenAlignment penMode); +Status GdipGetPenTransform(Handle pen, out Handle matrix); +Status GdipSetPenTransform(Handle pen, Handle matrix); +Status GdipResetPenTransform(Handle pen); +Status GdipMultiplyPenTransform(Handle pen, Handle matrix, MatrixOrder order); +Status GdipTranslatePenTransform(Handle pen, float dx, float dy, MatrixOrder order); +Status GdipScalePenTransform(Handle pen, float sx, float sy, MatrixOrder order); +Status GdipRotatePenTransform(Handle pen, float angle, MatrixOrder order); +Status GdipGetPenColor(Handle pen, out int argb); +Status GdipSetPenColor(Handle pen, int argb); +Status GdipGetPenWidth(Handle pen, out float width); +Status GdipSetPenWidth(Handle pen, float width); +Status GdipGetPenFillType(Handle pen, out PenType type); +Status GdipGetPenBrushFill(Handle pen, out Handle brush); +Status GdipSetPenBrushFill(Handle pen, Handle brush); +Status GdipGetPenDashStyle(Handle pen, out DashStyle dashstyle); +Status GdipSetPenDashStyle(Handle pen, DashStyle dashstyle); +Status GdipGetPenDashOffset(Handle pen, out float offset); +Status GdipSetPenDashOffset(Handle pen, float offset); +Status GdipGetPenDashCount(Handle pen, out int count); +Status GdipGetPenDashArray(Handle pen, float* dash, int count); +Status GdipSetPenDashArray(Handle pen, float* dash, int count); +Status GdipGetPenCompoundCount(Handle pen, out int count); +Status GdipGetPenCompoundArray(Handle pen, float* dash, int count); +Status GdipSetPenCompoundArray(Handle pen, float* dash, int count); + +Status GdipCreateRegion(out Handle region); +Status GdipCreateRegionRect(ref GpRectF rect, out Handle region); +Status GdipCreateRegionRectI(ref GpRect rect, out Handle region); +Status GdipCreateRegionPath(Handle path, out Handle region); +Status GdipCreateRegionHrgn(Handle hRgn, out Handle region); +Status GdipDeleteRegion(Handle region); +Status GdipSetInfinite(Handle region); +Status GdipSetEmpty(Handle region); +Status GdipCombineRegionRect(Handle region, ref GpRectF rect, CombineMode combineMode); +Status GdipCombineRegionRectI(Handle region, ref GpRect rect, CombineMode combineMode); +Status GdipCombineRegionPath(Handle region, Handle path, CombineMode combineMode); +Status GdipCombineRegionRegion(Handle region, Handle region, CombineMode combineMode); +Status GdipTranslateRegion(Handle region, float dx, float dy); +Status GdipTranslateRegionI(Handle region, int dx, int dy); +Status GdipTransformRegion(Handle region, Handle matrix); +Status GdipGetRegionBounds(Handle region, Handle graphics, out GpRectF rect); +Status GdipGetRegionHRgn(Handle region, Handle graphics, out Handle hRgn); +Status GdipIsEmptyRegion(Handle region, Handle graphics, out int result); +Status GdipIsInfiniteRegion(Handle region, Handle graphics, out int result); +Status GdipIsEqualRegion(Handle region1, Handle region2, Handle graphics, out int result); +Status GdipIsVisibleRegionPoint(Handle region, float x, float y, Handle graphics, out int result); +Status GdipIsVisibleRegionRect(Handle region, float x, float y, float width, float height, Handle graphics, out int result); +Status GdipIsVisibleRegionPointI(Handle region, int x, int y, Handle graphics, out int result); +Status GdipIsVisibleRegionRectI(Handle region, int x, int y, int width, int height, Handle graphics, out int result); +Status GdipGetRegionScansCount(Handle region, out int count, Handle matrix); +Status GdipGetRegionScans(Handle region, GpRectF* rects, out int count, Handle matrix); + +Status GdipDisposeImage(Handle image); +Status GdipImageForceValidation(Handle image); +Status GdipLoadImageFromFileICM(wchar* filename, out Handle image); +Status GdipLoadImageFromFile(wchar* filename, out Handle image); +// Status GdipLoadImageFromStreamICM(IStream stream, out Handle image); +// Status GdipLoadImageFromStream(IStream stream, out Handle image); +// Status GdipGetImageRawFormat(Handle image, out GUID format); +Status GdipGetImageEncodersSize(out int numEncoders, out int size); +// Status GdipGetImageEncoders(int numEncoders, int size, GpImageCodecInfo* encoders); +// Status GdipSaveImageToFile(Handle image, wchar* filename, ref GUID clsidEncoder, GpEncoderParameters* encoderParams); +// Status GdipSaveImageToStream(Handle image, IStream stream, ref GUID clsidEncoder, GpEncoderParameters* encoderParams); +// Status GdipSaveAdd(Handle image, GpEncoderParameters* encoderParams); +// Status GdipSaveAddImage(Handle image, Handle newImage, GpEncoderParameters* encoderParams); +Status GdipCloneImage(Handle image, out Handle cloneImage); +Status GdipGetImageType(Handle image, out int type); +Status GdipGetImageFlags(Handle image, out uint flags); +Status GdipGetImageWidth(Handle image, out uint width); +Status GdipGetImageHeight(Handle image, out uint height); +Status GdipGetImageHorizontalResolution(Handle image, out float resolution); +Status GdipGetImageVerticalResolution(Handle image, out float resolution); +Status GdipGetPropertyCount(Handle image, out int numOfProperty); +Status GdipGetPropertyIdList(Handle image, int numOfProperty, int* list); +Status GdipGetImagePixelFormat(Handle image, out PixelFormat format); +Status GdipGetImageDimension(Handle image, out float width, out float height); +Status GdipGetImageThumbnail(Handle image, int thumbWidth, int thumbHeight, out Handle thumbImage, GpGetThumbnailImageAbort callback, void* callbackData); +// Status GdipImageGetFrameCount(Handle image, ref GUID dimensionID, out int count); +// Status GdipImageSelectActiveFrame(Handle image, ref GUID dimensionID, int frameCount); +Status GdipImageGetFrameDimensionsCount(Handle image, out int count); +// Status GdipImageGetFrameDimensionsList(Handle image, GUID* dimensionIDs, int count); +Status GdipImageRotateFlip(Handle image, RotateFlipType rotateFlipType); +Status GdipGetPropertyItemSize(Handle image, int propId, out uint propSize); +Status GdipGetPropertyItem(Handle image, int propId, uint propSize, GpPropertyItem* buffer); +Status GdipSetPropertyItem(Handle image, ref GpPropertyItem buffer); +Status GdipRemovePropertyItem(Handle image, int propId); +Status GdipGetPropertySize(Handle image, out uint totalBufferSize, ref int numProperties); +Status GdipGetAllPropertyItems(Handle image, uint totalBufferSize, int numProperties, GpPropertyItem* allItems); +Status GdipGetImageBounds(Handle image, out GpRectF srcRect, out GraphicsUnit srcUnit); +// Status GdipGetEncoderParameterListSize(Handle image, ref GUID clsidEncoder, out uint size); +// Status GdipGetEncoderParameterList(Handle image, ref GUID clsidEncoder, uint size, GpEncoderParameters* buffer); +Status GdipGetImagePaletteSize(Handle image, out int size); +Status GdipGetImagePalette(Handle image, GpColorPalette* palette, int size); +Status GdipSetImagePalette(Handle image, GpColorPalette* palette); + +Status GdipCreateBitmapFromScan0(int width, int height, int stride, PixelFormat format, ubyte* scan0, out Handle bitmap); +Status GdipCreateBitmapFromHBITMAP(Handle hbitmap, Handle hpalette, out Handle bitmap); +Status GdipCreateBitmapFromHICON(Handle hicon, out Handle bitmap); +Status GdipCreateBitmapFromFileICM(wchar* fileName, out Handle bitmap); +Status GdipCreateBitmapFromFile(wchar* fileName, out Handle bitmap); +// Status GdipCreateBitmapFromStreamICM(IStream stream, out Handle bitmap); +// Status GdipCreateBitmapFromStream(IStream stream, out Handle bitmap); +Status GdipCreateBitmapFromGraphics(int width, int height, Handle graphics, out Handle bitmap); +Status GdipCloneBitmapArea(float x, float y, float width, float height, PixelFormat format, Handle srcbitmap, out Handle dstbitmap); +Status GdipCloneBitmapAreaI(int x, int y, int width, int height, PixelFormat format, Handle srcbitmap, out Handle dstbitmap); +Status GdipBitmapGetPixel(Handle bitmap, int x, int y, out int color); +Status GdipBitmapSetPixel(Handle bitmap, int x, int y, int color); +Status GdipBitmapLockBits(Handle bitmap, GpRect* rect, ImageLockMode flags, PixelFormat format, GpBitmapData* lockedBitmapData); +Status GdipBitmapUnlockBits(Handle bitmap, GpBitmapData* lockedBitmapData); +Status GdipBitmapSetResolution(Handle bitmap, float xdpi, float ydpi); +Status GdipCreateHICONFromBitmap(Handle bitmap, out Handle hbmReturn); +Status GdipCreateHBITMAPFromBitmap(Handle bitmap, out Handle hbmReturn, int background); + +Status GdipCreateImageAttributes(out Handle imageattr); +Status GdipDisposeImageAttributes(Handle imageattr); +Status GdipSetImageAttributesColorMatrix(Handle imageattr, ColorAdjustType type, int enableFlag, GpColorMatrix* colorMatrix, GpColorMatrix* grayMatrix, ColorMatrixFlag flags); +Status GdipSetImageAttributesThreshold(Handle imageattr, ColorAdjustType type, int enableFlag, float threshold); +Status GdipSetImageAttributesGamma(Handle imageattr, ColorAdjustType type, int enableFlag, float gamma); +Status GdipSetImageAttributesNoOp(Handle imageattr, ColorAdjustType type, int enableFlag); +Status GdipSetImageAttributesColorKeys(Handle imageattr, ColorAdjustType type, int enableFlag, int colorLow, int colorHigh); +Status GdipSetImageAttributesOutputChannel(Handle imageattr, ColorAdjustType type, int enableFlag, ColorChannelFlag flags); +Status GdipSetImageAttributesOutputChannelColorProfile(Handle imageattr, ColorAdjustType type, int enableFlag, wchar* colorProfileFilename); +Status GdipSetImageAttributesWrapMode(Handle imageattr, WrapMode wrap, int argb, int clamp); + +Status GdipNewInstalledFontCollection(out Handle fontCollection); +Status GdipNewPrivateFontCollection(out Handle fontCollection); +Status GdipDeletePrivateFontCollection(Handle fontCollection); +Status GdipPrivateAddFontFile(Handle fontCollection, wchar* filename); +Status GdipPrivateAddMemoryFont(Handle fontCollection, void* memory, int length); +Status GdipGetFontCollectionFamilyCount(Handle fontCollection, out int numFound); +Status GdipGetFontCollectionFamilyList(Handle fontCollection, int numSought, Handle* gpfamilies, out int numFound); + +Status GdipCreateFontFamilyFromName(wchar* name, Handle fontCollection, out Handle FontFamily); +Status GdipDeleteFontFamily(Handle FontFamily); +Status GdipCloneFontFamily(Handle FontFamily, out Handle clonedFontFamily); +Status GdipGetFamilyName(Handle family, wchar* name, int language); +Status GdipGetGenericFontFamilyMonospace(out Handle nativeFamily); +Status GdipGetGenericFontFamilySerif(out Handle nativeFamily); +Status GdipGetGenericFontFamilySansSerif(out Handle nativeFamily); +Status GdipGetEmHeight(Handle family, FontStyle style, out short EmHeight); +Status GdipGetCellAscent(Handle family, FontStyle style, out short CellAscent); +Status GdipGetCellDescent(Handle family, FontStyle style, out short CellDescent); +Status GdipGetLineSpacing(Handle family, FontStyle style, out short LineSpacing); +Status GdipIsStyleAvailable(Handle family, FontStyle style, out int IsStyleAvailable); + +Status GdipCreateFont(Handle fontFamily, float emSize, int style, int unit, out Handle font); +Status GdipCreateFontFromDC(Handle hdc, out Handle font); +Status GdipDeleteFont(Handle font); +Status GdipCloneFont(Handle font, out Handle cloneFont); +Status GdipGetFontSize(Handle font, out float size); +Status GdipGetFontHeight(Handle font, Handle graphics, out float height); +Status GdipGetFontHeightGivenDPI(Handle font, float dpi, out float height); +Status GdipGetFontStyle(Handle font, out FontStyle style); +Status GdipGetFontUnit(Handle font, out GraphicsUnit unit); +Status GdipGetFamily(Handle font, out Handle family); +Status GdipCreateFontFromLogfontW( Handle hdc, ref LOGFONTW logfont, out Handle font); +Status GdipCreateFontFromLogfontA( Handle hdc, ref LOGFONTA logfont, out Handle font ); + +Status GdipGetLogFontW(Handle font, Handle graphics, out LOGFONTW logfontW); +alias GdipGetLogFontW GdipGetLogFont; + +Status GdipCreateStringFormat(StringFormatFlags formatAttributes, int language, out Handle format); +Status GdipDeleteStringFormat(Handle format); +Status GdipGetStringFormatFlags(Handle format, out StringFormatFlags flags); +Status GdipSetStringFormatFlags(Handle format, StringFormatFlags flags); +Status GdipGetStringFormatAlign(Handle format, out StringAlignment alignment); +Status GdipSetStringFormatAlign(Handle format, StringAlignment alignment); +Status GdipGetStringFormatLineAlign(Handle format, out StringAlignment alignment); +Status GdipSetStringFormatLineAlign(Handle format, StringAlignment alignment); +Status GdipGetStringFormatTrimming(Handle format, out StringTrimming trimming); +Status GdipSetStringFormatTrimming(Handle format, StringTrimming trimming); + +Status GdipCreatePath(FillMode brushMode, out Handle path); +Status GdipCreatePath2(GpPointF*, ubyte*, int, FillMode, out Handle); +Status GdipCreatePath2I(GpPoint*, ubyte*, int, FillMode, out Handle); +Status GdipDeletePath(Handle path); +Status GdipClonePath(Handle path, out Handle clonepath); +Status GdipResetPath(Handle path); +Status GdipGetPathFillMode(Handle path, out FillMode fillmode); +Status GdipSetPathFillMode(Handle path, FillMode fillmode); +Status GdipStartPathFigure(Handle path); +Status GdipClosePathFigure(Handle path); +Status GdipClosePathFigures(Handle path); +Status GdipSetPathMarker(Handle path); +Status GdipClearPathMarkers(Handle path); +Status GdipReversePath(Handle path); +Status GdipGetPathLastPoint(Handle path, out GpPointF lastPoint); +Status GdipAddPathLine(Handle path, float x1, float y1, float x2, float y2); +Status GdipAddPathLineI(Handle path, int x1, int y1, int x2, int y2); +Status GdipAddPathLine2(Handle path, GpPointF* points, int count); +Status GdipAddPathLine2I(Handle path, GpPoint* points, int count); +Status GdipAddPathArc(Handle path, float x, float y, float width, float height, float startAngle, float sweepAngle); +Status GdipAddPathArcI(Handle path, int x, int y, int width, int height, float startAngle, float sweepAngle); +Status GdipAddPathBezier(Handle path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4); +Status GdipAddPathBezierI(Handle path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4); +Status GdipAddPathBeziers(Handle path, GpPointF* points, int count); +Status GdipAddPathBeziersI(Handle path, GpPoint* points, int count); +Status GdipAddPathCurve(Handle path, GpPointF* points, int count); +Status GdipAddPathCurveI(Handle path, GpPoint* points, int count); +Status GdipAddPathCurve2(Handle path, GpPointF* points, int count, float tension); +Status GdipAddPathCurve2I(Handle path, GpPoint* points, int count, float tension); +Status GdipAddPathCurve3(Handle path, GpPointF* points, int count, int offset, int numberOfSegments, float tension); +Status GdipAddPathCurve3I(Handle path, GpPoint* points, int count, int offset, int numberOfSegments, float tension); +Status GdipAddPathClosedCurve(Handle path, GpPointF* points, int count); +Status GdipAddPathClosedCurveI(Handle path, GpPoint* points, int count); +Status GdipAddPathClosedCurve2(Handle path, GpPointF* points, int count, float tension); +Status GdipAddPathClosedCurve2I(Handle path, GpPoint* points, int count, float tension); +Status GdipAddPathRectangle(Handle path, float x, float y, float width, float height); +Status GdipAddPathRectangleI(Handle path, int x, int y, int width, int height); +Status GdipAddPathRectangles(Handle path, GpRectF* rects, int count); +Status GdipAddPathRectanglesI(Handle path, GpRect* rects, int count); +Status GdipAddPathEllipse(Handle path, float x, float y, float width, float height); +Status GdipAddPathEllipseI(Handle path, int x, int y, int width, int height); +Status GdipAddPathPie(Handle path, float x, float y, float width, float height, float startAngle, float sweepAngle); +Status GdipAddPathPieI(Handle path, int x, int y, int width, int height, float startAngle, float sweepAngle); +Status GdipAddPathPolygon(Handle path, GpPointF* points, int count); +Status GdipAddPathPolygonI(Handle path, GpPoint* points, int count); +Status GdipAddPathPath(Handle path, Handle addingPath, int connect); +Status GdipAddPathString(Handle path, wchar* string, int length, Handle family, FontStyle style, float emSize, ref GpRectF layoutRect, Handle format); +Status GdipAddPathStringI(Handle path, wchar* string, int length, Handle family, FontStyle style, float emSize, ref GpRect layoutRect, Handle format); +Status GdipTransformPath(Handle path, Handle matrix); +Status GdipGetPathWorldBounds(Handle path, out GpRectF bounds, Handle matrix, Handle pen); +Status GdipFlattenPath(Handle path, Handle matrix, float flatness); +Status GdipWidenPath(Handle path, Handle pen, Handle matrix, float flatness); +Status GdipWindingModeOutline(Handle path, Handle matrix, float flatness); +Status GdipWarpPath(Handle path, Handle matrix, GpPointF* points, int count, float srcx, float srcy, float srcwidth, float srcwidth, WarpMode warpMode, float flatness); +Status GdipGetPointCount(Handle path, out int count); +Status GdipGetPathTypes(Handle path, byte* types, int count); +Status GdipGetPathPoints(Handle path, GpPointF* points, int count); +Status GdipIsVisiblePathPoint(Handle path, float x, float y, Handle graphics, out int result); +Status GdipIsVisiblePathPointI(Handle path, int x, int y, Handle graphics, out int result); +Status GdipIsOutlineVisiblePathPoint(Handle path, float x, float y, Handle pen, Handle graphics, out int result); +Status GdipIsOutlineVisiblePathPointI(Handle path, int x, int y, Handle pen, Handle graphics, out int result); +Status GdipDrawPath(Handle graphics, Handle pen, Handle path); + + +Status GdipCreatePathIter(out Handle iterator, Handle path); +Status GdipDeletePathIter(Handle iterator); +Status GdipPathIterNextSubpath(Handle iterator, out int resultCount, out int startIndex, out int endIndex, out int isClosed); +Status GdipPathIterNextSubpathPath(Handle iterator, out int resultCount, Handle path, out int isClosed); +Status GdipPathIterNextPathType(Handle iterator, out int resultCount, out ubyte pathType, out int startIndex, out int endIndex); +Status GdipPathIterNextMarker(Handle iterator, out int resultCount, out int startIndex, out int endIndex); +Status GdipPathIterNextMarkerPath(Handle iterator, out int resultCount, Handle path); +Status GdipPathIterGetCount(Handle iterator, out int count); +Status GdipPathIterGetSubpathCount(Handle iterator, out int count); +Status GdipPathIterHasCurve(Handle iterator, out int hasCurve); +Status GdipPathIterRewind(Handle iterator); +Status GdipPathIterEnumerate(Handle iterator, out int resultCount, GpPointF* points, ubyte* types, int count); +Status GdipPathIterCopyData(Handle iterator, out int resultCount, GpPointF* points, ubyte* types, int startIndex, int endIndex); + +Status GdipCreatePathGradient(GpPointF* points, int count, WrapMode wrapMode, out Handle polyGradient); +Status GdipCreatePathGradientI(GpPoint* points, int count, WrapMode wrapMode, out Handle polyGradient); +Status GdipCreatePathGradientFromPath(Handle path, out Handle polyGradient); +Status GdipGetPathGradientCenterColor(Handle brush, out int colors); +Status GdipSetPathGradientCenterColor(Handle brush, int colors); +Status GdipGetPathGradientSurroundColorCount(Handle brush, out int count); +Status GdipGetPathGradientSurroundColorsWithCount(Handle brush, int* color, ref int count); +Status GdipSetPathGradientSurroundColorsWithCount(Handle brush, int* color, ref int count); +Status GdipGetPathGradientCenterPoint(Handle brush, ref GpPointF point); +Status GdipSetPathGradientCenterPoint(Handle brush, ref GpPointF point); +Status GdipGetPathGradientRect(Handle brush, ref GpRectF rect); +Status GdipGetPathGradientBlendCount(Handle brush, out int count); +Status GdipGetPathGradientBlend(Handle brush, float* blend, float* positions, int count); +Status GdipSetPathGradientBlend(Handle brush, float* blend, float* positions, int count); +Status GdipGetPathGradientPresetBlendCount(Handle brush, out int count); +Status GdipGetPathGradientPresetBlend(Handle brush, int* blend, float* positions, int count); +Status GdipSetPathGradientPresetBlend(Handle brush, int* blend, float* positions, int count); +Status GdipSetPathGradientSigmaBlend(Handle brush, float focus, float scale); +Status GdipSetPathGradientLinearBlend(Handle brush, float focus, float scale); +Status GdipGetPathGradientTransform(Handle brush, out Handle matrix); +Status GdipSetPathGradientTransform(Handle brush, Handle matrix); +Status GdipResetPathGradientTransform(Handle brush); +Status GdipMultiplyPathGradientTransform(Handle brush, Handle matrix, MatrixOrder order); +Status GdipRotatePathGradientTransform(Handle brush, float angle, MatrixOrder order); +Status GdipTranslatePathGradientTransform(Handle brush, float dx, float dy, MatrixOrder order); +Status GdipScalePathGradientTransform(Handle brush, float sx, float sy, MatrixOrder order); +Status GdipGetPathGradientFocusScales(Handle brush, out float xScale, out float yScale); +Status GdipSetPathGradientFocusScales(Handle brush, float xScale, float yScale); +Status GdipGetPathGradientWrapMode(Handle brush, out WrapMode wrapMode); +Status GdipSetPathGradientWrapMode(Handle brush, WrapMode wrapMode); + +//added + +Status GdipResetTextureTransform( Handle brush ); +Status GdipScaleTextureTransform( Handle brush, float sx, float sy, MatrixOrder order ); +Status GdipTranslateTextureTransform( Handle brush, float dx, float dy, MatrixOrder order); +Status GdipStringFormatGetGenericDefault(out Handle format); +Status GdipStringFormatGetGenericTypographic(out Handle format); +Status GdipSetStringFormatHotkeyPrefix(Handle format, int hotkeyPrefix); +Status GdipSetStringFormatTabStops( Handle format, float firstTabOffset, int count, float* tabStops); + +/****************************************************************************** + +******************************************************************************/ +/+ +private uint initToken; +private bool isShutdown; + +public int startup() { + static GdiplusStartupInput input = { 1, null, 0, 0 }; + static GdiplusStartupOutput output; + + return GdiplusStartup(initToken, input, output); +} + +public void shutdown() { + // GC.collect(); + isShutdown = true; + + GdiplusShutdown(initToken); +} ++/