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


C# CGBitmapContext.SetFillColor方法代码示例

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


在下文中一共展示了CGBitmapContext.SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: makeProgressImage

		public static UIImage makeProgressImage(int width, int height, float progress, CGColor baseColor, CGColor topColor)
		{
		   //Create a CGBitmapContext object
		   CGBitmapContext ctx = new CGBitmapContext(IntPtr.Zero, width, height, 8, 4 * width, CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedFirst);
		
		   //Draw a rectangle with the base color
		   ctx.SetFillColor(baseColor);
		   ctx.FillRect(new RectangleF(0,0, width, height));
		
		   //Calculate the width of the 2nd rectangle based on the progress
		   float percentWidth = width * progress;
		
		   //Draw the second rectangle with the top color
		   ctx.SetFillColor(topColor);
		   ctx.FillRect(new RectangleF(0, 0, percentWidth, height));
		
		   //return a UIImage object
		   return UIImage.FromImage(ctx.ToImage());
		}		
开发者ID:21Off,项目名称:21Off,代码行数:19,代码来源:UIImageUtils.cs

示例3: MakeCalendarBadge

		public static UIImage MakeCalendarBadge (UIImage template, string smallText, string bigText)
		{
			using (var cs = CGColorSpace.CreateDeviceRGB ()){
				using (var context = new CGBitmapContext (IntPtr.Zero, 59, 58, 8, 59*4, cs, CGImageAlphaInfo.PremultipliedLast)){
					//context.ScaleCTM (0.5f, -1);
					context.TranslateCTM (0, 0);
					context.DrawImage (new RectangleF (0, 0, 59, 58), template.CGImage);
					context.SetFillColor (0, 0, 0, 1);
					
					// The _small_ string
					context.SelectFont ("Helvetica-Bold", 14f, CGTextEncoding.MacRoman);
					
					// Pretty lame way of measuring strings, as documented:
					var start = context.TextPosition.X;					
					context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
					context.ShowText (smallText);
					var width = context.TextPosition.X - start;
					
					context.SetTextDrawingMode (CGTextDrawingMode.Fill);
					context.ShowTextAtPoint ((59-width)/2, 10, smallText); // was 46
					
					// The BIG string
					context.SelectFont ("Helvetica-Bold", 32, CGTextEncoding.MacRoman);					
					start = context.TextPosition.X;
					context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
					context.ShowText (bigText);
					width = context.TextPosition.X - start;
					
					context.SetFillColor (0, 0, 0, 1);
					context.SetTextDrawingMode (CGTextDrawingMode.Fill);
					context.ShowTextAtPoint ((59-width)/2, 25, bigText);	// was 9
					
					context.StrokePath ();
				
					return UIImage.FromImage (context.ToImage ());
				}
			}
		}
开发者ID:slodge,项目名称:mobile-samples,代码行数:38,代码来源:CustomBadgeImage.cs

示例4: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			// set the background color of the view to white
			View.BackgroundColor = UIColor.White;
			
			// instantiate a new image view that takes up the whole screen and add it to 
			// the view hierarchy
			RectangleF imageViewFrame = new RectangleF (0, -NavigationController.NavigationBar.Frame.Height, View.Frame.Width, View.Frame.Height);
			imageView = new UIImageView (imageViewFrame);
			View.AddSubview (imageView);
			
			// create our offscreen bitmap context
			// size
			SizeF bitmapSize = new SizeF (View.Frame.Size);
			using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero, (int)bitmapSize.Width, (int)bitmapSize.Height, 8, (int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (), CGImageAlphaInfo.PremultipliedFirst)) {

				//==== create a grayscale shadow
				// 1) save graphics state
				context.SaveState ();
				// 2) set shadow context for offset and blur
				context.SetShadow (new SizeF (10, -10), 15);
				// 3) perform your drawing operation
				context.SetFillColor (.3f, .3f, .9f, 1);
				context.FillRect (new RectangleF (100, 600, 300, 250));
				// 4) restore the graphics state
				context.RestoreState ();
				
				//==== create a color shadow
				// 1) save graphics state
				context.SaveState ();
				// 2) set shadow context for offset and blur
				context.SetShadowWithColor(new SizeF (15, -15), 10, UIColor.Blue.CGColor);
				// 3) perform your drawing operation
				context.SelectFont ("Helvetica-Bold", 40, CGTextEncoding.MacRoman);
				context.SetTextDrawingMode (CGTextDrawingMode.Fill);
				string text = "Shadows are fun and easy!";
				context.ShowTextAtPoint (150, 200, text, text.Length);
				// 4) restore the graphics state
				context.RestoreState ();
				
				
				// output the drawing to the view
				imageView.Image = UIImage.FromImage (context.ToImage ());
			}
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:47,代码来源:Controller.cs

