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


C# CGBitmapContext.RotateCTM方法代码示例

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


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

示例1: DrawScreen

		protected void DrawScreen ()
		{

			// create our offscreen bitmap context
			// size
			CGSize bitmapSize = new CGSize (imageView.Frame.Size);
			using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero, (int)bitmapSize.Width, (int)bitmapSize.Height, 8, (int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (), CGImageAlphaInfo.PremultipliedFirst)) {

				// save the state of the context while we change the CTM
				context.SaveState ();

				// draw our circle
				context.SetFillColor (1, 0, 0, 1);
				context.TranslateCTM (currentLocation.X, currentLocation.Y);
				context.RotateCTM (currentRotation);
				context.ScaleCTM (currentScale, currentScale);
				context.FillRect (new CGRect (-10, -10, 20, 20));

				// restore our transformations
				context.RestoreState ();

				// draw our coordinates for reference
				DrawCoordinateSpace (context);

				// output the drawing to the view
				imageView.Image = UIImage.FromImage (context.ToImage ());
			}
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:28,代码来源:Controller.cs

示例2: SetOriginalImage

        public void SetOriginalImage(UIImage originalImage, CGRect cropFrame)
        {
            LoadIndicator.StartAnimating();
            InvokeOnMainThread(() =>
                {
                    CGImage imageRef = originalImage.CGImage;
                    UIImageOrientation imageOrientation = originalImage.Orientation;

                    if (imageRef == null)
                        return;

                    var bytesPerRow = 0;
                    var width = imageRef.Width;
                    var height = imageRef.Height;
                    var bitsPerComponent = imageRef.BitsPerComponent;
                    CGColorSpace colorSpace = CGColorSpace.CreateDeviceRGB();
                    CGBitmapFlags bitmapInfo = imageRef.BitmapInfo;

                    switch (imageOrientation)
                    {
                        case UIImageOrientation.RightMirrored:
                        case UIImageOrientation.LeftMirrored:
                        case UIImageOrientation.Right:
                        case UIImageOrientation.Left:
                            width = imageRef.Height;
                            height = imageRef.Width;
                            break;
                        default:
                            break;
                    }

                    CGSize imageSize = new CGSize(width, height);
                    CGBitmapContext context = new CGBitmapContext(null,
                                                  width,
                                                  height,
                                                  bitsPerComponent,
                                                  bytesPerRow,
                                                  colorSpace,
                                                  bitmapInfo);

                    colorSpace.Dispose();

                    if (context == null)
                    {
                        imageRef.Dispose();
                        return;
                    }

                    switch (imageOrientation)
                    {
                        case UIImageOrientation.RightMirrored:
                        case UIImageOrientation.Right:
                            context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                            context.RotateCTM(-((nfloat)Math.PI / 2));
                            context.TranslateCTM(-imageSize.Height / 2, -imageSize.Width / 2);
                            break;
                        case UIImageOrientation.LeftMirrored:
                        case UIImageOrientation.Left:
                            context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                            context.RotateCTM((nfloat)(Math.PI / 2));
                            context.TranslateCTM(-imageSize.Height / 2, -imageSize.Width / 2);
                            break;
                        case UIImageOrientation.Down:
                        case UIImageOrientation.DownMirrored:
                            context.TranslateCTM(imageSize.Width / 2, imageSize.Height / 2);
                            context.RotateCTM((nfloat)Math.PI);
                            context.TranslateCTM(-imageSize.Width / 2, -imageSize.Height / 2);
                            break;
                        default:
                            break;
                    }

                    context.InterpolationQuality = CGInterpolationQuality.High;
                    context.SetBlendMode(CGBlendMode.Copy);
                    context.DrawImage(new CGRect(0, 0, imageRef.Width, imageRef.Height), imageRef);

                    CGImage contextImage = context.ToImage();

                    context.Dispose();

                    if (contextImage != null)
                    {
                        _originalImage = UIImage.FromImage(contextImage, originalImage.CurrentScale, UIImageOrientation.Up);

                        contextImage.Dispose();
                    }

                    imageRef.Dispose();

                    BeginInvokeOnMainThread(() =>
                        {
                            CGSize convertedImageSize = new CGSize(_originalImage.Size.Width / _cropSizeRatio,
                                                            _originalImage.Size.Height / _cropSizeRatio);

                            ImageView.Alpha = 0;
                            ImageView.Image = _originalImage;

                            CGSize sampleImageSize = new CGSize(Math.Max(convertedImageSize.Width, ScrollView.Frame.Size.Width),
                                                         Math.Max(convertedImageSize.Height, ScrollView.Frame.Size.Height));

//.........这里部分代码省略.........
开发者ID:ProstoKorol,项目名称:HIPImageCropperXamarin,代码行数:101,代码来源:HIPImageCropperView.cs


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