当前位置: 首页>>代码示例>>C#>>正文


C# CGContext.DrawImage方法代码示例

本文整理汇总了C#中CGContext.DrawImage方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.DrawImage方法的具体用法?C# CGContext.DrawImage怎么用?C# CGContext.DrawImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CGContext的用法示例。


在下文中一共展示了CGContext.DrawImage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

		public override void Draw (RectangleF bounds, CGContext context, UIView view)
		{
			UIColor.White.SetFill ();
			context.FillRect (bounds);
			
			//if (userImage == null)
			//	userImage = UIImageUtils.GetPreview (string.Format("Images/Profiles/{0}.jpg", _User.Id), new SizeF (40, 40));

			if (userImage != null)
				context.DrawImage(new RectangleF(0, 0, 40, 40), userImage.CGImage);
			
			UIColor.Black.SetColor ();
			view.DrawString(_User.Name, new RectangleF(50, 5, bounds.Width/2, 10 ), fromFont, UILineBreakMode.TailTruncation);
		}
开发者ID:21Off,项目名称:21Off,代码行数:14,代码来源:UserElement.cs

示例2: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		var imageRect = new RectangleF (8, 8, 64, 64);
		
		// Note: The images are actually drawn upside down because Quartz image drawing expects
		// the coordinate system to have the origin in the lower-left corner, but a UIView
		// puts the origin in the upper-left corner. For the sake of brevity (and because
		// it likely would go unnoticed for the image used) this is not addressed here.
		// For the demonstration of PDF drawing however, it is addressed, as it would definately
		// be noticed, and one method of addressing it is shown there.
	
		// Draw the image in the upper left corner (0,0) with size 64x64
		context.DrawImage (imageRect, image);
		
		// Tile the same image across the bottom of the view
		// CGContextDrawTiledImage() will fill the entire clipping area with the image, so to avoid
		// filling the entire view, we'll clip the view to the rect below. This rect extends
		// past the region of the view, but since the view's rectangle has already been applied as a clip
		// to our drawing area, it will be intersected with this rect to form the final clipping area
		context.ClipToRect(new RectangleF (0, 80, Bounds.Width, Bounds.Height));
		
		// The origin of the image rect works similarly to the phase parameter for SetLineDash and
		// SetPatternPhase and specifies where in the coordinate system the "first" image is drawn.
		// The size (previously set to 64x64) specifies the size the image is scaled to before being tiled.
		imageRect.X = 32;
		imageRect.Y = 112;
		context.DrawTiledImage (imageRect, image);
		
		// Highlight the "first" image from the DrawTiledImage call.
		context.SetRGBFillColor (1, 0, 0, 0.5f);
		context.FillRect (imageRect);
		
		// And stroke the clipped area
		context.SetLineWidth (3);
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRect (context.GetClipBoundingBox ());
	}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:37,代码来源:ImageDrawing.cs

示例3: EraseStart

        public void EraseStart()
        {
            if (drawingBoard == null)
                return;

            UIGraphics.BeginImageContext (drawingBoard.Size);

            // erase lines
            ctx = UIGraphics.GetCurrentContext ();

            // Convert co-ordinate system to Cocoa's (origin in UL, not LL)
            ctx.TranslateCTM (0, drawingBoard.Size.Height);
            ctx.ConcatCTM (CGAffineTransform.MakeScale (1, -1));

            ctx.DrawImage (new RectangleF (0, 0, drawingBoard.Size.Width, drawingBoard.Size.Height),
                        drawingBoard.CGImage);
        }
开发者ID:sichy,项目名称:DrawingHelperSample,代码行数:17,代码来源:DrawingHelper.cs

示例4: DrawSelected

        private void DrawSelected(CGContext g)
        {
            if (selectionRect.IsEmpty)
                return;

            CGImage grabberImage;
            var targetRect = new CGRect(CGPoint.Empty, grabberSize);

            grabberImage = NSImage.ImageNamed("Grabber").AsCGImage(ref targetRect, NSGraphicsContext.CurrentContext, new NSDictionary());

            g.SetStrokeColor(new CGColor(0.5f, 0.5f));
            g.StrokeRectWithWidth(selectionRect, 0.5f);

            for (int i = 0; i < grabberRects.Length; i++)
            {
                g.DrawImage(grabberRects[i], grabberImage);
            }
        }
开发者ID:jlyonsmith,项目名称:Pinboard,代码行数:18,代码来源:PinboardView.cs

