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


C# Image.Arrange方法代码示例

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


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

示例1: SaveDrawingImage

        private static MemoryStream SaveDrawingImage(ImageSource drawingImage)
        {
            var image = new Image
            {
                Source = drawingImage
            };

            image.Arrange(new Rect(0, 0, drawingImage.Width, drawingImage.Height));

            var settings = Settings.Default;

            var renderTargetBitmap = new RenderTargetBitmap((int)drawingImage.Width, (int)drawingImage.Height, settings.ImageDPI, settings.ImageDPI, PixelFormats.Default);
            renderTargetBitmap.Render(image);

            Settings.Default.Save();

            var encoder = new JpegBitmapEncoder
            {
                QualityLevel = settings.JpgQuality
            };

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

            var memoryStream = new MemoryStream();

            encoder.Save(memoryStream);

            return memoryStream;
        }
开发者ID:Jo3-16,项目名称:FMA,代码行数:29,代码来源:FlyerCreator.cs

示例2: CheckImage

        void CheckImage(BitmapImage img)
        {
            if(img.IsDownloading)
            {
                Dispatcher.InvokeAsync(() => CheckImage(img), DispatcherPriority.Background);
            }
            else
            {
                var el = new System.Windows.Controls.Image()
                {
                    Source = img,
                    SnapsToDevicePixels = true,
                    UseLayoutRounding = true,
                    MinWidth = LedBadgeLib.BadgeCaps.Width,
                    MinHeight = LedBadgeLib.BadgeCaps.Height,
                    Width = img.Width * ((BitmapSource)img).DpiX / 96,
                    Stretch = Stretch.UniformToFill,
                };
                RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
                el.Measure(new Size(LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
                el.Arrange(new Rect(0, 0, LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));

                m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(el, dither : Dither)));
            };
        }
开发者ID:Effix,项目名称:LedBadge,代码行数:25,代码来源:ImageProvider.cs

示例3: PrintPage

 private static UIElement PrintPage(BitmapSource bitmap)
 {
     var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight);
     var image = new System.Windows.Controls.Image { Source = bitmap };
     image.Measure(bitmapSize);
     image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize));
     return image;
 }
开发者ID:nukolai,项目名称:xaml-sdk,代码行数:8,代码来源:PrintingService.cs

示例4: ApplyCinemagraphButton_Click

        private void ApplyCinemagraphButton_Click(object sender, RoutedEventArgs e)
        {
            if (CinemagraphInkCanvas.Strokes.Count == 0)
            {
                ShowWarning(ResMessage("Editor.Cinemagraph.WarningNoDrawing"), MessageIcon.Info);
                return;
            }

            ActionStack.Did(ListFrames);

            var dpi = ListFrames[0].ImageLocation.DpiOf();
            var scaledSize = ListFrames[0].ImageLocation.ScaledSize();

            #region Get the Strokes and Clip the Image

            var image = ListFrames[0].ImageLocation.SourceFrom();
            var rectangle = new RectangleGeometry(new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(image.PixelWidth, image.PixelHeight)));
            Geometry geometry = Geometry.Empty;

            foreach (Stroke stroke in CinemagraphInkCanvas.Strokes)
            {
                geometry = Geometry.Combine(geometry, stroke.GetGeometry(), GeometryCombineMode.Union, null);
            }

            geometry = Geometry.Combine(geometry, rectangle, GeometryCombineMode.Xor, null);

            var clippedImage = new System.Windows.Controls.Image
            {
                Height = image.PixelHeight,
                Width = image.PixelWidth,
                Source = image,
                Clip = geometry
            };
            clippedImage.Measure(scaledSize);
            clippedImage.Arrange(new Rect(scaledSize));

            var imageRender = clippedImage.GetRender(dpi, scaledSize);

            #endregion

            Cursor = Cursors.AppStarting;

            _overlayFramesDel = Overlay;
            _overlayFramesDel.BeginInvoke(imageRender, dpi, true, OverlayCallback, null);

            ClosePanel();
        }
开发者ID:dbremner,项目名称:ScreenToGif,代码行数:47,代码来源:Editor.xaml.cs

示例5: CheckTweetData

        void CheckTweetData(string text, List<BitmapImage> images)
        {
            bool ready = true;
            foreach(var img in images)
            {
                if(img.IsDownloading)
                {
                    ready = false;
                    break;
                }
            }

            if(ready)
            {
                Func<ImageSource, Image> makeImg = source =>
                {
                    var el = new System.Windows.Controls.Image()
                    {
                        Source = source,
                        SnapsToDevicePixels = true,
                        UseLayoutRounding = true,
                        MinWidth = LedBadgeLib.BadgeCaps.Width,
                        MinHeight = LedBadgeLib.BadgeCaps.Height,
                        Width = source.Width * ((BitmapSource)source).DpiX / 96,
                        Stretch = Stretch.UniformToFill,
                    };
                    RenderOptions.SetBitmapScalingMode(source, BitmapScalingMode.NearestNeighbor);
                    el.Measure(new Size(LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
                    el.Arrange(new Rect(0, 0, LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
                    return el;
                };

                if(images.Count > 0)
                {
                    m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(makeImg(images[0]), dither: Dither)));
                }
                m_messageQueue.Enqueue(LedBadgeLib.WPF.MakeQueuedItem(LedBadgeLib.WPF.MakeSingleLineItem(text)));
                for(int i = 1; i < images.Count; ++i)
                {
                    m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(makeImg(images[i]), dither : Dither)));
                }
            }
            else
            {
                Dispatcher.InvokeAsync(() => CheckTweetData(text, images), DispatcherPriority.Background);
            }
        }
开发者ID:Effix,项目名称:LedBadge,代码行数:47,代码来源:TwitterProvider.cs


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