• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Imaging.BitmapFrame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



BitmapFrame类属于System.Windows.Media.Imaging命名空间,在下文中一共展示了BitmapFrame类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: JpgToBase64

        public static string JpgToBase64(BitmapFrame aBMP)
        {
            try
            {
                string pBase64String = null;
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                //BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                encoder.Frames.Add(aBMP);
                MemoryStream ms = new MemoryStream();

                //Convert.ToBase64String
                encoder.Save(ms);
                byte[] pPole = new byte[ms.Length];
                ms.Seek(0, SeekOrigin.Begin);
                ms.Read(pPole, 0, pPole.Length);
                pBase64String = Convert.ToBase64String(pPole);
                ms.Close();
                return pBase64String;
            }
            catch (Exception)
            {

                return null;
            }
        }
开发者ID:Ttxman,项目名称:NanoTrans,代码行数:25,代码来源:MyKONST.cs


示例2: DesignTimeSearchResult

	    public DesignTimeSearchResult(BitmapFrame icon, string processName, string title, string error = null)
		{
			View = new BasicListEntry();
			Icon = icon;
			ProcessName = processName;
			Title = title;
		    Error = error;
		}
开发者ID:olivierdagenais,项目名称:GoToWindow,代码行数:8,代码来源:DesignTimeSearchResult.cs


示例3: ToByteArray

 private static byte[] ToByteArray(BitmapFrame bfResize)
 {
     MemoryStream msStream = new MemoryStream();
     JpegBitmapEncoder encoder = new JpegBitmapEncoder();
     encoder.Frames.Add(bfResize);
     encoder.Save(msStream);
     return msStream.ToArray();
 }
开发者ID:senioroman4uk,项目名称:SignetRecognition,代码行数:8,代码来源:ImageHandler.cs


示例4: GetPngStream

        private static MemoryStream GetPngStream(BitmapFrame photo)
        {
            MemoryStream result = new MemoryStream();

            PngBitmapEncoder targetEncoder = new PngBitmapEncoder();
            targetEncoder.Frames.Add(photo);
            targetEncoder.Save(result);

            return result;
        }
开发者ID:keyvan,项目名称:ImageResizer4DotNet,代码行数:10,代码来源:ResizerPrivate.cs


示例5: ImageToByte

 public static byte[] ImageToByte(BitmapFrame bfResize)
 {
     using (MemoryStream msStream = new MemoryStream())
     {
         PngBitmapEncoder pbdDecoder = new PngBitmapEncoder();
         pbdDecoder.Frames.Add(bfResize);
         pbdDecoder.Save(msStream);
         return msStream.ToArray();
     }
 }
开发者ID:MisterTobi,项目名称:restaurant-cafe,代码行数:10,代码来源:ImageHandler.cs


示例6: GetFramePixelDepth

		/// <summary>
		/// Gets the pixel depth (in bits per pixel, bpp) of the specified frame
		/// </summary>
		/// <param name="frame">The frame to get BPP for</param>
		/// <returns>The number of bits per pixel in the frame</returns>
		static int GetFramePixelDepth (BitmapFrame frame)
		{
			if (frame.Decoder.CodecInfo.ContainerFormat == new Guid("{a3a860c4-338f-4c17-919a-fba4b5628f21}")
			    && frame.Thumbnail != null)
			{
				// Windows Icon format, original pixel depth is in the thumbnail
				return frame.Thumbnail.Format.BitsPerPixel;
			}
			// Other formats, just assume the frame has the correct BPP info
			return frame.Format.BitsPerPixel;
		}
开发者ID:Exe0,项目名称:Eto,代码行数:16,代码来源:MultiSizeImage.cs


