public GpStatus GetLastStatus() { GpStatus lastStatus = lastResult; lastResult = GpStatus.Ok; return lastStatus; }
GpStatus SetStatus(GpStatus status) { if (status != GpStatus.Ok) return (lastResult = status); else return status; }
public static void ThrowIfFailed(GpStatus status) { if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } }
public static void CheckStatus(GpStatus status) { if (status != GpStatus.Ok) { throw new InvalidOperationException($"GDI+ error: {status}."); } }
protected void SetStatus(GpStatus gpStatus) { if (gpStatus != GpStatus.Ok) { throw GdiPlusStatusException.Exception(gpStatus); } }
GpStatus GetLastStatus() { GpStatus lastStatus = lastError; lastError = GpStatus.Ok; return lastStatus; }
public GraphicsPlus(HDC hdc) { GpGraphics Graphics = new GpGraphics(); lastResult = GdiPlus.GdipCreateFromHDC(hdc, out Graphics); SetNativeGraphics(Graphics); }
public PenPlus(Color color, float width) { Unit unit = Unit. UnitWorld; nativePen = null; lastResult = NativeMethods.GdipCreatePen1(color.ToArgb(), width, unit, out nativePen); }
public PenPlus(Color color, float width, bool opaque) { int c = color.ToArgb(); if (opaque) c |= (0xff << 24); Unit unit = Unit.UnitWorld; nativePen = null; lastResult = GdiPlus.GdipCreatePen1(c, width, unit, out nativePen); }
public PenPlus(BrushPlus brush, float width) { Unit unit = Unit.UnitWorld; nativePen = null; lastResult = NativeMethods.GdipCreatePen2(brush.nativeBrush, width, unit, out nativePen); }
public PenPlus Clone() { GpPen clonePen = null; lastResult = NativeMethods.GdipClonePen(nativePen, out clonePen); return new PenPlus(clonePen, lastResult); }
public GpStatus GetLastStatus() { GpStatus lastStatus = lastResult; lastResult = GpStatus.Ok; return(lastStatus); }
RegionPlus(HRGN hRgn) { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegionHrgn(hRgn, out region); SetNativeRegion(region); }
RegionPlus(GraphicsPath path) { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegionPath(path.nativePath, out region); SetNativeRegion(region); }
RegionPlus(GpRect rect) { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegionRectI(ref rect, out region); SetNativeRegion(region); }
RegionPlus() { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegion(out region); SetNativeRegion(region); }
public GraphicsPlus(HDC hdc, HANDLE hdevice) { GpGraphics Graphics = new GpGraphics(); lastResult = GdiPlus.GdipCreateFromHDC2(hdc, hdevice, out Graphics); SetNativeGraphics(Graphics); }
GpStatus GetLastStatus() { GpStatus lastStatus = lastError; lastError = GpStatus.Ok; return(lastStatus); }
public IntPtr GetHBITMAP(Color colorBackground) { HBITMAP hbmReturn; GpStatus status = GdiPlus.GdipCreateHBITMAPFromBitmap((GpBitmap)(IntPtr)nativeImage, out hbmReturn, colorBackground.ToArgb()); SetStatus(status); return(hbmReturn.val); }
Matrix() { GpMatrix matrix; lastResult = NativeMethods.GdipCreateMatrix(out matrix); SetNativeMatrix(matrix); }
private unsafe static void DrawLines(GpGraphics graphics, GpPen pen, GpPoint *points, int count) { GpStatus status = Imports.GdipDrawLinesI(graphics, pen, points, count); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } }
private void Dispose(bool disposing) { GpStatus status = Imports.GdipDeleteBrush(_gpBrush); if (disposing) { status.ThrowIfFailed(); } }
RegionPlus(byte[] regionData) { GpRegion region = new GpRegion(); lastResult = NativeMethods.GdipCreateRegionRgnData(regionData, regionData.Length, out region); SetNativeRegion(region); }
public static void FillEllipse(GpGraphics graphics, GpBrush brush, int x, int y, int width, int height) { GpStatus status = Imports.GdipFillEllipseI(graphics, brush, x, y, width, height); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } }
public static void SetSmoothingMode(GpGraphics graphics, SmoothingMode smoothingMode) { GpStatus status = Imports.GdipSetSmoothingMode(graphics, smoothingMode); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } }
public GraphicsPlus(Graphics g) { this.g = g; hdc = g.GetHdc(); GpGraphics Graphics = new GpGraphics(); lastResult = GdiPlus.GdipCreateFromHDC(hdc, out Graphics); SetNativeGraphics(Graphics); }
public GraphicsPlus(ImagePlus image) { GpGraphics Graphics = new GpGraphics(); if (image != null) { lastResult = GdiPlus.GdipGetImageGraphicsContext(image.nativeImage, out Graphics); } SetNativeGraphics(Graphics); }
public static GpGraphics CreateGraphics(DeviceContext deviceContext) { GpStatus status = Imports.GdipCreateFromHDC(deviceContext, out GpGraphics graphics); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } return(graphics); }
GpStatus SetStatus(GpStatus status) { if (status != GpStatus.Ok) { return(lastResult = status); } else { return(status); } }
public static GpPen CreatePen(ARGB color, float width = 1.0f, GpUnit unit = GpUnit.UnitWorld) { GpStatus status = Imports.GdipCreatePen1(color, width, unit, out GpPen pen); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } return(pen); }
internal GpStatus SetStatus(GpStatus newStatus) { if (newStatus == GpStatus.Ok) { return(GpStatus.Ok); } else { return(lastError = newStatus); } }
internal GpStatus SetStatus(GpStatus newStatus) { if (newStatus == GpStatus.Ok) { return GpStatus.Ok; } else { return lastError = newStatus; } }
public static GpSolidBrush CreateSolidBrush(ARGB color) { GpStatus status = Imports.GdipCreateSolidFill(color, out GpSolidBrush brush); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } return(brush); }
Matrix( GpRectF rect, GpPointF[] dstplg) { GpMatrix matrix; lastResult = NativeMethods.GdipCreateMatrix3(rect, dstplg, out matrix); SetNativeMatrix(matrix); }
GpStatus GetForegroundColor(out Color color) { int argb; GpStatus status = SetStatus(GdiPlus.GdipGetHatchForegroundColor( (GpHatch)nativeBrush, out argb)); color = Color.FromArgb(argb); return(status); }
GpStatus GetBackgroundColor(out Color color) { int argb; GpStatus status = SetStatus(NativeMethods.GdipGetHatchBackgroundColor( (GpHatch)nativeBrush, out argb)); color = Color.FromArgb(argb); return(status); }
StringFormatPlus( int formatFlags, int language ) { nativeFormat = new GpStringFormat(); lastError = NativeMethods.GdipCreateStringFormat( formatFlags, language, out nativeFormat ); }
public GpStatus SetParameters([NativeTypeName("const Gdiplus::RedEyeCorrectionParams *")] RedEyeCorrectionParams *parameters) { GpStatus status = InvalidParameter; if ((parameters) != null) { RedEyeCorrectionParams *inputParam = (RedEyeCorrectionParams *)(parameters); uint size = unchecked ((uint)(sizeof(RedEyeCorrectionParams)) + inputParam->numberOfAreas * 16); status = Base.SetParameters(parameters, size); } return(status); }
Matrix(float m11, float m12, float m21, float m22, float dx, float dy) { GpMatrix matrix; lastResult = NativeMethods.GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, out matrix); SetNativeMatrix(matrix); }
GpStatus GetLinearColors(Color[] colors) { int[] argb = new int[2]; GpStatus status = SetStatus(GdiPlus.GdipGetLineColors((GpLineGradient)nativeBrush, argb)); if (status == GpStatus.Ok) { colors[0] = Color.FromArgb(argb[0]); colors[1] = Color.FromArgb(argb[1]); } return(status); }
public GraphicsPlus(HWND hwnd, bool icm) { GpGraphics Graphics = new GpGraphics(); if (icm) { lastResult = GdiPlus.GdipCreateFromHWNDICM(hwnd, out Graphics); } else { lastResult = GdiPlus.GdipCreateFromHWND(hwnd, out Graphics); } SetNativeGraphics(Graphics); }
GpStatus GetLinearColors(Color[] colors) { int[] argb = new int[2]; GpStatus status = SetStatus(NativeMethods.GdipGetLineColors((GpLineGradient)nativeBrush, argb)); if (status == GpStatus.Ok) { // use bitwise copy operator for Color copy colors[0] = Color.FromArgb(argb[0]); colors[1] = Color.FromArgb(argb[1]); } return(status); }
public static Exception GetExceptionForStatus(GpStatus status) { switch (status) { case GpStatus.Win32Error: WindowsError error = Error.GetLastError(); if (error != WindowsError.ERROR_SUCCESS) { return(error.GetException()); } goto default; default: return(new GdiPlusException(status)); } }
public static UIntPtr Startup() { var input = new GdiplusStartupInput { GdiplusVersion = 1 }; GpStatus status = Imports.GdiplusStartup( out UIntPtr token, ref input, out GdiplusStartupOutput _); if (status != GpStatus.Ok) { throw GetExceptionForStatus(status); } return(token); }
public GpStatus SetInterpolationColors(Color[] presetColors, float[] blendPositions) { int[] argbs = new int[presetColors.Length]; for (int i = 0; i < argbs.Length; i++) { argbs[i] = presetColors[i].ToArgb(); } GpStatus status = SetStatus(GdiPlus. GdipSetPathGradientPresetBlend( (GpPathGradient)nativeBrush, argbs, blendPositions, argbs.Length)); return(status); }
public GpStatus GetInterpolationColors(Color[] presetColors, float[] blendPositions) { int[] argbs = new int[presetColors.Length]; GpStatus status = SetStatus(NativeMethods.GdipGetPathGradientPresetBlend( (GpPathGradient)nativeBrush, argbs, blendPositions, argbs.Length)); for (int i = 0; i < presetColors.Length; i++) { presetColors[i] = Color.FromArgb(argbs[i]); } return(status); }
GpStatus SetInterpolationColors(Color[] presetColors, float[] blendPositions) { int count = presetColors.Length; int[] argbs = new int[count]; for (int i = 0; i < count; i++) { argbs[i] = presetColors[i].ToArgb(); } GpStatus status = SetStatus(NativeMethods.GdipSetLinePresetBlend( (GpLineGradient)nativeBrush, argbs, blendPositions, argbs.Length)); return(status); }
public GpStatus GetPixel( int x, int y, out Color color) { int argb; color = Color.Transparent; GpStatus status = SetStatus(NativeMethods.GdipBitmapGetPixel( (GpBitmap)(IntPtr)nativeImage, x, y, out argb)); if (status == GpStatus.Ok) { color = Color.FromArgb(argb); } return(status); }
public CustomLineCap( GraphicsPath fillPath, GraphicsPath strokePath, LineCap baseCap, float baseInset ) { nativeCap = new GpCustomLineCap(); GpPath nativeFillPath = null; GpPath nativeStrokePath = null; if (fillPath != null) nativeFillPath = fillPath.nativePath; if (strokePath != null) nativeStrokePath = strokePath.nativePath; lastResult = NativeMethods.GdipCreateCustomLineCap( nativeFillPath, nativeStrokePath, baseCap, baseInset, out nativeCap); }
GpStatus GetInterpolationColors(Color[] presetColors, float[] blendPositions) { int count = presetColors.Length; int[] argbs = new int[count]; GpStatus status = SetStatus(NativeMethods.GdipGetLinePresetBlend((GpLineGradient)nativeBrush, argbs, blendPositions, argbs.Length)); if (status == GpStatus.Ok) { for (int i = 0; i < count; i++) { presetColors[i] = Color.FromArgb(argbs[i]); } } return(status); }
public GdiPlusException(GpStatus status) : base(status.ToString()) { Status = status; }
public GdiPlusException(GpStatus status) : base() { Status = status; }
GpStatus SetStatus(GpStatus stat) { lastResult = stat; return stat; }
internal ImageAttributesPlus(GpImageAttributes imageAttr, GpStatus status) { SetNativeImageAttr(imageAttr); lastResult = status; }
public CustomLineCap(GpCustomLineCap nativeCap, GpStatus status) { lastResult = status; SetNativeCap(nativeCap); }
internal ImagePlus(GpImage nativeImage, GpStatus status) { SetNativeImage(nativeImage); }
protected void SetStatus(GpStatus gpStatus) { if (gpStatus != GpStatus.Ok) throw GdiPlusStatusException.Exception(gpStatus); }
protected GraphicsPlus(GpGraphics Graphics) { lastResult = GpStatus.Ok; SetNativeGraphics(Graphics); }
protected GpStatus SetStatus(GpStatus status) { GpStatusPlus sp = status; if (status != GpStatus.Ok) return (lastResult = status); else return status; }