示例5: MakeCalendarBadgeSmall

		public static UIImage MakeCalendarBadgeSmall (UIImage template, string smallText, string bigText)
		{
			int imageWidth=30, imageHeight=29;
			int smallTextY=5, bigTextY=12;
			float smallTextSize=7f, bigTextSize=16f;

			using (var cs = CGColorSpace.CreateDeviceRGB ()) {
				using (var context = new CGBitmapContext (IntPtr.Zero
								, imageWidth, imageHeight, 8, imageWidth*4, cs
								, CGImageAlphaInfo.PremultipliedLast)) {
					
					//context.ScaleCTM (0.5f, -1);
					context.TranslateCTM (0, 0);
					context.DrawImage (new RectangleF (0, 0, imageWidth, imageHeight), template.CGImage);
					context.SetFillColor (0, 0, 0, 1);
					
					// The _small_ string
					context.SelectFont ("Helvetica-Bold", smallTextSize, CGTextEncoding.MacRoman);
					
					// Pretty lame way of measuring strings, as documented:
					var start = context.TextPosition.X;					
					context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
					context.ShowText (smallText);
					var width = context.TextPosition.X - start;
					
					context.SetTextDrawingMode (CGTextDrawingMode.Fill);
					context.ShowTextAtPoint ((imageWidth-width)/2, smallTextY, smallText);
					
					// The BIG string
					context.SelectFont ("Helvetica-Bold", bigTextSize, CGTextEncoding.MacRoman);					
					start = context.TextPosition.X;
					context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
					context.ShowText (bigText);
					width = context.TextPosition.X - start;
					
					context.SetFillColor (0, 0, 0, 1);
					context.SetTextDrawingMode (CGTextDrawingMode.Fill);
					context.ShowTextAtPoint ((imageWidth-width)/2, bigTextY, bigText);
					
					context.StrokePath ();
				
					return UIImage.FromImage (context.ToImage ());
				}
			}
		}
开发者ID:slodge,项目名称:mobile-samples,代码行数:45,代码来源:CustomBadgeImage.cs

示例6: AdjustImage

		public static UIImage AdjustImage (RectangleF rect, UIImage template, CGBlendMode mode, 
		                                   float red, float green, float blue, float alpha)
		{
			using (var cs = CGColorSpace.CreateDeviceRGB ()) {
				using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, 
				                                          (int)rect.Height * 4, cs, CGImageAlphaInfo.PremultipliedLast)) {
					
					context.TranslateCTM (0.0f, 0f);
					//context.ScaleCTM(1.0f,-1.0f);
					context.DrawImage (rect, template.CGImage);
					context.SetBlendMode (mode);
					context.ClipToMask (rect, template.CGImage);
					context.SetFillColor (red, green, blue, alpha);
					context.FillRect (rect);
					
					return UIImage.FromImage (context.ToImage ());
				}
			}
		}
开发者ID:21Off,项目名称:21Off,代码行数:19,代码来源:GraphicsII.cs

