博客园站长
这是人类成长进步中记录的每一时刻

//根据图片路径读取图片并且转byte[]   类型

                    FileStream fs = new FileStream(filePath, FileMode.Open);
                    byte[] byData = new byte[fs.Length];
                    fs.Read(byData, 0, byData.Length);
                    fs.Close();

 

//根据图片路径读取图片修改长宽 并且转byte[]   类型

            var pic = new Bitmap(filePath);
                    Bitmap newpic = new Bitmap((System.Drawing.Image)pic);                 
                    var savepic = new Bitmap(newpic, 100, 120);
                    MemoryStream ms = new MemoryStream();
                    savepic.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                    byte[] byData = ms.GetBuffer();  
                    ms.Close(); 

//byte[] 插入到数据库

http://www.cnblogs.com/wdw31210/p/3937417.html

 

posted on 2016-08-08 15:34  dm3344  阅读(732)  评论(0编辑  收藏  举报