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


C# Image.Arrange方法代码示例

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


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

示例1: GetPage

		public override DocumentPage GetPage(int pageNumber)
		{
			var bitmap = this.exportImages[pageNumber];
			var imageSize = new Size(bitmap.Width, bitmap.Height);
			var image = new Image { Source = bitmap };
			image.Measure(imageSize);
			image.Arrange(new Rect(imageSize));
			image.UpdateLayout();
			return new DocumentPage(image);
		}
开发者ID:JoelWeber,项目名称:xaml-sdk,代码行数:10,代码来源:GanttPaginator.cs

示例2: drawArrow

 public void drawArrow(Point x, Point y, Pen pen, Color penColor)
 {
     DrawingGroup drawing = new DrawingGroup();
     drawing.Children.Add(new ImageDrawing(bmp, new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight)));
     drawing.Children.Add(new GeometryDrawing(pen.Brush, pen, Drawing.makeArrowGeometry(x, y, pen.Thickness)));
     drawing.ClipGeometry = new RectangleGeometry(new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
     drawing.Freeze();
     var image = new Image { Source = new DrawingImage(drawing) };
     var bitmap = new RenderTargetBitmap(bmp.PixelWidth, bmp.PixelHeight, 96, 96, PixelFormats.Pbgra32);
     image.Arrange(new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
     bitmap.Render(image);
     bmp = BitmapFactory.ConvertToPbgra32Format(bitmap);
 }
开发者ID:riskawarrior,项目名称:tacticplanner,代码行数:13,代码来源:Drawing.cs

示例3: ParticleSystem

        public ParticleSystem(int maxCount, System.Windows.Media.Color color, Uri source)
        {
            this.maxParticleCount = maxCount;

            this.particleList = new List<Particle>();

            this.particleModel = new GeometryModel3D();
            this.particleModel.Geometry = new MeshGeometry3D();

            Image e = new Image();
            e.Source = new BitmapImage( source);

              //  Ellipse e = new Ellipse();

            e.Width = 32.0;
            e.Height = 32.0;
               // RadialGradientBrush b = new RadialGradientBrush();
               // b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0xFF, color.R, color.G, color.B), 0.25));
               // b.GradientStops.Add(new GradientStop(System.Windows.Media.Color.FromArgb(0x00, color.R, color.G, color.B), 1.0));

               // e.Fill = b;

            e.Measure(new System.Windows.Size(32, 32));
            e.Arrange(new Rect(0, 0, 32, 32));

            System.Windows.Media.Brush brush = null;

            #if USE_VISUALBRUSH
            brush = new VisualBrush(e);
            #else
            RenderTargetBitmap renderTarget = new RenderTargetBitmap(32, 32, 96, 96, PixelFormats.Pbgra32);
            renderTarget.Render(e);
            renderTarget.Freeze();
            brush = new ImageBrush(renderTarget);
            #endif

            DiffuseMaterial material = new DiffuseMaterial(brush);

            this.particleModel.Material = material;

            this.rand = new Random(brush.GetHashCode());
        }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:42,代码来源:ParticleSystem.cs

示例4: DrawingToBitmap

        /// <summary>
        /// Conerts a drawing into a bitmap object compatible with System.Drawing.
        /// </summary>
        /// <param name="drawing"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="stretch"></param>
        /// <returns></returns>
        public static System.Drawing.Bitmap DrawingToBitmap(Drawing drawing, int width, int height, Stretch stretch = Stretch.None)
        {
            var encoder = new PngBitmapEncoder();
            var drawingImage = new DrawingImage(drawing);

            var image = new Image() { Source = drawingImage };
            image.Stretch = stretch;
            image.HorizontalAlignment = HorizontalAlignment.Left;
            image.VerticalAlignment = VerticalAlignment.Top;
            image.Arrange(new Rect(0, 0, width, height));

            var bitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
            bitmap.Render(image);

            encoder.Frames.Add(BitmapFrame.Create(bitmap));

            var stream = new MemoryStream();
            encoder.Save(stream);

            return new System.Drawing.Bitmap(stream);
        }
开发者ID:EusthEnoptEron,项目名称:Sketchball,代码行数:29,代码来源:Booster.cs

示例5: AddPinTitleToDesktop

        public static void AddPinTitleToDesktop(string imageUri, string pinDestinationUri, StandardTileData newTileData)
        {
            string fileName = @"Shared\ShellContent\fbd-pintile-" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".jpg";

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                try
                {
                    var backImage = new Image();
                    backImage.Height = backImage.Width = 173;
                    backImage.Stretch = Stretch.None;
                    backImage.Source = new BitmapImage(new Uri(imageUri, UriKind.RelativeOrAbsolute))
                        {
                            CreateOptions = BitmapCreateOptions.BackgroundCreation
                        };
                    backImage.Measure(new Size(173, 173));
                    backImage.Arrange(new Rect(0, 0, 173, 173));
                    var image = new WriteableBitmap(backImage, null);

                    string directory = Path.GetDirectoryName(fileName);
                    if (!store.DirectoryExists(directory))
                    {
                        store.CreateDirectory(directory);
                    }
                    using (var stream = store.OpenFile(fileName, FileMode.OpenOrCreate))
                    {
                        image.SaveJpeg(stream, 173, 173, 0, 100);
                    }

                    newTileData.BackgroundImage = new Uri("isostore:/" + fileName, UriKind.Absolute);

                    // Create the tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
                    ShellTile.Create(new Uri(pinDestinationUri, UriKind.Relative), newTileData);
                }
                catch (Exception ex)
                {
                    return;
                }
            }
        }
