예제 #1
0
        public GpStatus GetLastStatus()
        {
            GpStatus lastStatus = lastResult;
            lastResult = GpStatus.Ok;

            return lastStatus;
        }
예제 #2
0
 GpStatus SetStatus(GpStatus status)
 {
     if (status != GpStatus.Ok)
         return (lastResult = status);
     else
         return status;
 }
예제 #3
0
 public static void ThrowIfFailed(GpStatus status)
 {
     if (status != GpStatus.Ok)
     {
         throw GetExceptionForStatus(status);
     }
 }
예제 #4
0
 public static void CheckStatus(GpStatus status)
 {
     if (status != GpStatus.Ok)
     {
         throw new InvalidOperationException($"GDI+ error: {status}.");
     }
 }
예제 #5
0
 protected void SetStatus(GpStatus gpStatus)
 {
     if (gpStatus != GpStatus.Ok)
     {
         throw GdiPlusStatusException.Exception(gpStatus);
     }
 }
예제 #6
0
        GpStatus GetLastStatus()
        {
            GpStatus lastStatus = lastError;
            lastError = GpStatus.Ok;

            return lastStatus;
        }
예제 #7
0
        public GraphicsPlus(HDC hdc)
        {
            GpGraphics Graphics = new GpGraphics();

            lastResult = GdiPlus.GdipCreateFromHDC(hdc, out Graphics);

            SetNativeGraphics(Graphics);
        }
예제 #8
0
파일: PenPlus.cs 프로젝트: misiek/foo
 public PenPlus(Color color,
     float width)
 {
     Unit unit = Unit. UnitWorld;
     nativePen = null;
     lastResult = NativeMethods.GdipCreatePen1(color.ToArgb(),
                                 width, unit, out nativePen);
 }
예제 #9
0
파일: PenPlus.cs 프로젝트: north0808/haina
 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);
 }
예제 #10
0
파일: PenPlus.cs 프로젝트: misiek/foo
 public PenPlus(BrushPlus brush,
     float width)
 {
     Unit unit = Unit.UnitWorld;
     nativePen = null;
     lastResult = NativeMethods.GdipCreatePen2(brush.nativeBrush,
                                 width, unit, out nativePen);
 }
예제 #11
0
파일: PenPlus.cs 프로젝트: misiek/foo
        public PenPlus Clone()
        {
            GpPen clonePen = null;

            lastResult = NativeMethods.GdipClonePen(nativePen, out clonePen);

            return new PenPlus(clonePen, lastResult);
        }
예제 #12
0
        public GpStatus GetLastStatus()
        {
            GpStatus lastStatus = lastResult;

            lastResult = GpStatus.Ok;

            return(lastStatus);
        }
예제 #13
0
파일: RegionPlus.cs 프로젝트: misiek/foo
        RegionPlus(HRGN hRgn)
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegionHrgn(hRgn, out region);

            SetNativeRegion(region);
        }
예제 #14
0
파일: RegionPlus.cs 프로젝트: misiek/foo
        RegionPlus(GraphicsPath path)
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegionPath(path.nativePath, out region);

            SetNativeRegion(region);
        }
예제 #15
0
파일: RegionPlus.cs 프로젝트: misiek/foo
        RegionPlus(GpRect rect)
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegionRectI(ref rect, out region);

            SetNativeRegion(region);
        }
예제 #16
0
파일: RegionPlus.cs 프로젝트: misiek/foo
        RegionPlus()
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegion(out region);

            SetNativeRegion(region);
        }
예제 #17
0
        public GraphicsPlus(HDC hdc, HANDLE hdevice)
        {
            GpGraphics Graphics = new GpGraphics();

            lastResult = GdiPlus.GdipCreateFromHDC2(hdc, hdevice, out Graphics);

            SetNativeGraphics(Graphics);
        }
