當前位置: 首頁>>代碼示例>>C#>>正文


C# CoreGraphics.CGContext類代碼示例

本文整理匯總了C#中MonoMac.CoreGraphics.CGContext的典型用法代碼示例。如果您正苦於以下問題:C# CGContext類的具體用法?C# CGContext怎麽用?C# CGContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CGContext類屬於MonoMac.CoreGraphics命名空間,在下文中一共展示了CGContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderGlyphToContext

		public static void RenderGlyphToContext (CGContext context, PointF position, Glyph g, Fnt font, byte[] palette, int offset)
		{
			byte[] buf = new byte[g.Width * g.Height * 4];
			int i = 0;

			for (int y = g.Height - 1; y >= 0; y--) {
				for (int x = g.Width - 1; x >= 0; x--) {
					if (g.Bitmap[y,x] == 0)
						buf [i + 0] = 0;
					else if (g.Bitmap[y,x] == 1)
						buf [i + 0] = 255;
					else
						buf [i + 0] = 128;

					buf[i + 1] = palette[ (g.Bitmap[y,x]) * 3 + offset + 0];
					buf[i + 2] = palette[ (g.Bitmap[y,x]) * 3 + offset + 1];
					buf[i + 3] = palette[ (g.Bitmap[y,x]) * 3 + offset + 2];

					if (buf[i+1] == 252 && buf[i+2] == 0 && buf[i+3] == 252)
						buf[i + 0] = 0;

					i += 4;
				}
			}

			CGImage glyphImage = CreateImage (buf, (ushort)g.Width, (ushort)g.Height, 32, g.Width * 4);
			
			context.DrawImage (new RectangleF (position, new SizeF (g.Width, g.Height)), glyphImage);
		}
開發者ID:carriercomm,項目名稱:scsharp,代碼行數:29,代碼來源:GuiUtil.cs

示例2: Graphics

 public Graphics(CGContext context, bool flipped = true)
 {
     if (context == null)
         throw new ArgumentNullException ("context");
     isFlipped = flipped;
     InitializeContext(context);
 }
開發者ID:stnk3000,項目名稱:sysdrawing-coregraphics,代碼行數:7,代碼來源:Graphics.cs

示例3: CocoaGraphDrawer

 public CocoaGraphDrawer(CGContext g, int w, int h)
 {
     this.g = g;
     this.w = w;
     this.h = h;
     g.SetAllowsAntialiasing(true);
     g.InterpolationQuality = CGInterpolationQuality.High;
 }
開發者ID:ivynetca,項目名稱:lapsestudio,代碼行數:8,代碼來源:CocoaGraphDrawer.cs

示例4: DrawInContext

		public override void DrawInContext (CGContext context)
		{
			base.DrawInContext (context);
			
			context.AddEllipseInRect (Bounds);
			context.SetFillColor (ClockColor);
			context.FillPath ();
		}
開發者ID:Anomalous-Software,項目名稱:monomac,代碼行數:8,代碼來源:ClockLayer.cs

示例5: FillEllipsis

 public static void FillEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetFillColor(color);
     context.AddEllipseInRect(rect);
     context.FillPath();
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:8,代碼來源:CoreGraphicsHelper.cs

