日期:2014-05-17 浏览次数:20736 次
public static byte[] BitmapToByte(Bitmap A_0) { if (A_0 == null) { return null; } BitmapData bitmapdata = A_0.LockBits(new Rectangle(new System.Drawing.Point(), A_0.Size), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); int length = bitmapdata.Stride * A_0.Height; byte[] destination = new byte[length]; Marshal.Copy(bitmapdata.Scan0, destination, 0, length); A_0.UnlockBits(bitmapdata); return destination; } public static string ByteToStr(byte[] A_0) { if (A_0 == null) { return ""; } string str = ""; if (A_0 != null) { for (int i = 0; i < A_0.Length; i++) { str = str + A_0[i].ToString("X2"); } } return str; }