コード例 #1
0
ファイル: ImageIO.cs プロジェクト: goupviet/dot-imaging
        unsafe static TColor[,] decodeImage <TColor>(byte[] encodedImage, ImageLoadType loadType)
        where TColor : unmanaged, IColor
        {
            CvMat *matDecoded;

            fixed(byte *encodedImPtr = encodedImage)
            {
                CvMat mat = CvMat.FromUserData((IntPtr)encodedImPtr, encodedImage.Length, 1, encodedImage.Length, CvMat.CvChannelDepth.CV_8U, 1);

                matDecoded = CvInvoke.cvDecodeImageM(&mat, ImageLoadType.Color);
            }

            var imDecoded = (*matDecoded).ToArray <TColor>();

            CvInvoke.cvReleaseMat(ref matDecoded);

            return(imDecoded);
        }
コード例 #2
0
ファイル: CvMat.cs プロジェクト: valerysntx/dot-imaging
        /// <summary>
        /// Represents the existing image as CvMat structure where data is shared.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <returns>CvMat representation.</returns>
        public static CvMat AsCvMat(this IImage image)
        {
            var depthType = typeConversion[image.ColorInfo.ChannelType];

            return(CvMat.FromUserData(image.ImageData, image.Width, image.Height, image.Stride, depthType, image.ColorInfo.ChannelCount));
        }