示例6: GraphicsContextWrapper

 public GraphicsContextWrapper(CGContext context, float boundsWidth, float boundsHeight, BasicRectangle dirtyRect)
 {
     Context = context;
     BoundsWidth = boundsWidth;
     BoundsHeight = boundsHeight;
     DirtyRect = dirtyRect;
     Density = GetDisplayScale();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:8,代碼來源:GraphicsContextWrapper.cs

示例7: FillRect

 public static void FillRect(CGContext context, RectangleF rect, CGColor color)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetFillColor(color);
     context.FillRect(rect);
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:9,代碼來源:CoreGraphicsHelper.cs

示例8: DrawEllipsis

 public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetStrokeColor(color);
     context.SetLineWidth(lineWidth);
     context.AddEllipseInRect(rect);
     context.StrokePath();
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:9,代碼來源:CoreGraphicsHelper.cs

示例9: DrawRect

 public static void DrawRect(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.AddRect(rect);
     context.Clip();
     context.SetLineWidth(lineWidth);
     context.SetStrokeColor(color);
     context.StrokeRect(rect);
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:10,代碼來源:CoreGraphicsHelper.cs

示例10: Draw

		internal static void Draw (CGContext ctx, GradientInfo gradient)
		{
			ctx.SaveState ();
			ctx.Clip ();
			using (var cg = new CGGradient (Util.DeviceRGBColorSpace, gradient.Colors.ToArray (), gradient.Stops.ToArray ())) {
				if (gradient.Linear)
					ctx.DrawLinearGradient (cg, gradient.Start, gradient.End, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
				else
					ctx.DrawRadialGradient (cg, gradient.Start, gradient.StartRadius, gradient.End, gradient.EndRadius, CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
			}
			ctx.RestoreState ();
		}
開發者ID:m13253,項目名稱:xwt,代碼行數:12,代碼來源:GradientBackendHandler.cs

示例11: CoreGraphicsRenderContext

        /// <summary>
        /// Initializes a new instance of the <see cref="CoreGraphicsRenderContext"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        public CoreGraphicsRenderContext(CGContext context)
        {
            this.gctx = context;

            // Set rendering quality
            this.gctx.SetAllowsFontSmoothing (true);
            this.gctx.SetAllowsFontSubpixelQuantization (true);
            this.gctx.SetAllowsAntialiasing (true);
            this.gctx.SetShouldSmoothFonts (true);
            this.gctx.SetShouldAntialias (true);
            this.gctx.InterpolationQuality = CGInterpolationQuality.High;
            this.gctx.SetTextDrawingMode (CGTextDrawingMode.Fill);
            this.gctx.TextMatrix = CGAffineTransform.MakeScale (1, 1);
        }
開發者ID:trinnguyen,項目名稱:oxyplot-xammac,代碼行數:18,代碼來源:CoreGraphicsRenderContext.cs

示例12: MeasureStringWidth

        public static float MeasureStringWidth(CGContext context, string text, string fontName, float fontSize)
        {
            if (string.IsNullOrEmpty(text))
                return 0;

            context.SaveState();
            PointF pos = context.TextPosition;
            context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
            context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
            //context.TranslateCTM(0, 20);
            context.ScaleCTM(1, -1);
            context.SetTextDrawingMode(CGTextDrawingMode.Invisible);
            context.ShowTextAtPoint(pos.X, pos.Y, text);
            PointF pos2 = context.TextPosition;
            context.RestoreState();
            
            return pos2.X - pos.X;
        }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:18,代碼來源:CoreGraphicsHelper.cs

示例13: DrawText

 public static void DrawText(CGContext context, string text, string fontName, float fontSize, float translateHeight, float x, float y)
 {
     context.SaveState();
     context.SelectFont(fontName, fontSize, CGTextEncoding.MacRoman);
     context.SetTextDrawingMode(CGTextDrawingMode.Fill);
     context.SetFillColor(new CGColor(1, 1));
     context.SetStrokeColor(new CGColor(1.0f, 1.0f));
     //context.AddRect(rectText);
     //context.Clip();
     context.TextMatrix = CGAffineTransform.MakeScale(1.0f, -1.0f);
     context.TranslateCTM(0, translateHeight);
     context.ScaleCTM(1, -1);
     context.ShowTextAtPoint(x, y, text);
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:15,代碼來源:CoreGraphicsHelper.cs

示例14: DrawTextInRect

 public static void DrawTextInRect(CGContext context, RectangleF rect, string text, string fontName, float fontSize, NSColor fontColor)
 {
     context.SaveState();
     NSString str = new NSString(text);
     var dict = new NSMutableDictionary();
     dict.Add(NSAttributedString.ForegroundColorAttributeName, fontColor);
     dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
     str.DrawString(rect, dict);
     context.RestoreState();
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:10,代碼來源:CoreGraphicsHelper.cs

示例15: MeasureText

 public static SizeF MeasureText(CGContext context, string text, string fontName, float fontSize)
 {
     NSString str = new NSString(text);
     var dict = new NSMutableDictionary();
     dict.Add(NSAttributedString.FontAttributeName, NSFont.FromFontName(fontName, fontSize));
     var size = str.StringSize(dict);
     return size;
 }
開發者ID:pascalfr,項目名稱:MPfm,代碼行數:8,代碼來源:CoreGraphicsHelper.cs


注:本文中的MonoMac.CoreGraphics.CGContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。