首页 新闻 会员 周边

byte[] 复制到bitmap,图像错位怎么解决?

0
悬赏园豆:200 [已关闭问题] 关闭于 2010-04-01 23:18

byte[]数据里面没有文件头,只有数据,但复制到bitmap里后,图像错位了,怎么解决?

图像是31*31,16位1a5r5g5b

请给个.net 平台下的解决办法

问题补充: 抱歉大家,没写明是什么的,是winform的
四条腿的人马的主页 四条腿的人马 | 初学一级 | 园豆:0
提问于:2010-03-20 17:46
< >
分享
所有回答(2)
0

byte[] bb;
           
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bb);
        System.Drawing.Bitmap image = new System.Drawing.Bitmap(31, 31);

            image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

       context.Response.ClearContent();
            context.Response.ContentType = "image/Jpeg";
            context.Response.BinaryWrite(ms.GetBuffer());

            ms.Close();
            ms = null;
            image.Dispose();
            image = null;

你把这个图像输出到页面上,看看还错不错位

ForFreeDom | 园豆:589 (小虾三级) | 2010-03-20 20:10
0

Bitmap   b   =   new   Bitmap("test.bmp");  
  MemoryStream   ms   =   new   MemoryStream();  
  b.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp);  
  byte[]   bytes=   ms.ToArray();  
   
  b.Save("c:\\dd3.jpg");  
   
  byte[]   bytelist=bytes;  
  MemoryStream   ms1   =   new   MemoryStream(bytelist);  
  Bitmap   bm   =   (Bitmap)Image.FromStream(ms1);  
   
  bm.Save("c:\\dd4.jpg");  

查尔斯 | 园豆:3832 (老鸟四级) | 2010-03-21 14:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册