示例7: GenSheet

        //Function to Gen the sprite sheet with a string of images
        public void GenSheet(string[] images)
        {
            BitmapFrame[] frames = new BitmapFrame[images.Length];
            // Atlas Dimensions
            int iW = 0;
            int iH = 0;

            // Loads the images to tile (no need to specify PngBitmapDecoder, the correct decoder is automatically selected)
            for (int i = 0; i < images.Length; i++)
            {
               frames[i] = BitmapDecoder.Create(new Uri(images[i]), BitmapCreateOptions.None, BitmapCacheOption.OnLoad).Frames.First();
            }
            //Make it so that the two biggest heights and widths depict size
            for(int i = 0; i<frames.Length; i++)
            {
                iW += frames[i].PixelWidth;
            }
            for(int i = 1; i<frames.Length; i++)
            {
                iH = Math.Max(frames[i-1].PixelHeight, frames[i].PixelHeight);
            }
            // Draws the images into a DrawingVisual component
            DrawingVisual drawingVisual = new DrawingVisual();
            using (DrawingContext drawingContext = drawingVisual.RenderOpen())
            {
                int prevFrames = 0;//var prevFrames changed during loop
                for (int i = 0; i < frames.Length; i++)
                {
                    //loading all the images using a for loop for a finite number of images
                    drawingContext.DrawImage(frames[i], new Rect(prevFrames, 0, frames[i].PixelWidth, frames[i].PixelHeight));
                    //saves the width of the prevFrame so that the next image can draw next to it and produces a row of images
                    prevFrames += frames[i].PixelWidth;

                }
            }
            // Converts the Visual (DrawingVisual) into a BitmapSource
            RenderTargetBitmap bmp = new RenderTargetBitmap(iW, iH, 96, 96, PixelFormats.Pbgra32);
            bmp.Render(drawingVisual);

            // Creates a PngBitmapEncoder and adds the BitmapSource to the frames of the encoder
            PngBitmapEncoder encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(bmp));

            string directory = Directory.GetCurrentDirectory();

            // Saves the image into a file using the encoder
            using (Stream stream = File.Create(directory + @"\tile.png"))
                encoder.Save(stream);
            Vector[] eeek = stripSorter(frames);

            XML eek = new XML();
            eek.BuildXMLDoc(images, frames, iW, iH, eeek);
        }
开发者ID:JayStilla,项目名称:SpriteMapGenerator,代码行数:54,代码来源:MyCanvas.cs


示例8: SetTile

        public void SetTile(int _x, int _y, BitmapFrame _image)
        {
            // hat das bild noch keine ID?
            if(!images.Contains(_image))
            {
                // id erstellen
                images.Add(_image);
            }

            // id setzen
            Tiles[_x, _y] = images.IndexOf(_image);
        }
开发者ID:ColonelBlack94,项目名称:ToolDev_GPD415,代码行数:12,代码来源:Map.cs


示例9: ToByteArrayWpf

 public static byte[] ToByteArrayWpf(BitmapFrame targetFrame, int quality)
 {
     byte[] targetBytes;
     using (var memoryStream = new MemoryStream()) {
         var targetEncoder = new JpegBitmapEncoder {
                                                       QualityLevel = quality
                                                   };
         targetEncoder.Frames.Add(targetFrame);
         targetEncoder.Save(memoryStream);
         targetBytes = memoryStream.ToArray();
     }
     return targetBytes;
 }
开发者ID:eakova,项目名称:resizer,代码行数:13,代码来源:Utils.cs


示例10: Resize

 private static BitmapFrame Resize(BitmapFrame photo, int width, int height, BitmapScalingMode scalingMode)
 {
     DrawingGroup group = new DrawingGroup();
     RenderOptions.SetBitmapScalingMode(group, scalingMode);
     group.Children.Add(new ImageDrawing(photo, new Rect(0, 0, width, height)));
     DrawingVisual targetVisual = new DrawingVisual();
     DrawingContext targetContext = targetVisual.RenderOpen();
     targetContext.DrawDrawing(group);
     RenderTargetBitmap target = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default);
     targetContext.Close();
     target.Render(targetVisual);
     BitmapFrame targetFrame = BitmapFrame.Create(target);
     return targetFrame;
 }
开发者ID:keyvan,项目名称:ImageResizer4DotNet,代码行数:14,代码来源:ResizerPrivate.cs


示例11: CreateImageFile

 private void CreateImageFile(FileStream file,BitmapFrame frame,ImageType type)
 {
     if(file==null)return;
     BitmapEncoder encoder=null;
     switch(type)
     {
     case ImageType.Bmp:encoder=new BmpBitmapEncoder();break;
     case ImageType.Jpg:encoder=new JpegBitmapEncoder(){QualityLevel=100};break;
     case ImageType.Png:encoder=new PngBitmapEncoder();break;
     case ImageType.Gif:encoder=new GifBitmapEncoder();break;
     case ImageType.Tiff:encoder=new TiffBitmapEncoder(){Compression=TiffCompressOption.Default};break;
     }
     encoder.Frames.Add(frame);
     encoder.Save(file);
 }
