예제 #1
0
파일: Bytemap.cs 프로젝트: maplewei/MyCaffe
        /// <summary>
        /// Converts a bitmap into a new Bytemap.
        /// </summary>
        /// <param name="bmp">Specifies the bitmap.</param>
        /// <returns>A new Bytemap is returned.</returns>
        public static Bytemap FromImage(Bitmap bmp)
        {
            Bytemap    data = new Bytemap(3, bmp.Height, bmp.Width);
            LockBitmap bmpA = new LockBitmap(bmp);

            bmpA.LockBits();

            for (int y = 0; y < bmp.Height; y++)
            {
                for (int x = 0; x < bmp.Width; x++)
                {
                    Color clr = bmpA.GetPixel(x, y);
                    data.SetPixel(x, y, clr);
                }
            }

            bmpA.UnlockBits();

            return(data);
        }