首页 > 其他分享 >opencv sharp MatToBitmapSource

opencv sharp MatToBitmapSource

时间:2023-03-06 13:33:18浏览次数:51  
标签:gray mat BitmapSource Width opencv MatToBitmapSource pf sharp

        private BitmapSource MatToBitmapSource(Mat mat, ref byte[] gray)
        {
            PixelFormat pf = PixelFormats.Gray8;
            int rawStride = (mat.Width * pf.BitsPerPixel + 7) / 8;
            mat.GetArray(out gray);
            return BitmapSource.Create(mat.Width, mat.Height, 96, 96, pf, null, gray, rawStride);
        }
        private BitmapSource MatToBitmapSource(Mat mat, ref ushort[] gray)
        {
            PixelFormat pf = PixelFormats.Gray16;
            int rawStride = (mat.Width * pf.BitsPerPixel + 7) / 8;
            mat.GetArray(out gray);
            return BitmapSource.Create(mat.Width, mat.Height, 96, 96, pf, null, gray, rawStride);
        }

 

标签:gray,mat,BitmapSource,Width,opencv,MatToBitmapSource,pf,sharp
From: https://www.cnblogs.com/lizhiqiang0204/p/17183521.html

相关文章