C#备忘录

1、Bitmap的保存像素到bmp图片文件(1)纯像素数组拷贝;2)图片格式读取到有格式的流再拷贝到另一个Bitmap)

    1)Rectangle rect = new Rectangle(0, 0, xtCamaraConnect.PixelWidth, xtCamaraConnect.PixelHeight);
          Bitmap bitmap = new Bitmap(xtCamaraConnect.PixelWidth, xtCamaraConnect.PixelHeight,System.Drawing.Imaging.PixelFormat.Format32bppArgb);
          System.Drawing.Imaging.BitmapData data = bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat);
          Marshal.Copy(ColorData, 0, data.Scan0, ColorData.Length );
          bitmap.UnlockBits(data);
          bitmap.Save("cccc.bmp"  );

    2)byte[] aa = new byte[100*100*4];
          //Buffer.BlockCopy( ColorData, 0, aa, 0, ColorData.Length*4);
          stream = new System.IO.MemoryStream(aa);
  Bitmap image = (Bitmap)Image.FromFile("未命名.bmp");//.FromStream(stream);
          image.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);

  Bitmap image2 = (Bitmap)Image.FromStream(stream);
          image.Save("sss.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
          byte[] bb = stream.ToArray();
          Console.WriteLine(bb[0] + " " + bb[1] + " " + bb[2] + " " + bb[3]);


2)c# 解析JSON的几种办法 (JavaScriptSerializer要用Net.4.0 不是Client Profile)    http://www.cnblogs.com/ambar/archive/2010/07/13/parse-json-via-csharp.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值