开发者ID:NBitionDevelopment,项目名称:WindowsPhoneFeedBoard,代码行数:40,代码来源:GeneralHelper.cs

示例6: Print

        /// <summary>
        /// Print this canvas.  The dialog should have already been displayed and confirmed.
        /// </summary>
        /// <param name="printDlg"></param>
        public void Print(PrintDialog printDlg)
        {
            

            System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);

            Mute = true;

            BitmapSource bs = CreateImage();

            double wid = capabilities.PageImageableArea.ExtentWidth / bs.Width;
            double hei = capabilities.PageImageableArea.ExtentHeight / bs.Height;

            Image i = new Image();
            i.Source = bs;
            i.Stretch = Stretch.Uniform;
            i.Width = capabilities.PageImageableArea.ExtentWidth;
            i.Height = capabilities.PageImageableArea.ExtentHeight;

            Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

            //update the layout of the visual to the printer page size.

            i.Measure(sz);

            i.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

            
            //now print the visual to printer to fit on the one page.

            printDlg.PrintVisual(i, "Circuit");

            Mute = false;
            UseZoomCenter = false;
            
            SizeCanvas();
        }
开发者ID:buptkang,项目名称:LogicPad,代码行数:41,代码来源:GateCanvas.xaml.cs

示例7: PrintImageLabel_MouseDown

        private async void PrintImageLabel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            PrintDialog printDialog = new PrintDialog();

            if (printDialog.ShowDialog() != true)
            {
                return;
            }

            var progressDialog = await this.ShowProgressAsync(Resource.PleaseWait, "Printing image");

            BitmapSource bitmap = ElementToBitmap(this.ViewPort);

            // Create Image element for hosting bitmap.
            Image img = new Image
            {
                Source = bitmap,
                Stretch = Stretch.None
            };

            // Get scale of the print to screen of WPF visual.
            double scale = Math.Min(
                printDialog.PrintableAreaWidth / bitmap.Width,
                printDialog.PrintableAreaHeight / bitmap.Height);

            //Transform the imgae to scale
            img.LayoutTransform = new ScaleTransform(scale, scale);

            // Get the size of the printer page.
            Size size = new Size(
                bitmap.Width * scale,
                bitmap.Height * scale);

            //update the layout of the visual to the printer page size.
            img.Measure(size);
            img.Arrange(new Rect(new Point(0, 0), size));

            // Print the Image element.
            printDialog.PrintVisual(img, Path.GetFileName(this.filePath));

            await progressDialog.CloseAsync();
        }
开发者ID:oleksadobrianskyy,项目名称:ModelViewer3D,代码行数:47,代码来源:MainWindow.xaml.cs

示例8: drawStamp

 public void drawStamp(Point p, BitmapSource stamp, int size)
 {
     int stampWidth, stampHeight;
     if (stamp.PixelHeight > stamp.PixelWidth) {
         stampHeight = size;
         stampWidth = (int)((double)size * ((double)stamp.PixelWidth / (double)stamp.PixelHeight));
     } else {
         stampHeight = (int)((double)size * ((double)stamp.PixelHeight / (double)stamp.PixelWidth));
         stampWidth = size;
     }
     DrawingGroup drawing = new DrawingGroup();
     drawing.Children.Add(new ImageDrawing(bmp, new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight)));
     drawing.Children.Add(new ImageDrawing(stamp, new Rect(p.X - stampWidth / 2, p.Y - stampHeight / 2, stampWidth, stampHeight)));
     drawing.ClipGeometry = new RectangleGeometry(new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
     drawing.Freeze();
     var image = new Image { Source = new DrawingImage(drawing) };
     var bitmap = new RenderTargetBitmap(bmp.PixelWidth, bmp.PixelHeight, 96, 96, PixelFormats.Pbgra32);
     image.Arrange(new Rect(0, 0, bmp.PixelWidth, bmp.PixelHeight));
     bitmap.Render(image);
     bmp = BitmapFactory.ConvertToPbgra32Format(bitmap);
 }