예제 #18
0
        GpStatus GetLastStatus()
        {
            GpStatus lastStatus = lastError;

            lastError = GpStatus.Ok;

            return(lastStatus);
        }
예제 #19
0
        public IntPtr GetHBITMAP(Color colorBackground)
        {
            HBITMAP  hbmReturn;
            GpStatus status = GdiPlus.GdipCreateHBITMAPFromBitmap((GpBitmap)(IntPtr)nativeImage, out hbmReturn, colorBackground.ToArgb());

            SetStatus(status);
            return(hbmReturn.val);
        }
예제 #20
0
파일: Matrix.cs 프로젝트: misiek/foo
        Matrix()
        {
            GpMatrix matrix;

            lastResult = NativeMethods.GdipCreateMatrix(out matrix);

            SetNativeMatrix(matrix);
        }
예제 #21
0
        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);
            }
        }
예제 #22
0
        private void Dispose(bool disposing)
        {
            GpStatus status = Imports.GdipDeleteBrush(_gpBrush);

            if (disposing)
            {
                status.ThrowIfFailed();
            }
        }
예제 #23
0
파일: RegionPlus.cs 프로젝트: misiek/foo
        RegionPlus(byte[] regionData)
        {
            GpRegion region = new GpRegion();

            lastResult = NativeMethods.GdipCreateRegionRgnData(regionData, regionData.Length,
                                                             out region);

            SetNativeRegion(region);
        }
예제 #24
0
        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);
            }
        }
예제 #25
0
        public static void SetSmoothingMode(GpGraphics graphics, SmoothingMode smoothingMode)
        {
            GpStatus status = Imports.GdipSetSmoothingMode(graphics, smoothingMode);

            if (status != GpStatus.Ok)
            {
                throw GetExceptionForStatus(status);
            }
        }
예제 #26
0
        public GraphicsPlus(Graphics g)
        {
            this.g = g;
            hdc = g.GetHdc();
            GpGraphics Graphics = new GpGraphics();

            lastResult = GdiPlus.GdipCreateFromHDC(hdc, out Graphics);

            SetNativeGraphics(Graphics);
        }
예제 #27
0
        public GraphicsPlus(ImagePlus image)
        {
            GpGraphics Graphics = new GpGraphics();

            if (image != null)
            {
                lastResult = GdiPlus.GdipGetImageGraphicsContext(image.nativeImage, out Graphics);
            }
            SetNativeGraphics(Graphics);
        }
예제 #28
0
        public static GpGraphics CreateGraphics(DeviceContext deviceContext)
        {
            GpStatus status = Imports.GdipCreateFromHDC(deviceContext, out GpGraphics graphics);

            if (status != GpStatus.Ok)
            {
                throw GetExceptionForStatus(status);
            }
            return(graphics);
        }
예제 #29
0
 GpStatus SetStatus(GpStatus status)
 {
     if (status != GpStatus.Ok)
     {
         return(lastResult = status);
     }
     else
     {
         return(status);
     }
 }
예제 #30
0
        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);
        }
예제 #31
0
 internal GpStatus SetStatus(GpStatus newStatus)
 {
     if (newStatus == GpStatus.Ok)
     {
         return(GpStatus.Ok);
     }
     else
     {
         return(lastError = newStatus);
     }
 }
예제 #32
0
 internal GpStatus SetStatus(GpStatus newStatus)
 {
     if (newStatus == GpStatus.Ok)
     {
         return GpStatus.Ok;
     }
     else
     {
         return lastError = newStatus;
     }
 }
예제 #33
0
        public static GpSolidBrush CreateSolidBrush(ARGB color)
        {
            GpStatus status = Imports.GdipCreateSolidFill(color, out GpSolidBrush brush);

            if (status != GpStatus.Ok)
            {
                throw GetExceptionForStatus(status);
            }

            return(brush);
        }
