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


C# System.GetHbitmap方法代码示例

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


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

示例1: LoadBitmap

 public static BitmapSource LoadBitmap(System.Drawing.Bitmap source)
 {
     handle = source.GetHbitmap();
     bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(handle, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
     DeleteObject(handle);
     return bitmapSource;
 }
开发者ID:boo1ean,项目名称:bom-bom,代码行数:7,代码来源:PictureHelper.cs

示例2: LoadBitmap

 public static BitmapSource LoadBitmap(System.Drawing.Bitmap source)
 {
     var ip = source.GetHbitmap();
     var bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
     DeleteObject(ip);
     return bs;
 }
开发者ID:beaglebot,项目名称:BeagleBot,代码行数:7,代码来源:CameraControl.xaml.cs

示例3: Bitmap2BitmapImage

        public static BitmapImage Bitmap2BitmapImage(System.Drawing.Bitmap bitmap)
        {
            IntPtr hBitmap = bitmap.GetHbitmap();
            BitmapSource bmpSource;
            BitmapImage bitmapImage = new BitmapImage();

            try
            {
                bmpSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                             hBitmap,
                             IntPtr.Zero,
                             Int32Rect.Empty,
                             BitmapSizeOptions.FromEmptyOptions());

                BitmapEncoder enc = new BmpBitmapEncoder();
                MemoryStream memoryStream = new MemoryStream();

                enc.Frames.Add(BitmapFrame.Create(bmpSource));
                enc.Save(memoryStream);

                memoryStream.Position = 0;
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = memoryStream;
                bitmapImage.EndInit();
            }
            finally
            {
                DeleteObject(hBitmap);
            }

            return bitmapImage;
        }
开发者ID:sipsorcery,项目名称:sipsorcery,代码行数:32,代码来源:UIHelper.cs

示例4: loadBitmap

 public static BitmapSource loadBitmap(System.Drawing.Bitmap source)
 {
     return System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(source.GetHbitmap(), IntPtr.Zero,
                                                                         Int32Rect.Empty,
                                                                         System.Windows.Media.Imaging
                                                                               .BitmapSizeOptions
                                                                               .FromEmptyOptions());
 }
开发者ID:gdlprj,项目名称:duscusys,代码行数:8,代码来源:CustomColorSelector.xaml.cs

示例5: ConvertGDI_To_WPF

 /// <summary>
 /// Convert GDI bitmap into a WPF BitmapSource
 /// </summary>
 /// <param name="source"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <returns></returns>
 public static BitmapSource ConvertGDI_To_WPF(System.Drawing.Bitmap bmp)
 {
     BitmapSource bms = null;
     if (bmp != null)
     {
         IntPtr h_bm = bmp.GetHbitmap();
         bms = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(h_bm, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
     }
     return bms;
 }
开发者ID:Corillian,项目名称:Windows-API-Code-Pack-1.1,代码行数:17,代码来源:StarBackupHelper.cs

示例6: ToImageSource

		public static ImageSource ToImageSource(System.Drawing.Bitmap bitmap) {
			var hbitmap = bitmap.GetHbitmap();
			try {
				var imageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromWidthAndHeight(bitmap.Width, bitmap.Height));

				return imageSource;
			} finally {
				DeleteObject(hbitmap);
			}
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:10,代码来源:Utils.cs

示例7: BitmapToBitmapSource

        public static BitmapSource BitmapToBitmapSource(System.Drawing.Bitmap bitmap)
        {
            intPointer = bitmap.GetHbitmap();

            bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(intPointer,
                IntPtr.Zero,
                System.Windows.Int32Rect.Empty,
                System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

            DeleteObject(intPointer);
            return bitmapSource;
        }
开发者ID:adolescent,项目名称:gazetest,代码行数:12,代码来源:ConvertBitmap.cs

示例8: ToBitmapSource

        private static BitmapSource ToBitmapSource(System.Drawing.Bitmap source)
        {
            BitmapSource bitSrc = null;

            var hBitmap = source.GetHbitmap();
            bitSrc = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                hBitmap,
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());
            return bitSrc;
        }
开发者ID:Elinos,项目名称:TelerikAcademy,代码行数:12,代码来源:ImportFilesWindow.xaml.cs

示例9: convertBitmapToBitmapSource

        public static ImageSource convertBitmapToBitmapSource(System.Drawing.Bitmap bitmap)
        {
            using (bitmap)
            {
                System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    bitmap.GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());

                return bitmapSource;
            }
        }
开发者ID:zebulon75018,项目名称:photochoicetouch,代码行数:13,代码来源:EffectBitmap.cs

示例10: SetImageSource

        private void SetImageSource(System.Drawing.Bitmap bmp)
        {
            if (bmp == null)
                return;

            // how to convert a bitmap to an imagesource http://blog.laranjee.com/how-to-convert-winforms-bitmap-to-wpf-imagesource/ 
            // TODO - watch out for memory leaks using system.drawing.bitmaps in managed code, see here http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/4e213af5-d546-4cc1-a8f0-462720e5fcde
            // need to call Dispose manually somewhere, or perhaps use a WPF native structure instead of bitmap?

            var hbitmap = bmp.GetHbitmap();
            var imageSource = Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(bmp.Width, bmp.Height));
            image.Source =  imageSource;
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:13,代码来源:WatchImage.cs