开发者ID:riskawarrior,项目名称:tacticplanner,代码行数:21,代码来源:Drawing.cs

示例9: ThreadFunc

		private static void ThreadFunc(object state)
		{
			while (true)
			{
				var request = imageQueue.Take();

				int width = request.Width;
				int height = request.Heigth;
				Image image = new Image { Width = width, Height = height, Source = request.DrawingImage, Stretch = Stretch.Fill };
				image.Measure(new Size(width, height));
				image.Arrange(new Rect(0, 0, width, height));
				image.Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.Background);

#if false
				Window window = new Window();
				window.Content = image;
				window.Show();
#endif

				RenderTargetBitmap renderBitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
				renderBitmap.Render(image);
				image.Dispatcher.Invoke(new Action(() => { }), DispatcherPriority.Background);

				int[] pixels = new int[width * height];
				renderBitmap.CopyPixels(pixels, (width * PixelFormats.Pbgra32.BitsPerPixel + 7) / 8, 0);

				resultQueue.Add(pixels);
			}
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:29,代码来源:ImageHelper.cs

示例10: RenderCurve

        private void RenderCurve(
			int width,
			IEnumerable<IList<Point>> collection,
			double thickness,
			int miterLimit,
			int height,
			int stride,
			out byte[] bitmap,
			out byte[] selection)
        {
            if (_renderTargetBitmap == null
                || _renderTargetBitmap.PixelWidth != width
                || _renderTargetBitmap.PixelHeight != height)
            {
                _renderTargetBitmap = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
                _formatConvertedBitmap = new FormatConvertedBitmap(_renderTargetBitmap, DrawingParameter.TargetPixelFormat, DrawingParameter.TargetBitmapPalette, 1);

                _blurImage = new Image
                    {
                        Effect = new BlurEffect
                            {
                                Radius = 15,
                                KernelType = KernelType.Gaussian
                            },
                        Source = _renderTargetBitmap
                    };
                _blurImage.Measure(new Size(width, height));
                _blurImage.Arrange(new Rect(0, 0, width, height));
                _blurImage.InvalidateVisual();
                _selectionRtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Pbgra32);
                _selectionFcb = new FormatConvertedBitmap(_selectionRtb, DrawingParameter.TargetPixelFormat, DrawingParameter.TargetBitmapPalette, 1);
            }
            else
            {
                _renderTargetBitmap.Clear();
                _selectionRtb.Clear();
            }

            collection
                .Select(it =>
                    {
                        try
                        {
                            var visual = _drawingVisualFactory();
                            visual.Draw(it, thickness, miterLimit, _logicalToScreenMapperFactory());
                            return visual;
                        }
                        // Kann vorkommen, wenn der Container schon disposed ist, aber noch gezeichnet werden soll
                        catch (ObjectDisposedException)
                        {
                            return new DrawingVisual();
                        }
                    })
                .ForEachElement(_renderTargetBitmap.Render);

            bitmap = new byte[stride * height];
            _formatConvertedBitmap.CopyPixels(bitmap, stride, 0);

            //selection = bitmap;
            //return;

            //var writeableBitmap = new WriteableBitmap(width, height, 96, 96, DrawingParameter.TargetPixelFormat, DrawingParameter.TargetBitmapPalette);
            //writeableBitmap.Lock();
            //var rect = new Int32Rect(0, 0, width, height);
            //writeableBitmap.WritePixels(rect, bitmap, stride, 0);
            //writeableBitmap.AddDirtyRect(rect);
            //writeableBitmap.Unlock();
            // set the image to the original

            _selectionRtb.Render(_blurImage);
            selection = new byte[stride * height];
            _selectionFcb.CopyPixels(selection, stride, 0);

            // ABSOLUT notwendig, da es ansonsten MemoryLeaks gibt
            // siehe hier: http://stackoverflow.com/questions/192329/simple-wpf-sample-causes-uncontrolled-memory-growth
            _blurImage.UpdateLayout();

            //var png = new PngBitmapEncoder();
            //png.Frames.Add(BitmapFrame.Create(imageRtb));
            //using (var fs = new FileStream("c:\\temp\\test6.png", FileMode.Create))
            //    png.Save(fs);
        }
开发者ID:Bruhankovi4,项目名称:Emotyper,代码行数:82,代码来源:WpfBlurSelectionDrawer.cs