예제 #34
0
파일: Matrix.cs 프로젝트: misiek/foo
        Matrix( GpRectF rect, 
            GpPointF[] dstplg)
        {
            GpMatrix matrix;

            lastResult = NativeMethods.GdipCreateMatrix3(rect,
                                                   dstplg,
                                                   out matrix);

            SetNativeMatrix(matrix);
        }
예제 #35
0
        GpStatus GetForegroundColor(out Color color)
        {
            int argb;

            GpStatus status = SetStatus(GdiPlus.GdipGetHatchForegroundColor(
                                            (GpHatch)nativeBrush,
                                            out argb));

            color = Color.FromArgb(argb);

            return(status);
        }
예제 #36
0
파일: BrushPlus.cs 프로젝트: mitice/foo
        GpStatus GetBackgroundColor(out Color color)
        {
            int argb;

            GpStatus status = SetStatus(NativeMethods.GdipGetHatchBackgroundColor(
                                            (GpHatch)nativeBrush,
                                            out argb));

            color = Color.FromArgb(argb);

            return(status);
        }
예제 #37
0
 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);
    }
예제 #39
0
파일: Matrix.cs 프로젝트: misiek/foo
        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);
        }
예제 #40
0
        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);
        }
예제 #41
0
        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);
        }
예제 #42
0
파일: BrushPlus.cs 프로젝트: mitice/foo
        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);
        }
예제 #43
0
        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));
            }
        }
예제 #44
0
        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);
        }
예제 #45
0
        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);
        }
예제 #46
0
파일: BrushPlus.cs 프로젝트: mitice/foo
        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);
        }
예제 #47
0
파일: BrushPlus.cs 프로젝트: mitice/foo
        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);
        }
예제 #48
0
파일: BitmapPlus.cs 프로젝트: mitice/foo
        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);
        }
예제 #49
0
파일: CustomLineCap.cs 프로젝트: misiek/foo
        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);
        }
예제 #50
0
파일: BrushPlus.cs 프로젝트: mitice/foo
        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);
        }
예제 #51
0
 public GdiPlusException(GpStatus status) : base(status.ToString())
 {
     Status = status;
 }
예제 #52
0
 public GdiPlusException(GpStatus status) : base()
 {
     Status = status;
 }
예제 #53
0
 GpStatus SetStatus(GpStatus stat)
 {
     lastResult = stat;
     return stat;
 }
예제 #54
0
 internal ImageAttributesPlus(GpImageAttributes imageAttr, GpStatus status)
 {
     SetNativeImageAttr(imageAttr);
     lastResult = status;
 }
예제 #55
0
 public CustomLineCap(GpCustomLineCap nativeCap, GpStatus status)
 {
     lastResult = status;
     SetNativeCap(nativeCap);
 }
예제 #56
0
파일: Image.cs 프로젝트: Radytz/DroppedBoxx
 internal ImagePlus(GpImage nativeImage, GpStatus status)
 {
     SetNativeImage(nativeImage);
 }
예제 #57
0
파일: Image.cs 프로젝트: Radytz/DroppedBoxx
 protected void SetStatus(GpStatus gpStatus)
 {
     if (gpStatus != GpStatus.Ok) throw GdiPlusStatusException.Exception(gpStatus);
 }
예제 #58
0
파일: GraphicsPlus.cs 프로젝트: misiek/foo
 protected GraphicsPlus(GpGraphics Graphics)
 {
     lastResult = GpStatus.Ok;
     SetNativeGraphics(Graphics);
 }
예제 #59
0
파일: GraphicsPlus.cs 프로젝트: misiek/foo
 protected GpStatus SetStatus(GpStatus status)
 {
     GpStatusPlus sp = status;
     if (status != GpStatus.Ok)
         return (lastResult = status);
     else
         return status;
 }
예제 #60
0
 public CustomLineCap(GpCustomLineCap nativeCap, GpStatus status)
 {
     lastResult = status;
     SetNativeCap(nativeCap);
 }