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


C# BitmapImage.Freeze方法代码示例

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


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

示例1: getImage

        public Image getImage()
        {
            Image img = new Image();

            if (!imageCache.ContainsKey(Item.IconURL))
            {
                using (var stream = ApplicationState.Model.GetImage(Item))
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = stream;
                    bitmap.CacheOption = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    bitmap.Freeze();
                    imageCache.Add(Item.IconURL, bitmap);
                }
            }

            img.Source = imageCache[Item.IconURL];
            var itemhover = new ItemHover() { DataContext = ItemHoverViewModelFactory.Create(Item) };

            Popup popup = new Popup();
            popup.AllowsTransparency = true;
            popup.PopupAnimation = PopupAnimation.Fade;
            popup.StaysOpen = true;
            popup.Child = itemhover;
            popup.PlacementTarget = img;
            img.Stretch = Stretch.None;
            img.MouseEnter += (o, e) => { popup.IsOpen = true; };
            img.MouseLeave += (o, e) => { popup.IsOpen = false; };
            return img;
        }
开发者ID:sebflex,项目名称:build-optimizer,代码行数:32,代码来源:ItemDisplayViewModel.cs

示例2: Convert

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			if (value == null)
				return null;
			if (value.ToString().IsEmpty() || (value.ToString() == "none")) {
				var image = new BitmapImage();
				image.BeginInit();
				image.UriSource = new Uri("pack://application:,,,/PCSX2Bonus;component/Images/noart.png", UriKind.Absolute);
				image.DecodePixelWidth = 0x109;
				image.DecodePixelHeight = 350;
				image.EndInit();
				if (image.CanFreeze)
					image.Freeze();
				return image;
			}
			var image2 = new BitmapImage();
			using (var stream = File.OpenRead(value.ToString())) {
				image2.BeginInit();
				image2.StreamSource = stream;
				image2.DecodePixelWidth = 0x109;
				image2.DecodePixelHeight = 350;
				image2.CacheOption = BitmapCacheOption.OnLoad;
				image2.EndInit();
			}
			if (image2.CanFreeze)
				image2.Freeze();
			return image2;
		}
开发者ID:CyberFoxHax,项目名称:PCSXBonus,代码行数:27,代码来源:FullscreenBitmapConverter.cs

示例3: SignatureWindow

        public SignatureWindow(string signature)
        {
            var digitalSignatureCollection = new List<object>();
            digitalSignatureCollection.Add(new ComboBoxItem() { Content = "" });
            digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatureCollection.Select(n => new DigitalSignatureComboBoxItem(n)).ToArray());

            InitializeComponent();

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(App.DirectoryPaths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _signatureComboBox.ItemsSource = digitalSignatureCollection;

            for (int index = 0; index < Settings.Instance.Global_DigitalSignatureCollection.Count; index++)
            {
                if (Settings.Instance.Global_DigitalSignatureCollection[index].ToString() == signature)
                {
                    _signatureComboBox.SelectedIndex = index + 1;

                    break;
                }
            }
        }
开发者ID:networkelements,项目名称:Amoeba,代码行数:31,代码来源:SignatureWindow.xaml.cs

示例4: ComposerToThumbnail

        public static BitmapImage ComposerToThumbnail(Composer composer)
        {
            var thumbnail = (BitmapImage)null;

            if (_thumbnailCache.TryGetValue(composer.ComposerId, out thumbnail))
            {
                return _thumbnailCache[composer.ComposerId];
            }

            var directoryPath = [email protected]"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create)}\Music Timeline\Resources\Thumbnails\";

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            var thumbnailPath = [email protected]"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.Create)}\Music Timeline\Resources\Thumbnails\{composer.ComposerId}.jpg";
            var thumbnailUri = new Uri(thumbnailPath, UriKind.Absolute);

            if (File.Exists(thumbnailPath))
            {
                thumbnail = new BitmapImage();
                thumbnail.BeginInit();
                thumbnail.DecodePixelHeight = 50;
                thumbnail.StreamSource = new MemoryStream(File.ReadAllBytes(thumbnailPath));
                thumbnail.EndInit();
                thumbnail.Freeze();

                _thumbnailCache[composer.ComposerId] = thumbnail;

                return thumbnail;
            }

            return CreateThumbnail(composer);
        }
开发者ID:nharren,项目名称:MusicTimeline,代码行数:35,代码来源:ComposerToThumbnailConverter.cs

示例5: LoadImage

        internal static async Task LoadImage(this Canvas canvas, WindowData data, int imageIndex)
        {
            var image = await Task.Run(delegate
            {
                var im = new BitmapImage(new Uri(data.FileList[imageIndex].FileName));
                im.Freeze();
                return im;
            });

            data.ScaleX = image.Width / image.PixelWidth;
            data.ScaleY = image.Height / image.PixelHeight;

            //if (image.PixelWidth != FileAccess.imageWidth || image.PixelHeight != FileAccess.imageHeight) throw new Exception();

            var bg = new ImageBrush
            {
                ImageSource = image
            };

            data.WindowTitle = Path.GetFileName(data.FileList[imageIndex].FileName) + " (" + bg.ImageSource.Width + "x" + bg.ImageSource.Height + ")";

            canvas.Background = bg;
            canvas.Width = bg.ImageSource.Width;
            canvas.Height = bg.ImageSource.Height;

            canvas.Scale(data.Zoom);

            Keyboard.Focus(canvas);
        }
