zoukankan      html  css  js  c++  java
  • System.Drawing.image 与ImageSource 互转

    private BitmapSource bs(Bitmap bt)
    {
    IntPtr ip = bt.GetHbitmap();
    BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
    ip, IntPtr.Zero, Int32Rect.Empty,
    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
    DeleteObject(ip);
    return bitmapSource;
    }



    public System.Drawing.Bitmap WpfBitmapSourceToBitmap(BitmapSource s)
            {
                System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(s.PixelWidth, s.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                System.Drawing.Imaging.BitmapData data = bmp.LockBits(new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size),
     System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                s.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride);
                bmp.UnlockBits(data);
                return bmp;
            }
  • 相关阅读:
    九九乘法表
    杨辉三角
    显示计算机界面
    完善3.2
    杨辉三角形
    100以内的素数
    九九乘法表
    杨辉三角
    九九乘法表
    杨辉三角形
  • 原文地址:https://www.cnblogs.com/hongsedigua/p/3780014.html
Copyright © 2011-2022 走看看