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;
&
相关文档:
一、首先先添加引用 using Microsoft.Win32;
//因为操作注册表的两个类RegistryKey和Registry都包含在此引用中;
二、编写代码开始操作注册表
1、 #region 限制软件的使用次数
pri ......
接上一篇
显示所有结点的内容
1 原xml文件 bookstore.xml
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book ISBN="1234123">
<title>who am i </title>
<author>who</author>
<price> ......
DBHelper:
/// <summary>
/// 执行查询
/// </summary>
/// <param name="sql">有效的select语句</param ......
提高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 ......