开发者ID:DP458,项目名称:Clipboard_Watcher,代码行数:15,代码来源:MainWindow.Save.cs


示例12: GetThumbnail

 /// <summary>
 /// ThumbnailExceptionWorkArround when image cause a format exception by accessing the Thumbnail
 /// </summary>
 /// <param name="frame"></param>
 /// <returns></returns>
 static BitmapSource GetThumbnail(BitmapFrame frame)
 {
     try
     {
         if (frame != null &&
             frame.PixelWidth == 16 && frame.PixelHeight == 16 &&
             ((frame.Format == PixelFormats.Bgra32) || (frame.Format == PixelFormats.Bgr24)))
             return frame;
         else
             return null;
     }
     catch (Exception)
     {
         return null;
     }
 }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:21,代码来源:IconConverter.cs


示例13: ConvertToBitmapImage

 private BitmapImage ConvertToBitmapImage(BitmapFrame bf)
 {
     BmpBitmapEncoder encoder = new BmpBitmapEncoder
     {
         Frames = { bf }
     };
     MemoryStream stream = new MemoryStream();
     encoder.Save(stream);
     stream.Seek(0L, SeekOrigin.Begin);
     BitmapImage image = new BitmapImage();
     image.BeginInit();
     image.StreamSource = stream;
     image.EndInit();
     stream.Close();
     return image;
 }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:16,代码来源:GifAnimation.cs


示例14: AddToolboxImage

        private void AddToolboxImage(BitmapFrame _image)
        {
            // neues bild erstellen
            Image newImage = new Image();

            // groesse des bildes festlegen
            newImage.Width = 50.0f;
            newImage.Height = 50.0f;
            newImage.Margin = new Thickness(5.0d);

            // event registrieren
            newImage.MouseDown += Image_MouseDown;

            // bildquelle angeben
            newImage.Source = _image;

            // bild der toolbox hinzufuegen
            ToolBoxStackPanel.Children.Add(newImage);
        }
开发者ID:ColonelBlack94,项目名称:ToolDev_GPD415,代码行数:19,代码来源:MainWindow.xaml.cs


示例15: Photo

        /// <summary>
        /// Constructor
        /// </summary>
        public Photo(string path, string name)
        {
            _source = new Uri(path);
            _image = BitmapFrame.Create(_source);
            //_name = name.Remove(name.Length - 4); //Remove fileextension
            _name = Tools.RemoveExtension(name);
            _name = Tools.RemoveStartNumber(_name);

            //Create Thumbnail for png and Bmp images
            if (_image.Thumbnail == null)
            {
                _myThumbnail = new BitmapImage();
                _myThumbnail.BeginInit();
                _myThumbnail.UriSource = _source;
                _myThumbnail.DecodePixelWidth = 436;
                _myThumbnail.DecodePixelHeight = 326;
                _myThumbnail.EndInit();
            }
        }
开发者ID:virucho,项目名称:TouchInfoPoint,代码行数:22,代码来源:PhotoModel.cs


示例16: FlipDigit

        public FlipDigit()
        {
            InitializeComponent();

            _step = 0;
            _current = 0;
            Pace = 300;
            _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(Pace / 7) };
            _timer.Tick += timer_Tick;

            var digitsTop = Application.GetContentStream(new Uri(@"digits-top.png", UriKind.RelativeOrAbsolute));
            if (digitsTop != null)
                _digitsTop = BitmapFrame.Create(digitsTop.Stream);

            var digitsBottom = Application.GetContentStream(new Uri(@"digits-bottom.png", UriKind.RelativeOrAbsolute));
            if (digitsBottom != null)
                _digitsBottom = BitmapFrame.Create(digitsBottom.Stream);

            goToNumber(0, 0);
        }
开发者ID:timgaunt,项目名称:FreeAgent-Time-Logger,代码行数:20,代码来源:FlipDigit.xaml.cs


示例17: FrameToBitmap

        /// <summary>
        /// Converts the Frame to a Bitmapimage
        /// </summary>
        /// <param name="bitmapFrame"></param>
        /// <returns></returns>
        public static BitmapImage FrameToBitmap(BitmapFrame bitmapFrame)
        {
            BitmapImage bImg = new BitmapImage();
            BitmapEncoder encoder = new PngBitmapEncoder(); //new JpegBitmapEncoder();

            using (MemoryStream memoryStream = new MemoryStream())
            {
                encoder.Frames.Add(bitmapFrame);
                encoder.Save(memoryStream);
                bImg.BeginInit();
                bImg.CacheOption = BitmapCacheOption.OnLoad;
                bImg.CreateOptions = BitmapCreateOptions.None;
                bImg.StreamSource = new MemoryStream(memoryStream.ToArray());
                bImg.EndInit();

                bImg.Freeze();
            }

            return bImg;
        }