示例11: BitmapToImageSource

        /// <summary>
        /// 从Bitmap创建可供WPF Image控件使用的BitmapSource对象
        /// </summary>
        /// <param name="bitmap"></param>
        /// <returns></returns>
        public static BitmapSource BitmapToImageSource(System.Drawing.Bitmap bitmap)
        {
            BitmapSource destination;

            IntPtr hBitmap = bitmap.GetHbitmap();

            BitmapSizeOptions sizeOptions = BitmapSizeOptions.FromEmptyOptions();

            destination = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, System.Windows.Int32Rect.Empty, sizeOptions);

            destination.Freeze();

            return destination;
        }
开发者ID:HETUAN,项目名称:PersonalInfoForWPF,代码行数:19,代码来源:MySuperEditorHelper.cs

示例12: CamProc_NewTargetPosition

        void CamProc_NewTargetPosition(IntPoint Center, System.Drawing.Bitmap image)
        {
            IntPtr hBitMap = image.GetHbitmap();
            BitmapSource bmaps = Imaging.CreateBitmapSourceFromHBitmap(hBitMap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            bmaps.Freeze();
            Dispatcher.Invoke((Action)(() =>
            {

                if (Center.X > 0)
                {
                    try
                    {

                        prova.Content = String.Format("   Codigo: {0}", Center.X);
                        item.Content = String.Format(" Nº Itens: {0}", Center.Y);
                        TextReader respostas = new StreamReader(@"" + Center.X + ".txt");
                        string R_1 = respostas.ReadLine();
                        string R_2 = respostas.ReadLine();
                        string R_3 = respostas.ReadLine();
                        string R_4 = respostas.ReadLine();
                        string R_5 = respostas.ReadLine();
                        string R_6 = respostas.ReadLine();
                        string R_7 = respostas.ReadLine();
                        string R_8 = respostas.ReadLine();
                        string R_9 = respostas.ReadLine();
                        string R_0 = respostas.ReadLine();
                        item1.Content = String.Format(" Item 01: {0}", R_1);
                        item2.Content = String.Format(" Item 02: {0}", R_2);
                        item3.Content = String.Format(" Item 03: {0}", R_3);
                        item4.Content = String.Format(" Item 04: {0}", R_4);
                        item5.Content = String.Format(" Item 05: {0}", R_5);
                        item6.Content = String.Format(" Item 06: {0}", R_6);
                        item7.Content = String.Format(" Item 07: {0}", R_7);
                        item8.Content = String.Format(" Item 08: {0}", R_8);
                        item9.Content = String.Format(" Item 09: {0}", R_9);
                        item10.Content = String.Format(" Item 10: {0}", R_0);
                        string resps = R_1 + ";" + R_2 + ";" + R_3 + ";" + R_4 + ";" + R_5 + ";" + R_6 + ";" + R_7 + ";" + R_8 + ";" + R_9 + ";" + R_0;

                        refer.Content = String.Format("todas: {0}", resps);
                        conexao((int)Center.X, resps);
                        respostas.Close();
                    }
                    catch { }
                }
                pictureBoxMain.Source = bmaps;
            }), DispatcherPriority.Render, null);
            DeleteObject(hBitMap);
        }
开发者ID:jeffersonpp,项目名称:REPO,代码行数:48,代码来源:MainWindow.xaml.cs

示例13: loadBitmap

        public static BitmapSource loadBitmap(System.Drawing.Bitmap source)
        {
            IntPtr ip = source.GetHbitmap();
            BitmapSource bs = null;
            try
            {
                bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip,
                   IntPtr.Zero, Int32Rect.Empty,
                   System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
            }
            finally
            {
                DeleteObject(ip);
            }

            return bs;
        }
开发者ID:EbhlingDiaz,项目名称:KaraokeList2,代码行数:17,代码来源:KaraokeWindow.xaml.cs

示例14: ToWPFBitmap

        public static BitmapSource ToWPFBitmap(System.Drawing.Bitmap bitmap)
        {
            var hBitmap = bitmap.GetHbitmap();

            BitmapSource source;
            try
            {
                source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                    hBitmap, IntPtr.Zero, Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());
            }
            finally
            {
                DeleteObject(hBitmap);
            }
            return source;
        }
开发者ID:toydev,项目名称:ExampleCSharp,代码行数:17,代码来源:MainWindow.xaml.cs

示例15: TileSet

		public TileSet(System.Drawing.Bitmap source, int tileWidth, int tileHeight)
		{
			_source = new WriteableBitmap(Imaging.CreateBitmapSourceFromHBitmap(
				source.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty,
				BitmapSizeOptions.FromWidthAndHeight(source.Width, source.Height)));

			TileWidth = tileWidth;
			TileHeight = tileHeight;
			_tilesPerRow = (int)_source.Width / TileWidth;

			_bytesPerPixel = _source.Format.BitsPerPixel / BITS_PER_BYTE;
			_stride = _source.PixelWidth * _bytesPerPixel;
			_originalPixels = new byte[_stride * _source.PixelHeight];
			_source.CopyPixels(_originalPixels, _stride, 0);

			_tiles = new List<CroppedBitmap>();
			GenerateTiles();
		}
开发者ID:treytomes,项目名称:wpf-console,代码行数:18,代码来源:TileSet.cs


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