开发者ID:zbxzc35,项目名称:Classifier,代码行数:29,代码来源:WindowCanvas.cs

示例6: load_image

 public void load_image(object arg, DoWorkEventArgs e)
 {
     int contribution_id = (int)e.Argument;
     if (!window_manager.downloaded_contributions.Contains(contribution_id))
     {
         naturenet_dataclassDataContext db = new naturenet_dataclassDataContext();
         var result1 = from c in db.Contributions
                       where c.id == contribution_id
                       select c;
         if (result1.Count() != 0)
         {
             Contribution contrib = result1.First<Contribution>();
             bool result = file_manager.download_file_from_googledirve(contrib.media_url, contribution_id);
             if (result) window_manager.downloaded_contributions.Add(contribution_id);
         }
     }
     try
     {
         ImageSource src = new BitmapImage(new Uri(configurations.GetAbsoluteContributionPath() + contribution_id.ToString() + ".jpg"));
         src.Freeze();
         the_image = src;
         //window_manager.contributions.Add(contribution_id, src);
         e.Result = (object)contribution_id;
     }
     catch (Exception)
     {
         /// write log
         e.Result = -1;
     }
 }
开发者ID:naturenet,项目名称:nature-net-ppi,代码行数:30,代码来源:image_frame.xaml.cs

示例7: GetAlbumArt

        public static BitmapImage GetAlbumArt(string path)
        {
            if(path != null)
            {
                try
                {
                     TagLib.File tagFile = TagLib.File.Create(path);

                        if (tagFile.Tag.Pictures.Length != 0)
                        {
                            MemoryStream ms = new MemoryStream(tagFile.Tag.Pictures[0].Data.Data);
                            ms.Seek(0, SeekOrigin.Begin);

                            // ImageSource for System.Windows.Controls.Image
                            BitmapImage bitmap = new BitmapImage();
                            bitmap.BeginInit();
                            bitmap.StreamSource = ms;
                            bitmap.EndInit();
                            bitmap.Freeze();

                            return bitmap;
                        }

                }
                catch(Exception e)
                {

                }
            }

            return null;
        }
开发者ID:savatia,项目名称:TerribleMusicPlayer,代码行数:32,代码来源:SongHelper.cs

示例8: GetBmpFromBitmap

        /// <summary>
        /// 将bitmap转换成bitmapImage类型
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns>绑定给控件显示的类型</returns>
        public static BitmapImage GetBmpFromBitmap(Bitmap bitmap)
        {
            BitmapImage bitImg = new BitmapImage();
            using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                bitmap.Save(ms, ImageFormat.Bmp);

                try
                {
                    bitImg.BeginInit();

                    bitImg.CacheOption = BitmapCacheOption.OnLoad;

                    bitImg.StreamSource = ms;

                    bitImg.EndInit();
                    bitImg.Freeze();
                    return bitImg;
                }
                catch (System.Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }
        }
开发者ID:orange-pig,项目名称:orange-pig.common,代码行数:30,代码来源:BitmapHelper.cs

示例9: createImage

        private Image createImage(Node node, int children)
        {
            Image img = new Image();
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri("res/img/" + node.ImageName + ".png", UriKind.Relative);
            bi.EndInit();
            bi.Freeze();

            img.Source = bi;
            if (node.Level == 1)
            {
                img.Height = 118;
                img.Width = 258;
            }
            else
            {
                if (children <= 6)
                {
                    img.Height = 200;
                    img.Width = 209;
                }
                else
                {
                    img.Height = 150;
                    img.Width = 153;
                }
            }

            img.Margin = new Thickness(10, 0, 80, 0);
            img.Tag = node;
            img.MouseLeftButtonDown += gotoNext;

            return img;
        }
开发者ID:huiyi-outsourcing,项目名称:SimuTraining,代码行数:35,代码来源:IndexWindow.xaml.cs

示例10: GetCover

        public BitmapImage GetCover(Guid guid, string artist, string album = null)
        {
            var item = new byte[] { };

            try
            {
                item = Get(guid);
            }
            catch (DataIdentifierNotFoundException)
            {
                if (SettingsModel.Instance.CoverDownloadEnabled)
                {
                    item = DownloadImage(guid, artist, album, 5);
                }
            }

            if (item.Length == 0) return _defaultCover;

            var source = new BitmapImage();
            using (Stream stream = new MemoryStream(item))
            {
                source.BeginInit();
                source.StreamSource = stream;
                source.CacheOption = BitmapCacheOption.OnLoad;
                source.EndInit();
            }
            source.Freeze();
            return source;
        }
开发者ID:gfdittmer,项目名称:MiSharp,代码行数:29,代码来源:CoverRepository.cs