示例11: Screenshot

        private void Screenshot()
        {
            if (null == this.sensor)
            {
                this.statusBarText.Text = Properties.Resources.ConnectDeviceFirst;
                return;
            }

            // create a png bitmap encoder which knows how to save a .png file
            BitmapEncoder encoder = new PngBitmapEncoder();

            #region drawingGroup to bitmap
            var drawingImage = new DrawingImage(this.drawingGroup);
            var snapImage = new Image { Source = drawingImage };
            snapImage.Arrange(new Rect(0, 0, 640, 480));
            var snapbitmap = new RenderTargetBitmap(640, 480, 96, 96, PixelFormats.Pbgra32);
            snapbitmap.Render(snapImage);

            #endregion

            // create frame from the writable bitmap and add to encoder
            encoder.Frames.Add(BitmapFrame.Create(snapbitmap));

            string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

            string date = System.DateTime.Today.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

            string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            //string myPhotos = Environment.CurrentDirectory;

            string path = System.IO.Path.Combine(myPhotos, "KinectSnapshot-" + time + ".jpg");


            // write the new file to disk
            try
            {
                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    encoder.Save(fs);
                }

                this.statusBarText.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}", Properties.Resources.ScreenshotWriteSuccess, path);
            }
            catch (IOException)
            {
                this.statusBarText.Text = string.Format(CultureInfo.InvariantCulture, "{0} {1}", Properties.Resources.ScreenshotWriteFailed, path);
            }
        }
开发者ID:TrashTonyLin,项目名称:KinectCalAngle,代码行数:48,代码来源:MainWindow.xaml.cs

示例12: GetImage

        private RenderTargetBitmap GetImage()
        {
            var transformedText = Text.Text;
            _transformers.ToList().ForEach(x => transformedText = x.Transform(transformedText));

            var glowImage = new Image();
            var linesImage = new Image();

            glowImage.Source = DrawGlow(transformedText, 5, 5);
            glowImage.Measure(new Size((int)(LayoutRoot.ActualWidth * 5), (int)(LayoutRoot.ActualHeight * 5)));
            glowImage.Arrange(new Rect(new Size((int)(LayoutRoot.ActualWidth * 5), (int)(LayoutRoot.ActualHeight * 5))));
            glowImage.UpdateLayout();

            linesImage.Source = DrawLines(transformedText, 5, 5);
            linesImage.Measure(new Size((int)(LayoutRoot.ActualWidth * 5), (int)(LayoutRoot.ActualHeight * 5)));
            linesImage.Arrange(new Rect(new Size((int)(LayoutRoot.ActualWidth * 5), (int)(LayoutRoot.ActualHeight * 5))));
            linesImage.UpdateLayout();

            var bitmap = new RenderTargetBitmap((int)(LayoutRoot.ActualWidth * 5), (int)(LayoutRoot.ActualHeight * 5), 96, 96, PixelFormats.Pbgra32);
            bitmap.Render(glowImage);
            bitmap.Render(linesImage);

            return bitmap;
        }
开发者ID:Rayvid,项目名称:Zizit.Sigils,代码行数:24,代码来源:MainWindow.xaml.cs

示例13: getMapImage

 public BitmapSource getMapImage()
 {
     if (mapImg == null) {
         if (_mapPack == MapPack.Original) {
             mapImg = new BitmapImage(new Uri(originalFilename, UriKind.RelativeOrAbsolute));
         } else {
             mapImg = new BitmapImage(new Uri(hdFilename, UriKind.RelativeOrAbsolute));
         }
         if (_type != BattleType.Undefined) {
             DrawingGroup group = new DrawingGroup();
             group.Children.Add(new ImageDrawing(mapImg, new Rect(0, 0, mapImg.PixelWidth, mapImg.PixelHeight)));
             for (int i = 0; i < presets.Length; i++) {
                 if (presets[i].battle == _type && presets[i].variation == _variation) {
                     BitmapImage icon = presets[i].icon.getImage();
                     group.Children.Add(new ImageDrawing(icon, new Rect(presets[i].icon.position.X - _iconsSize / 2, presets[i].icon.position.Y - _iconsSize / 2, _iconsSize, (_iconsSize * icon.Height) / icon.Width)));
                 }
             }
             group.ClipGeometry = new RectangleGeometry(new Rect(0, 0, mapImg.PixelWidth, mapImg.PixelHeight));
             group.Freeze();
             var image = new Image { Source = new DrawingImage(group) };
             var bitmap = new RenderTargetBitmap(mapImg.PixelWidth, mapImg.PixelHeight, 96, 96, PixelFormats.Pbgra32);
             image.Arrange(new Rect(0, 0, mapImg.PixelWidth, mapImg.PixelHeight));
             bitmap.Render(image);
             mapImg = BitmapFactory.ConvertToPbgra32Format(bitmap);
         }
     }
     return (BitmapSource)mapImg.Clone();
 }
开发者ID:riskawarrior,项目名称:tacticplanner,代码行数:28,代码来源:Map.cs


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