开发者ID:ElderByte-,项目名称:Archimedes.Patterns,代码行数:25,代码来源:ImageSupport.cs


示例18: BuildXMLDoc

        //Create declaration
        public void BuildXMLDoc(string[] filename, BitmapFrame[] frames, int width, int height, Vector[] xy)
        {
            XDeclaration XMLdec = new XDeclaration("1.0", "UTF-8", "yes");
            //fill with frames
            Object[] XMLelem = new Object[frames.Length];
            for (int i = 0; i < frames.Length; i++)
            {
                XElement node = new XElement("SubTexture");

                BitmapFrame eek = frames[i];

                node.SetAttributeValue("name", filename[i]);
                node.SetAttributeValue("x", xy[i].X);
                node.SetAttributeValue("y", xy[i].Y);
                node.SetAttributeValue("width", frames[i].PixelWidth);
                node.SetAttributeValue("height", frames[i].PixelHeight);

                XMLelem[i] = node;

            }
            XElement XMLRootNode = new XElement("TextureAtlas", XMLelem);
            XMLRootNode.SetAttributeValue("imagePath", "Naw");

            XDocument XMLdoc = new XDocument(XMLdec, XMLRootNode);

            AtlasXML = XMLdoc;

            Microsoft.Win32.SaveFileDialog saveDiag = new Microsoft.Win32.SaveFileDialog();
            Nullable<bool> diagResult = saveDiag.ShowDialog();

            if (diagResult == true)
            {
                FileStream XMLstream = new FileStream(saveDiag.FileName, FileMode.Create);
                XMLdoc.Save(XMLstream);
                XMLstream.Close();
            }
            else
            {
                return;
            }
        }
开发者ID:JayStilla,项目名称:SpriteMapGenerator,代码行数:42,代码来源:XML.cs


示例19: CommunitySessionWindow

 public CommunitySessionWindow(SessionTabItem sessionTabItem)
 {
     this.sessionTabItems = new ObservableCollection<SessionTabItem>();
     //WindowHelper.Hook(this, "headerBackground", new string[] { "controlBox", "toolBar" });
     this.InitializeComponent();
     Util_UserSettings_ContactSessionWindow.SettingsChanged += new PropertyChangedEventHandler(this.Util_UserSettings_CommunitySessionWindow_SettingsChanged);
     this.SetSendButtonToolTip();
     this.AddSession(sessionTabItem);
     if (_icon == null)
     {
         _icon = BitmapFrame.Create(new Uri(EnvironmentPath.Startup + @"res\community16.ico", UriKind.Absolute));
     }
     base.Icon = _icon;
     this.BindWindowTitleAndIcon();
     this.communityManager = this.CurrentSessionTabItem.CommunitySession.Community.CommunityManager;
     this.communityManager.RefreshAllMemberInfo();
     this.communityManager.SortManager.SortEvent += new EventHandler<EventArgs>(this.CommunityMemberSortManager_Sort);
     this.communityManager.SortManager.RequestSorting();
     this.CurrentSessionTabItem.CommunitySession.Community.PropertyChanged += new PropertyChangedEventHandler(this.CommunitySessionWindow_PropertyChanged);
     Buddy.BuddyPropertyChanged += new PropertyChangedEventHandler(this.Buddy_BuddyPropertyChanged);
     this.communityManager.MemberChanged += new EventHandler(this.communityManager_MemberChanged);
     this.CalcMemberCount();
     this.SetMsgSetImage();
 }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:24,代码来源:CommunitySessionWindow.xaml.cs


示例20: AddIcon

 private static void AddIcon(AvalonEditTextOutput output, BitmapFrame frame)
 {
   output.AddUIElement(() => new Image { Source = frame });
 }
开发者ID:Gobiner,项目名称:ILSpy,代码行数:4,代码来源:IconResourceEntryNode.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Imaging.BitmapImage类代码示例发布时间:2022-05-26
下一篇:
C# Effects.PixelShader类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap