📄 gapisurface.cs.svn-base
字号:
}
// public UInt32 CGapiSurface_AlphaBltFast (IntPtr pSurface, int dwX, int dwY, IntPtr pSrcSurface, ref GDRect pSrcRect, IntPtr pAlphaSurface, ref GDRect pAlphaRect, int dwFlags, ref GDALPHABLTFASTFX pGDABltFastFx);
public void AlphaBltFast(int dwX, int dwY, GapiSurface srcSurface, ref GDRect pSrcRect, GapiSurface alphaSurface, ref GDRect alphaRect, AlphaBltFastOptions dwFlags, ref GDALPHABLTFASTFX pGDBltFastFx)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_AlphaBltFast(unmanagedGapiObject, dwX, dwY, srcSurface.GapiObject, ref pSrcRect, alphaSurface.GapiObject, ref alphaRect, (int)dwFlags, ref pGDBltFastFx));
}
public void AlphaBltFast(int dwX, int dwY, GapiSurface srcSurface, ref GDRect srcRect, GapiSurface alphaSurface, ref GDRect alphaRect)
{
unsafe
{
fixed (GDRect* pSrcRect = &srcRect)
fixed (GDRect* pAlphaRect = &alphaRect)
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_AlphaBltFastNoRefs(unmanagedGapiObject, dwX, dwY, srcSurface.GapiObject, pSrcRect, alphaSurface.GapiObject, pAlphaRect, (int)0, null));
}
}
// public UInt32 CGapiSurface_AlphaBlt (IntPtr pSurface, ref GDRect pDestRect, IntPtr pSrcSurface, ref GDRect pSrcRect, IntPtr pAlphaSurface, ref GDRect pAlphaRect, int dwFlags, ref GDALPHABLTFX pGDAlphaBltFx);
public void AlphaBlt(ref GDRect pDestRect, GapiSurface srcSurface, ref GDRect pSrcRect, GapiSurface alphaSurface, ref GDRect alphaRect, AlphaBltOptions dwFlags, ref GDALPHABLTFX pGDAlphaBltFx)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_AlphaBlt(unmanagedGapiObject, ref pDestRect, srcSurface.GapiObject, ref pSrcRect, alphaSurface.GapiObject, ref alphaRect, (int)dwFlags, ref pGDAlphaBltFx));
}
public void AlphaBlt(ref GDRect pDestRect, GapiSurface srcSurface, GapiSurface alphaSurface, ref GDRect alphaRect)
{
unsafe
{
fixed (GDRect* pAlphaRect = &alphaRect)
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_AlphaBltNoRect(unmanagedGapiObject, ref pDestRect, srcSurface.GapiObject, null, alphaSurface.GapiObject, ref alphaRect, 0, null));
}
}
public void AlphaBlt(ref GDRect pDestRect, GapiSurface srcSurface, ref GDRect srcRect, GapiSurface alphaSurface, ref GDRect alphaRect)
{
unsafe
{
fixed (GDRect* pSrcRect = &srcRect)
fixed (GDRect* pAlphaRect = &alphaRect)
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_AlphaBltNoRect(unmanagedGapiObject, ref pDestRect, srcSurface.GapiObject, pSrcRect, alphaSurface.GapiObject, ref alphaRect, 0, null));
}
}
// public UInt32 CGapiSurface_GetPixel (IntPtr pSurface, int dwX, int dwY, ref int pColor);
public int GetPixel(int dwX, int dwY)
{
int result;
GdNet.CGapiSurface_GetPixel(unmanagedGapiObject, dwX, dwY, out result);
return result;
}
// public UInt32 CGapiSurface_SetPixel (IntPtr pSurface, int dwX, int dwY, int dwColor);
public UInt32 SetPixel(int dwX, int dwY, int dwColor)
{
return GdNet.CGapiSurface_SetPixel(unmanagedGapiObject, dwX, dwY, dwColor);
}
// public UInt32 CGapiSurface_SetPixelsArray(IntPtr pSurface, ref GDPIXEL pFirst, int dwElementSize, int dwElementCount, int dwFlags);
public void SetPixels(GDPIXEL[] pFirst, int dwElementSize, SetPixelsOptions dwFlags)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_SetPixelsArray(unmanagedGapiObject, ref pFirst[0], dwElementSize, pFirst.Length, (int)dwFlags));
}
public void SetPixels(GDPIXEL[] pFirst, int dwElementSize)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_SetPixelsArray(unmanagedGapiObject, ref pFirst[0], dwElementSize, pFirst.Length, 0));
}
// public UInt32 CGapiSurface_SetPixelsList(IntPtr pSurface, ref GDPIXELNODE pHead, int dwFlags);
public void SetPixels(ref GDPIXELNODE pHead, int dwFlags)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_SetPixelsList(unmanagedGapiObject, ref pHead, dwFlags));
}
public void SetPixelsArray(GDPIXEL[] pFirst, int dwElementSize)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_SetPixelsArray(unmanagedGapiObject, ref pFirst[0], dwElementSize, pFirst.Length, 0));
}
public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
{
DrawLine(x1, y1, x2, y2, GapiUtility.RGB(pen.Color));
}
// public UInt32 CGapiSurface_DrawLine(IntPtr pSurface, int dwX1, int dwY1, int dwX2, int dwY2, int dwColor, int dwFlags, ref GDLINEFX pGDLineFx);
public void DrawLine(int dwX1, int dwY1, int dwX2, int dwY2, int dwColor, DrawLineOptions dwFlags, ref GDLINEFX pGDLineFx)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_DrawLine(unmanagedGapiObject, dwX1, dwY1, dwX2, dwY2, dwColor, (int)dwFlags, ref pGDLineFx));
}
public UInt32 DrawLine(int dwX1, int dwY1, int dwX2, int dwY2, int dwColor)
{
unsafe
{
return (GdNet.CGapiSurface_DrawLineNoOptions(unmanagedGapiObject, dwX1, dwY1, dwX2, dwY2, dwColor, 0, null));
}
}
// public UInt32 CGapiSurface_DrawRect(IntPtr pSurface, ref GDRect pRect, int dwColor, int dwFlags, ref GDLINEFX pGDLineFx);
public void DrawRect(ref GDRect pRect, int dwColor, DrawLineOptions dwFlags, ref GDLINEFX pGDLineFx)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_DrawRect(unmanagedGapiObject, ref pRect, dwColor, (int)dwFlags, ref pGDLineFx));
}
public UInt32 DrawRect(ref GDRect pRect, int dwColor)
{
unsafe
{
return (GdNet.CGapiSurface_DrawRectNoOptions(unmanagedGapiObject, ref pRect, dwColor, 0, null));
}
}
// public UInt32 CGapiSurface_FillRect(IntPtr pSurface, ref GDRect pRect, int dwColor, int dwFlags, ref GDFILLRECTFX pGDFillRectFx);
/// <summary>
/// For best performance, try to keep the width of the rectangle as a power of two (2, 4, 8, 16, 32, ...).
/// </summary>
/// <param name="rect"></param>
/// <param name="dwColor"></param>
/// <param name="dwFlags"></param>
/// <param name="gDFillRectFx"></param>
public void FillRect(ref GDRect rect, int dwColor, FillRectOptions dwFlags, ref GDFILLRECTFX gDFillRectFx)
{
// TODO : GDFILLRECTFX doesn't seem to be working!
unsafe
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_FillRectRefs(unmanagedGapiObject, ref rect, dwColor, (int)dwFlags, ref gDFillRectFx));
}
}
public void FillRectangle(Brush brush, Rectangle rectangle)
{
FillRect(GapiUtility.RectToGDRect(rectangle), GapiUtility.RGB(((SolidBrush)brush).Color));
}
public void FillRectangle(Brush brush, int x, int y, int width, int height)
{
FillRectangle(brush, new Rectangle(x, y, width, height));
}
public void FillRect(GDRect rect, int dwColor, FillRectOptions dwFlags, ref GDFILLRECTFX gDFillRectFx)
{
// TODO : remove this one
unsafe
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_FillRectRefs(unmanagedGapiObject, ref rect, dwColor, (int)dwFlags, ref gDFillRectFx));
}
}
public UInt32 FillRect(GDRect rect, int dwColor)
{
unsafe
{
return (GdNet.CGapiSurface_FillRect(unmanagedGapiObject, &rect, dwColor, 0, null));
}
}
GDFILLRECTFX opacityFillRectFx = new GDFILLRECTFX();
public UInt32 FillRect(ref GDRect rect, int dwColor, int opacity)
{
// TODO : GDFILLRECTFX doesn't seem to be working!
unsafe
{
opacityFillRectFx.dwOpacity = opacity;
return (GdNet.CGapiSurface_FillRectRefs(unmanagedGapiObject, ref rect, dwColor, (int)FillRectOptions.GDFILLRECT_OPACITY, ref opacityFillRectFx));
}
}
public UInt32 FillRect(int dwColor, FillRectOptions dwFlags, GDFILLRECTFX pGDFillRectFx)
{
unsafe
{
return (GdNet.CGapiSurface_FillRect(unmanagedGapiObject, null, dwColor, (int)dwFlags, &pGDFillRectFx));
}
}
public UInt32 FillRect(int dwColor, FillRectOptions dwFlags)
{
unsafe
{
return (GdNet.CGapiSurface_FillRect(unmanagedGapiObject, null, dwColor, (int)dwFlags, null));
}
}
public void FillRect(int dwColor)
{
unsafe
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_FillRect(unmanagedGapiObject, null, dwColor, 0, null));
}
}
// public static extern UInt32 CGapiSurface_DrawTextBitmapFont(IntPtr pSurface, int dwX, int dwY, string pString, IntPtr pFont, int dwTextFlags, int dwBltFastFlags, IntPtr pGDBltFastFx, out int pWidth);
//public int GetTextWidth(string drawString, GapiBitmapFont font)
//{
// int result;
// GdNet.CGapiBitmapFont_GetStringWidth (font.GapiObject, drawString, out result);
// /// TODO : fix GetTextWidth
// // GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_DrawTextBitmapFont(unmanagedGapiObject, 0, 0, drawString, font.GapiObject, (int)DrawTextOptions.GDDRAWTEXT_CALCWIDTH, 0, IntPtr.Zero, out result));
// return result;
//}
public void GetClipper(ref GDRect clipRect)
{
GdNet.CGapiSurface_GetClipper(unmanagedGapiObject, ref clipRect);
}
public void ResetClip() // .net's name
{
ClearClipper();
}
public void ClearClipper()
{
SetClipper(new GDRect(0, 0, 0, 0));
}
public Rectangle Clip
{
set
{
SetClipper(GapiUtility.RectToGDRect(value));
}
}
public void SetClipper(ref GDRect clipRect)
{
GdNet.CGapiSurface_SetClipper(unmanagedGapiObject, ref clipRect);
}
public void SetClipper(GDRect clipRect)
{
GdNet.CGapiSurface_SetClipper(unmanagedGapiObject, ref clipRect);
}
public void SetClipper(int left, int top, int right, int bottom)
{
SetClipper(new GDRect(left, top, right, bottom));
}
//public void DrawText(int dwX, int dwY, string drawString, GapiBitmapFont font, DrawTextOptions dwFlags, GDTEXTFX gDTextFx)
//{
// int dummy;
// unsafe
// {
// IntPtr textFx = new IntPtr(&gDTextFx);
// GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_DrawTextGapiFont(unmanagedGapiObject, dwX, dwY, drawString, font.GapiObject, (int)dwFlags, textFx, out dummy));
// }
//}
public int DrawText(int dwX, int dwY, string drawString, IntPtr pFont, DrawTextOptions dwFlags)
{
int result;
/// TODO : Overload with missing paramters
unsafe
{
result = (int)GdNet.CGapiSurface_DrawText(unmanagedGapiObject, dwX, dwY, drawString, pFont, (int)dwFlags, IntPtr.Zero, 0, null);
}
return result;
}
public int DrawText(int dwX, int dwY, string drawString, IntPtr pFont, DrawTextOptions dwFlags, BltFastOptions bltFlags, GDBLTFASTFX fastfx )
{
int result;
/// TODO : Overload with missing paramters
unsafe
{
result = (int)GdNet.CGapiSurface_DrawText(unmanagedGapiObject, dwX, dwY, drawString, pFont, (int)dwFlags, IntPtr.Zero, (int)bltFlags, &fastfx);
}
return result;
}
public int DrawText(int dwX, int dwY, string drawString, GapiBitmapFont font, DrawTextOptions dwFlags, BltFastOptions bltFlags, GDBLTFASTFX fastfx)
{
int result;
/// TODO : Overload with missing paramters
unsafe
{
result = (int)GdNet.CGapiSurface_DrawText(unmanagedGapiObject, dwX, dwY, drawString, font.GapiObject, (int)dwFlags, IntPtr.Zero, (int)bltFlags, &fastfx);
}
return result;
}
public int DrawText(int dwX, int dwY, string drawString, GapiBitmapFont font, DrawTextOptions dwFlags)
{
int result;
/// TODO : Overload with missing paramters
unsafe
{
result = (int)GdNet.CGapiSurface_DrawText(unmanagedGapiObject, dwX, dwY, drawString, font.GapiObject, (int)dwFlags, IntPtr.Zero, 0, null);
}
return result;
}
// public UInt32 Intersect(int dwX1, int dwY1, IntPtr pSrcSurface1, ref GDRect pSrcRect1, int dwX2, int dwY2, IntPtr pSrcSurface2, ref GDRect pSrcRect2, ref System.Drawing.Point pIntersection);
public static void Intersect(int dwX1, int dwY1, GapiSurface srcSurface1, ref GDRect pSrcRect1, int dwX2, int dwY2, GapiSurface srcSurface2, ref GDRect pSrcRect2, ref System.Drawing.Point pIntersection)
{
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_Intersect(dwX1, dwY1, srcSurface1.GapiObject, ref pSrcRect1, dwX2, dwY2, srcSurface2.GapiObject, ref pSrcRect2, ref pIntersection));
}
public static System.Drawing.Point Intersect(int dwX1, int dwY1, GapiSurface srcSurface1, ref GDRect pSrcRect1, int dwX2, int dwY2, GapiSurface srcSurface2, ref GDRect pSrcRect2)
{
System.Drawing.Point point = new System.Drawing.Point(-1, -1);
GapiUtility.RaiseExceptionOnError(GdNet.CGapiSurface_Intersect(dwX1, dwY1, srcSurface1.GapiObject, ref pSrcRect1, dwX2, dwY2, srcSurface2.GapiObject, ref pSrcRect2, ref point));
return point;
}
// TODO : TEST THESE
//public static extern UInt32 CGapiSurface_ColorrefToNative(IntPtr pSurface, int dwColor, out int pNative);
public int ColorrefToNative(int dwColor)
{
int pNative;
GdNet.CGapiSurface_ColorrefToNative(unmanagedGapiObject, dwColor, out pNative);
return pNative;
}
// TODO : TEST THESE
//public static extern UInt32 CGapiSurface_NativeToColorref(IntPtr pSurface, int dwNative, out int pColor);
public int NativeToColorref(int dwNative)
{
int pColor;
GdNet.CGapiSurface_NativeToColorref(unmanagedGapiObject, dwNative, out pColor);
return pColor;
}
/// <summary>
/// Draws a colour tinted 2 tone semi-transparent glass box
/// </summary>
/// <param name="h"></param>
public void DrawGlassRect(GDRect h, int colour)
{
int half = h.Height / 2;
h.Bottom = h.Top + half;
FillRect(ref h, colour, 60);
h.Top = h.Bottom;
h.Bottom = h.Bottom + half;
FillRect(ref h, colour, 80);
}
/// <summary>
/// Draws a 2 tone semi-transparent glass box
/// </summary>
/// <param name="h"></param>
public void DrawGlassRect(GDRect h)
{
DrawGlassRect(h, 0);
}
public void DrawString(string text, GapiBitmapFont gapiBitmapFont, Brush brush, int x, int y)
{
DrawString(text, gapiBitmapFont, brush, x, y, DrawTextOptions.GDDRAWTEXT_LEFT);
}
public void DrawString(string text, GapiBitmapFont gapiBitmapFont, Brush brush, int x, int y, DrawTextOptions option )
{
GDBLTFASTFX fx = new GDBLTFASTFX();
fx.dwFillColor = GapiUtility.RGB(((SolidBrush)brush).Color);
DrawText(x, y, text, gapiBitmapFont, option, BltFastOptions.GDBLTFAST_COLORFILL, fx);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -