欢迎来到天天文库
浏览记录
ID:38805365
大小:28.00 KB
页数:4页
时间:2019-06-19
《简单的C#图片压缩类-winform》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#regionC#图片处理功能--BYDREAMDLM/*{*******************************************************************}{ }{ C#图片处理功能-DREAMDLM }{ }{*******************************************************************}*/#e
2、ndregionusingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Drawing;usingSystem.Drawing.Imaging;usingSystem.IO;usingSystem.Windows.Forms;namespaceEU.EUClass{ classImgGDI { publicImgGDI() { //构造函数 } /// ///Bitmap转换byte[]数组 ///<
3、/summary> /// /// publicbyte[]Bmptobyte(Bitmapbmp) { MemoryStreamms=newMemoryStream(); bmp.Save(ms,ImageFormat.Jpeg); ms.Flush(); byte[]buffer=ms.GetBuffer(); ms.Close(); returnbuffer; } //
4、/ ///byte[]数组转换Bitmap /// /// /// publicBitmapbytetobmp(byte[]buffer) { MemoryStreamms=newMemoryStream(); ms.Write(buffer,0,buffer.Length); Bitmapbmp=newBitmap(ms); ms.Close();
5、 returnbmp; } /// ///返回默认图片 /// /// publicBitmapgetInstance() { Bitmapbmp=DefaultPic(); returnbmp; } /// ///选取本地图片 /// /// ///
6、 publicBitmapLocalIMG(stringIMG) { FileStreamfs=newFileStream(IMG,FileMode.Open); Bitmapbmp=newBitmap(fs); fs.Close(); returnbmp; } /// ///返回流状态图片 /// /// /// publicBitmapI
7、mgFromBase64(stringImg) { Bitmapbmp; byte[]buffer=Convert.FromBase64String(Img); if(buffer.Length>0) { MemoryStreamms=newMemoryStream(); ms.Write(buffer,0,buffer.Length); bmp=newBitmap(ms); ms.Close(); returnbmp; }
8、 else { bmp=DefaultP
此文档下载收益归作者所有