示例11: MulticastMessageEditWindow

        public MulticastMessageEditWindow(Tag tag, string comment, AmoebaManager amoebaManager)
        {
            _tag = tag;
            _amoebaManager = amoebaManager;

            _digitalSignatureCollection.AddRange(Settings.Instance.Global_DigitalSignatures.ToArray());

            InitializeComponent();

            this.Title = LanguagesManager.Instance.MulticastMessageEditWindow_Title + " - " + MessageConverter.ToTagString(tag);

            {
                var icon = new BitmapImage();

                icon.BeginInit();
                icon.StreamSource = new FileStream(Path.Combine(_serviceManager.Paths["Icons"], "Amoeba.ico"), FileMode.Open, FileAccess.Read, FileShare.Read);
                icon.EndInit();
                if (icon.CanFreeze) icon.Freeze();

                this.Icon = icon;
            }

            _signatureComboBox.ItemsSource = _digitalSignatureCollection;
            _signatureComboBox.SelectedIndex = 0;

            _commentTextBox.Text = comment;

            _watchTimer = new WatchTimer(this.WatchThread, 0, 1000);
            this.Closed += (sender, e) => _watchTimer.Dispose();

            _textEditor_Helper.Setup(_textEditor);
        }
开发者ID:Alliance-Network,项目名称:Amoeba,代码行数:32,代码来源:MulticastMessageEditWindow.xaml.cs

示例12: Convert

        public BitmapImage Convert(BitmapSource bitmap)
        {
            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(bitmap));

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

            var bitmapImage = new BitmapImage();
            bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
            bitmapImage.CreateOptions = BitmapCreateOptions.None;

            try
            {
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = new MemoryStream(memoryStream.ToArray());
            }
            finally
            {
                bitmapImage.EndInit();
                bitmapImage.Freeze();
                memoryStream.Close();
            }

            return bitmapImage;
        }
开发者ID:RainbowCrashie,项目名称:ImgUpl0ad,代码行数:26,代码来源:ImageIO.cs

示例13: GetImage

        public static BitmapImage GetImage(string resource, int size = -1, Assembly assembly = null)
        {
            BitmapImage bitmap;
            if (assembly == null)
            {
                assembly = Assembly.GetExecutingAssembly();
            }

            using (var stream = assembly.GetManifestResourceStream(resource))
            {
                if (stream != null)
                {
                    bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = stream;
                    bitmap.CacheOption = BitmapCacheOption.OnLoad;
                    if (size != -1)
                    {
                        bitmap.DecodePixelHeight = size;
                        bitmap.DecodePixelWidth = size;
                    }
                    bitmap.EndInit();
                    bitmap.Freeze();
                    return bitmap;
                }
            }

            return null;

        }
开发者ID:00Green27,项目名称:DocUI,代码行数:30,代码来源:EmbeddedResourceTools.cs

示例14: GetDefaultAlbumArt

 /// <summary>
 /// Returns a 'default' image for when album art wasn't found in a song
 /// </summary>
 /// <returns></returns>
 private static BitmapImage GetDefaultAlbumArt()
 {
     var img = new BitmapImage(new Uri("pack://application:,,,/Resources/Images/DefaultAlbumCover.png",
         UriKind.RelativeOrAbsolute));
     img.Freeze();
     return img;
 }
开发者ID:JLignell,项目名称:Jokify,代码行数:11,代码来源:ImageHelper.cs

示例15: FigureWrapper

        public FigureWrapper(byte figure)
        {
            InitializeComponent();
            FigurePlacedOrChosen = false;
            Figure = figure;

            Ellipse e1 = (Ellipse)this.FindName("Ellipse1");
            Ellipse e2 = (Ellipse)this.FindName("Ellipse2");
            Ellipse e3 = (Ellipse)this.FindName("Ellipse3");
            Ellipse e4 = (Ellipse)this.FindName("Ellipse4");

            e1.Fill = new SolidColorBrush(((figure & 1) == 0) ? Color.FromArgb(255, 0x44, 0x44, 0x44) : Color.FromArgb(255, 255, 255, 255));
            e2.Fill = new SolidColorBrush(((figure & 2) == 0) ? Color.FromArgb(255, 0x44, 0x44, 0x44) : Color.FromArgb(255, 255, 255, 255));
            e3.Fill = new SolidColorBrush(((figure & 4) == 0) ? Color.FromArgb(255, 0x44, 0x44, 0x44) : Color.FromArgb(255, 255, 255, 255));
            e4.Fill = new SolidColorBrush(((figure & 8) == 0) ? Color.FromArgb(255, 0x44, 0x44, 0x44) : Color.FromArgb(255, 255, 255, 255));

            using (Stream _stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Quarto.Images.figure" + figure + ".png"))
            {
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = _stream;
                bi.CacheOption = BitmapCacheOption.OnLoad;
                bi.EndInit();
                bi.Freeze();
                this.Background = new ImageBrush
                {
                    ImageSource = bi
                };
            }
            SwitchToPieceView();
        }
开发者ID:VanVector,项目名称:Quarto,代码行数:31,代码来源:FigureWrapper.xaml.cs


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