Bitmap To byte[]
/// <summary> /// Bitmap To byte[] /// </summary> /// <param name="bp">需转化的Bitmap图像</param> /// <returns>byte[]</returns> public static byte[] BitmapToBytes(Bitmap bp) { if (bp != null) { int w = bp.Width, h = bp.Height; byte[] byteImage = new byte[w * h]; int index = 0; PointBitmap point_bmp = new PointBitmap(bp); point_bmp.LockBits(); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { byteImage[index] = point_bmp.GetPixel(x, y).R; index++; } } point_bmp.UnlockBits(); return byteImage; } return null; }
需要指针法基类配合使用

浙公网安备 33010602011771号