示例7: Render

        /// <summary>
        /// Render the current complete scene.
        /// </summary>
        void Render()
        {
            try
            {
                //if (Monitor.TryEnter(_cacheRenderer, 10))
                lock(_cacheRenderer)
                {
                    try
                    {
                        // use object
                        var rect = _rect;

                        // create the view.
                        var size = (float)System.Math.Max(_rect.Width, _rect.Height);
                        var view = _cacheRenderer.Create((int)(size * _extra), (int)(size * _extra),
                            this.Map, (float)this.Map.Projection.ToZoomFactor(this.MapZoom),
                            this.MapCenter, _invertX, _invertY, this.MapTilt);
                        if (rect.Width == 0)
                        { // only render if a proper size is known.
                            return;
                        }

                        // calculate width/height.
                        var imageWidth = (int)(size * _extra * _scaleFactor);
                        var imageHeight = (int)(size * _extra * _scaleFactor);

                        // create a new bitmap context.
                        var space = CGColorSpace.CreateDeviceRGB();
                        int bytesPerPixel = 4;
                        int bytesPerRow = bytesPerPixel * imageWidth;
                        int bitsPerComponent = 8;

                        // get old image if available.
                        var image = new CGBitmapContext(null, imageWidth, imageHeight,
                            bitsPerComponent, bytesPerRow,
                            space, // kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast
                            CGBitmapFlags.PremultipliedFirst | CGBitmapFlags.ByteOrder32Big);

                        long before = DateTime.Now.Ticks;

                        // build the layers list.
                        var layers = new List<Layer>();
                        for (int layerIdx = 0; layerIdx < this.Map.LayerCount; layerIdx++)
                        {
                            layers.Add(this.Map[layerIdx]);
                        }

                        // add the internal layer.
                        try
                        {
                            image.SetFillColor(1, 1, 1, 1);
                            image.FillRect(new CGRect(
                                0, 0, imageWidth, imageHeight));

                            // notify the map that the view has changed.
                            var normalView = _cacheRenderer.Create((float)_rect.Width, (float)_rect.Height,
                                this.Map, (float)this.Map.Projection.ToZoomFactor(this.MapZoom),
                                this.MapCenter, _invertX, _invertY, this.MapTilt);
                            this.Map.ViewChanged((float)this.Map.Projection.ToZoomFactor(this.MapZoom), this.MapCenter,
                                normalView, view);
                            long afterViewChanged = DateTime.Now.Ticks;
                            OsmSharp.Logging.Log.TraceEvent("OsmSharp.iOS.UI.MapView", TraceEventType.Information,
                                "View change took: {0}ms @ zoom level {1}",
                                (new TimeSpan(afterViewChanged - before).TotalMilliseconds), this.MapZoom);

                            float zoomFactor = this.MapZoom;
                            float sceneZoomFactor = (float)this.Map.Projection.ToZoomFactor(this.MapZoom);

                            // does the rendering.
                            bool complete = _cacheRenderer.Render(new CGContextWrapper(image,
                                new CGRect(0, 0, (int)(size * _extra), (int)(size * _extra))),
                                _map.Projection, layers, view, sceneZoomFactor);

                            long afterRendering = DateTime.Now.Ticks;

                            if (complete)
                            { // there was no cancellation, the rendering completely finished.
                                lock (_bufferSynchronisation)
                                {
                                    if (_onScreenBuffer != null &&
                                        _onScreenBuffer.NativeImage != null)
                                    { // on screen buffer.
                                        _onScreenBuffer.NativeImage.Dispose();
                                    }

                                    // add the newly rendered image again.
                                    _onScreenBuffer = new ImageTilted2D(view.Rectangle,
                                        new NativeImage(image.ToImage()), float.MinValue, float.MaxValue);

                                    // store the previous view.
                                    _previouslyRenderedView = view;
                                }

                                // make sure this view knows that there is a new rendering.
                                this.InvokeOnMainThread(SetNeedsDisplay);
                            }

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

示例8: applyMosaic

        static CGImage applyMosaic(int tileSize, List<Color> colorPalette, UIImage resizedImg, Bitmap bitmap)
        {
            // - Parameters
            int width = tileSize; // tile width
            int height = tileSize; // tile height
            int outWidth = (int)(resizedImg.Size.Width - (resizedImg.Size.Width % width)); // Round image size
            int outHeight = (int)(resizedImg.Size.Height - (resizedImg.Size.Height % height));

            // -- Initialize buffer
            CGBitmapContext context = new CGBitmapContext (System.IntPtr.Zero, // data
                                                           (int)outWidth, // width
                                                           (int)outHeight, // height
                                                           8, // bitsPerComponent
                                                           outWidth * 4, // bytesPerRow based on pixel width
                                                           CGColorSpace.CreateDeviceRGB (), // colorSpace
                                                           CGImageAlphaInfo.NoneSkipFirst);

            // bitmapInfo
            for (int yb = 0; yb < outHeight / height; yb++) {
                for (int xb = 0; xb < outWidth / width; xb++) {

                    // -- Do the average colors on the source image for the
                    // corresponding mosaic square
                    int r_avg = 0;
                    int g_avg = 0;
                    int b_avg = 0;
                    for (int y = yb * height; y < (yb * height) + height; y++) {
                        for (int x = xb * width; x < (xb * width) + width; x++) {
                            Color c = bitmap.GetPixel (x, y);
                            // Retrieve color values of the source image
                            r_avg += c.R;
                            g_avg += c.G;
                            b_avg += c.B;
                        }
                    }

                    // Make average of R,G and B on filter size
                    r_avg = r_avg / (width * height);
                    g_avg = g_avg / (width * height);
                    b_avg = b_avg / (width * height);

                    // Find the nearest color in the palette
                    Color mosaicColor = new Color ();
                    double minDistance = int.MaxValue;

                    foreach (Color c in colorPalette) {
                        double distance = Math.Abs (Math.Pow (r_avg - c.R, 2) + Math.Pow (g_avg - c.G, 2) + Math.Pow (b_avg - c.B, 2));
                        if (distance < minDistance) {
                            mosaicColor = c;
                            minDistance = distance;
                        }
                    }

                    // Apply mosaic
                    for (int y = 0; y < height; y++) {
                        for (int x = 0; x < width; x++) {
                            context.SetFillColor (new CGColor (mosaicColor.R / 255f, mosaicColor.G / 255f, mosaicColor.B / 255f));
                            context.FillRect (new RectangleF (xb * width, yb * height, width, height));
                        }
                    }
                }
            }

            //-- image from buffer
            CGImage flippedImage = context.ToImage ();
            context.Dispose ();

            return flippedImage;
        }
开发者ID:valryon,项目名称:pixpuzzle,代码行数:69,代码来源:ImageFilters.cs

示例9: UpdateRouteView

        public void UpdateRouteView()
        {
            using(var context = new CGBitmapContext(null, (int)_RouteView.Frame.Width, (int)_RouteView.Frame.Height, 8,
                (int)(4 * _RouteView.Frame.Width), CGColorSpace.CreateDeviceRGB(), CGImageAlphaInfo.PremultipliedLast))
            {
                context.SetStrokeColor(LineColor.CGColor);
                context.SetFillColor(0.0f, 0.0f, 1.0f, 1.0f);
                context.SetLineWidth(3.0f);

                for (int i = 0; i < _Routes.Count(); i++)
                {
                    var route = _Routes[i];
                    var point = _MapView.ConvertCoordinate(route.Coordinate, _RouteView);

                    if(i == 0)
                        context.MoveTo(point.X, _RouteView.Frame.Height - point.Y);
                    else
                        context.AddLineToPoint(point.X, _RouteView.Frame.Height - point.Y);
                }

                context.StrokePath();

                var cgImage = context.ToImage();
                var image = UIImage.FromImage(cgImage);

                _RouteView.Image = image;
            }
        }
开发者ID:anujb,项目名称:MapWithRoutes,代码行数:28,代码来源:MapView.cs

示例10: CreateTextBitmapContext

		CGBitmapContext CreateTextBitmapContext (string str, out byte[] bitmapData)
		{
			NSString text = new NSString (str);
			UIFont font = UIFont.FromName ("HelveticaNeue-Light", 128);
			CGSize size = text.StringSize (font);
			int width = (int)size.Width;
			int height = (int)size.Height;
			bitmapData = new byte[256*256*4];
			CGBitmapContext bitmapContext = new CGBitmapContext (bitmapData, 256, 256, 8, 256*4, CGColorSpace.CreateDeviceRGB (), CGImageAlphaInfo.PremultipliedLast);
			//Console.WriteLine ("bitmap context size: {0} x {1}", bitmapContext.Width, bitmapContext.Height);
			UIGraphics.PushContext (bitmapContext);
			float grayLevel = str == " " ? .8f : 1;
			bitmapContext.SetFillColor(grayLevel, grayLevel, grayLevel, 1);
			bitmapContext.FillRect (new RectangleF (0, 0, 256.0f, 256.0f));
			bitmapContext.SetFillColor(0, 0, 0, 1);

			text.DrawString (new CoreGraphics.CGPoint((256.0f - width) / 2.0f, (256.0f - height) / 2.0f + font.Descender), font);
			UIGraphics.PopContext ();

			return bitmapContext;
		}
开发者ID:ARMoir,项目名称:mobile-samples,代码行数:21,代码来源:EAGLView.cs

示例11: Texture2D

        public Texture2D(string text, SizeF dim, UITextAlignment alignment, string fontName, float fontSize)
        {
            UIFont font = UIFont.FromName(fontName, fontSize);

            int width = (int)dim.Width;
            if (width != 1 && (width & (width - 1)) != 0) {
                int i = 1;
                while (i < width) {
                    i *= 2;
                }

                width = i;
            }

            int height = (int)dim.Height;
            if (height != 1 && (height & (height - 1)) != 0) {
                int i = 1;
                while (i < height) {
                    i *= 2;
                }
                height = i;
            }

            CGColorSpace colorSpace = CGColorSpace.CreateDeviceGray();

            byte[] data = new byte[width * height];

            unsafe {
                fixed (byte* dataPb = data) {
                    using (CGContext context = new CGBitmapContext((IntPtr)dataPb, width, height, 8, width, colorSpace, CGImageAlphaInfo.None)) {
                        context.SetFillColor(1f, 1f);
                        context.TranslateCTM(0f, height);
                        context.ScaleCTM(1f, -1f);
                        UIGraphics.PushContext(context);
                        text.DrawInRect(new RectangleF(0, 0, dim.Width, dim.Height), font, UILineBreakMode.WordWrap, alignment);
                        UIGraphics.PopContext();
                    }
                }
            }
            colorSpace.Dispose();

            InitWithData(data, Texture2DPixelFormat.A8, width, height, dim);
        }
开发者ID:ishinao,项目名称:CocosNet,代码行数:43,代码来源:Texture2D.cs

示例12: CreateCalendarImage

            static UIImage CreateCalendarImage(DateTime date)
            {
                string month = date.ToString ("MMMM");
                string day = date.Day.ToString ();

                using (var cs = CGColorSpace.CreateDeviceRGB ()) {
                    using (var context = new CGBitmapContext (IntPtr.Zero, 57, 57, 8, 57 * 4, cs, CGImageAlphaInfo.PremultipliedLast)) {
                        //context.ScaleCTM (0.5f, -1);
                        context.TranslateCTM (0, 0);
                        context.DrawImage (new RectangleF (0, 0, 57, 57), Calendar.CGImage);
                        context.SetFillColor (1.0f, 1.0f, 1.0f, 1.0f);

                        context.SelectFont ("Helvetica", 10f, CGTextEncoding.MacRoman);

                        // Pretty lame way of measuring strings, as documented:
                        var start = context.TextPosition.X;
                        context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
                        context.ShowText (month);
                        var width = context.TextPosition.X - start;

                        context.SetTextDrawingMode (CGTextDrawingMode.Fill);
                        context.ShowTextAtPoint ((57 - width) / 2, 46, month);

                        // The big string
                        context.SelectFont ("Helvetica-Bold", 32, CGTextEncoding.MacRoman);
                        start = context.TextPosition.X;
                        context.SetTextDrawingMode (CGTextDrawingMode.Invisible);
                        context.ShowText (day);
                        width = context.TextPosition.X - start;

                        context.SetFillColor (0.0f, 0.0f, 0.0f, 1.0f);
                        context.SetTextDrawingMode (CGTextDrawingMode.Fill);
                        context.ShowTextAtPoint ((57 - width) / 2, 9, day);

                        context.StrokePath ();

                        return UIImage.FromImage (context.ToImage ());
                    }
                }
            }
开发者ID:Clancey,项目名称:FlightLog,代码行数:40,代码来源:FlightElement.cs

示例13: BuildCoverFlow

		public static UIImage BuildCoverFlow(UIImage image, float reflectionFraction)
		{
			int reflectionHeight = (int) (image.Size.Height * reflectionFraction);

			// gradient is always black and white and the mask must be in the gray colorspace
			var colorSpace = CGColorSpace.CreateDeviceGray();

			// Create the bitmap context
			var gradientBitmapContext = new CGBitmapContext (IntPtr.Zero, 1, reflectionHeight, 8, 0, colorSpace, CGImageAlphaInfo.None);

			// define the start and end grayscale values (with the alpha, even though
			// our bitmap context doesn't support alpha the gradien requires it)
			float [] colors = { 0, 1, 1, 1 };

			// Create the CGGradient and then release the gray color space
			var grayScaleGradient = new CGGradient (colorSpace, colors, null);
			colorSpace.Dispose();

			// create the start and end points for the gradient vector (straight down)
			var gradientStartPoint = new PointF (0, reflectionHeight);
			var gradientEndPoint = PointF.Empty;

			// draw the gradient into the gray bitmap context
			gradientBitmapContext.DrawLinearGradient (grayScaleGradient, gradientStartPoint, gradientEndPoint, CGGradientDrawingOptions.DrawsAfterEndLocation);
			grayScaleGradient.Dispose();

			// Add a black fill with 50% opactiy
			gradientBitmapContext.SetFillColor(0, 0.5f);
			gradientBitmapContext.FillRect (new RectangleF (0, 0, 1, reflectionHeight));

            // conver the context into a CGImage and release the context
			var gradientImageMask = gradientBitmapContext.ToImage();
			gradientBitmapContext.Dispose();

			// create an image by masking the bitmap of the mainView content with the gradient view
			// then release the pre-masked content bitmap and the gradient bitmap
			var cgImage = image.CGImage;
			var reflectionImage = cgImage.WithMask(gradientImageMask);
			cgImage.Dispose();
			gradientImageMask.Dispose();

			var size = new SizeF(image.Size.Width, image.Size.Height + reflectionHeight);
			
			UIGraphics.BeginImageContext(size);
			image.Draw(PointF.Empty);
			var context = UIGraphics.GetCurrentContext();
			context.DrawImage(new RectangleF(0, image.Size.Height, image.Size.Width, reflectionHeight), reflectionImage);

			var result = UIGraphics.GetImageFromCurrentImageContext();
			UIGraphics.EndImageContext();
			reflectionImage.Dispose();

			return result;
		}
开发者ID:modulexcite,项目名称:artapp,代码行数:54,代码来源:ImageFactory.cs

示例14: GetThumbImage

        /// <summary>
        /// Returns thumb image object for page 
        /// </summary>
        /// <param name="thumbContentSize">Thumb content size</param>
        /// <param name="pageNumber">Page number for what will created image object</param>
        /// <returns>Page image object</returns>
        private static UIImage GetThumbImage(float thumbContentSize, int pageNumber)
        {
            if ((pageNumber <= 0) || (pageNumber > PDFDocument.PageCount)) {
                return null;
            }

            // Calc page view size
            var pageSize = PageContentView.GetPageViewSize(pageNumber);
            if (pageSize.Width % 2 > 0) {
                pageSize.Width--;
            }
            if (pageSize.Height % 2 > 0) {
                pageSize.Height--;
            }

            // Calc target size
            var targetSize = new Size((int)pageSize.Width, (int)pageSize.Height);

            // Draw page on CGImage
            CGImage pageImage;
            using (CGColorSpace rgb = CGColorSpace.CreateDeviceRGB()) {
                using (var context = new CGBitmapContext(null, targetSize.Width, targetSize.Height, 8, 0, rgb, CGBitmapFlags.ByteOrder32Little | CGBitmapFlags.NoneSkipFirst)) {
                    using (var pdfPage = PDFDocument.GetPage(pageNumber)) {
                        // Draw page on custom CGBitmap context
                        var thumbRect = new RectangleF(0.0f, 0.0f, targetSize.Width, targetSize.Height);
                        context.SetFillColor(1.0f, 1.0f, 1.0f, 1.0f);
                        context.FillRect(thumbRect);
                        context.ConcatCTM(pdfPage.GetDrawingTransform(CGPDFBox.Crop, thumbRect, 0, true));
                        context.SetRenderingIntent(CGColorRenderingIntent.Default);
                        context.InterpolationQuality = CGInterpolationQuality.Default;
                        context.DrawPDFPage(pdfPage);
                        // Create CGImage from custom CGBitmap context
                        pageImage = context.ToImage();
                    }
                }
            }
            return UIImage.FromImage(pageImage);
        }
开发者ID:kenLa,项目名称:mTouch-PDFReader,代码行数:44,代码来源:ThumbView.cs

示例15: MakeEmpty

		public static UIImage MakeEmpty (Size size)
		{
			using (var cs = CGColorSpace.CreateDeviceRGB ()) {
				using (var bit = new CGBitmapContext (IntPtr.Zero, size.Width, size.Height, 8, 0, cs, CGImageAlphaInfo.PremultipliedFirst)) {
					bit.SetStrokeColor (0, 0, 0, 0);
					bit.SetFillColor (1, 1, 1, 1);
					bit.FillRect (new RectangleF (0, 0, size.Width, size.Height));
					
					return UIImage.FromImage (bit.ToImage ());
				}
			}
		}		
开发者ID:21Off,项目名称:21Off,代码行数:12,代码来源:UIImageUtils.cs


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