示例5: RenderPages

        public void RenderPages(CGContext context,CGRect rect)
        {
            if (numberOfPages < 2 && HidesForSinglePage)
            {
                return;
            }

            nfloat left = LeftOffset;

            nfloat xOffset = left;
            nfloat yOffset = 0.0f;
            UIColor fillColor = null;
            UIImage image = null;
            CGImage maskingImage = null;
            CGSize maskSize = new CGSize();

            for (uint i = 0; i < numberOfPages; i++)
            {
                NSNumber indexNumber = new NSNumber(i);

                if (i == displayedPage)
                {
                    fillColor = CurrentPageIndicatorTintColor !=null ? CurrentPageIndicatorTintColor : UIColor.White;
                    image = GetImageFromDictionary(currentPageImages,indexNumber);
                    if (null == image)
                    {
                        image = currentPageIndicatorImage;
                    }
                }
                else
                {
                    fillColor = PageIndicatorTintColor !=null ? PageIndicatorTintColor : UIColor.White.ColorWithAlpha (0.3f);
                    image = GetImageFromDictionary(pageImages,indexNumber);
                    if (null == image)
                    {
                        image = pageIndicatorImage;
                    }
                }

                // If no finished images have been set, try a masking image
                if (null == image)
                {
                    maskingImage = GetImageFromDictionary(cgImageMasks,indexNumber);
                    UIImage originalImage = GetImageFromDictionary(pageImageMasks,indexNumber);
                    if (originalImage!=null)
                        maskSize = originalImage.Size;

                    // If no per page mask is set, try for a global page mask!
                    if (null == maskingImage)
                    {
                        maskingImage = pageImageMask;
                        if (pageIndicatorMaskImage!=null)
                            maskSize = pageIndicatorMaskImage.Size;
                    }
                }

                fillColor.SetFill();

                if (image!=null)
                {
                    yOffset = TopOffsetForHeight(image.Size.Height,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - image.Size.Width) / 2.0f);
                    image.Draw(new CGPoint(centeredXOffset, yOffset));
                }
                else if (maskingImage!=null)
                {
                    yOffset = TopOffsetForHeight(maskSize.Height,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - maskSize.Width) / 2.0f);
                    CGRect imageRect = new CGRect(centeredXOffset,yOffset,maskSize.Width,maskSize.Height);
                    context.DrawImage(imageRect,maskingImage);
                }
                else
                {
                    yOffset = TopOffsetForHeight(indicatorDiameter,rect);
                    var centeredXOffset = xOffset + Floor((measuredIndicatorWidth - indicatorDiameter) / 2.0f);
                    context.FillEllipseInRect(new CGRect(centeredXOffset,yOffset,indicatorDiameter,indicatorDiameter));
                }

                maskingImage = null;
                xOffset += measuredIndicatorWidth + indicatorMargin;
            }
        }
开发者ID:skela,项目名称:SMPageControl,代码行数:82,代码来源:SMPageControl.cs

示例6: DrawMapRect

		public override void DrawMapRect (MKMapRect mapRect, nfloat zoomScale, CGContext context)
		{
			if (cachedImages?.Count > index)
				context.DrawImage (cachedRect, cachedImages [Convert.ToInt32 (index)]);
		}
开发者ID:colbylwilliams,项目名称:XWeather,代码行数:5,代码来源:RadarOverlayRenderer.cs

示例7: DrawTexture

        // test draw pattern
        protected void DrawTexture(CGContext context)
        {
            var destRect = new CGRect (0,0,textureImage.Width,textureImage.Height);
            context.DrawImage(destRect, textureImage.NativeCGImage);

            if (wrapMode == WrapMode.TileFlipX)
            {
                context.ConcatCTM(CGAffineTransform.MakeScale(-1,1));
                context.DrawImage(destRect, textureImage.NativeCGImage);
            }

            if (wrapMode == WrapMode.TileFlipY)
            {
                var transformY = new CGAffineTransform(1, 0, 0, -1,
                                                       textureImage.Width,
                                                       textureImage.Height);
                context.ConcatCTM(transformY);
                context.DrawImage(destRect, textureImage.NativeCGImage);
            }

            if (wrapMode == WrapMode.TileFlipXY)
            {
                // draw the original
                var transform = new CGAffineTransform(1, 0, 0, 1,
                                                       0, textureImage.Height);
                context.ConcatCTM(transform);
                context.DrawImage(destRect, textureImage.NativeCGImage);

                // reset the transform
                context.ConcatCTM (context.GetCTM().Invert());

                // draw next to original one that is flipped by x axis
                transform = new CGAffineTransform(-1, 0, 0, 1,
                                                  textureImage.Width * 2, textureImage.Height);
                context.ConcatCTM(transform);
                context.DrawImage(destRect, textureImage.NativeCGImage);

                // reset the transform
                context.ConcatCTM (context.GetCTM().Invert());

                // draw one that is flipped by Y axis under the oricinal
                transform = new CGAffineTransform(1, 0, 0, -1,
                                                  0, textureImage.Height);
                context.ConcatCTM(transform);
                context.DrawImage(destRect, textureImage.NativeCGImage);

                // draw the last one of the quadrant which is flipped by both the y and x axis
                context.ConcatCTM (context.GetCTM().Invert());
                transform = new CGAffineTransform(-1, 0, 0, -1,
                                                  textureImage.Width * 2, textureImage.Height);
                context.ConcatCTM(transform);
                context.DrawImage(destRect, textureImage.NativeCGImage);
            }
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:55,代码来源:TextureBrush.cs

示例8: DrawImage

 private void DrawImage(UIImage image, CGContext context, RectangleF bounds)
 {
     // required hack to get the images to draw rightside up
     context.SaveState();
     context.TranslateCTM(0, bounds.Height);
     context.ScaleCTM(1.0f, -1.0f);
     bounds.Y = -bounds.Y;
     context.DrawImage(bounds, image.CGImage);
     context.RestoreState();
 }
开发者ID:redbitdev,项目名称:socialcloud-mobile,代码行数:10,代码来源:MainMenuTableViewCell.cs


注:本文中的CGContext.DrawImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。