GDI+入门(C#高速处理版本)
首先感谢CSDN的朋友laviewpbt为我给我的建议。
laviewpbt提出使用getpixel处理速度太慢,上不了档次。
这里我再给大家写两种处理速度更快的图形处理方式。
下面是个内存操作灰度的程序:
bmp = new Bitmap(Application.StartupPath + "\\1.jpg");
Bitmap bmp2 = (Bitmap)bmp.Clone();
int width = bmp2.Width;
int height = bmp2.Height;
Rectangle rect = new Rectangle(0, 0, width, height);
//用可读写的方式锁定全部位图像素
BitmapData bmpData = bmp2.LockBits(rect, ImageLockMode.ReadWrite, bmp2.PixelFormat);
//得到首地址
IntPtr ptr = bmpData.Scan0;
//24位bmp位图字节数
int bytes = width * height * 3;
byte[] rgbValues = new byte[bytes];
Marshal.Copy(ptr, rgbValues, 0, bytes);
//灰度化
double colorTemp = 0;
for (int i = 0; i < bytes; i += 3)
{
colorTemp = rgbValues[i + 2] * 0.299 + rgbValues[i + 1] * 0.587 + rgbValues[i] * 0.114;
&
相关文档:
private void save_db(){
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings[""].ToString());
SqlCommand comm = new SqlCommand();
conn.Open();
SqlTransaction rollbk2= conn.BeginTransaction();
& ......
1.添加命名空间引用
using System.Xml;
2.新建xml实例
public XmlDocument objXmlDoc = new XmlDocument();
3.加载Xml文档
string path=Server.Mappath("demo.xml");//得到文档路径
objXmlDoc.Load(path);//加载文档
4.查找要进行操作的结点
objXmlDoc.SelectNodes(xpath);//得到结点集合
objXmlDoc.SelectSingleN ......
提高C#编程水平的50个要点
1.总是用属性 (Property) 来代替可访问的数据成员
2.在 readonly 和 const 之间,优先使用 readonly
3.在 as 和 强制类型转换之间,优先使用 as 操作符
4.使用条件属性 (Conditional Attributes ......
C#利用webrequest计算待下载的文件大小
string URL = textBox1.Text;
string filetype = URL.Substring(URL.LastIndexOf(".") + 1, (URL.Length - URL.LastIndexOf(".") - 1));
filetypevalue.Text = filetype.ToUpper();
string filename = URL.Substring(URL.LastIn ......