Exemple #1
0
        public static bool Reshape(ref MemoryBitmap dst, GDIPTR src, INTEROPFMT?fmtOverride = null)
        {
            if (src == null)
            {
                dst = default; return(true);
            }

            BitmapInfo binfo;

            if (fmtOverride.HasValue)
            {
                binfo = new BitmapInfo(src.Width, src.Height, fmtOverride.Value);
            }
            else if (TryGetExactPixelFormat(src.PixelFormat, out var fmt))
            {
                binfo = new BitmapInfo(src.Width, src.Height, fmt);
            }
            else
            {
                throw new ArgumentException(nameof(src));
            }

            return(MemoryBitmap.Reshape(ref dst, binfo));
        }