[csharp]
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Common
{
/// <summary>
/// 图片处理 基础类
/// </summary>
public class ImagePS
{
public static Bitmap GetControlBmp(Control ctrl, int offsetX, int offsetY)
{
Graphics myGraphics = ctrl.CreateGraphics();
Rectangle r = ctrl.RectangleToScreen(ctrl.Bounds);
Bitmap memoryImage = new Bitmap(r.Width, r.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(r.X - offsetX, r.Y - offsetY, 0, 0, new Size(r.Width, r.Height));
return memoryImage;
}
/// <summary>
/// 色相类型,红,绿,蓝
/// </summary>
public enum ColorFilterType
{
Red, Green, Blue
}
/// <summary>
/// 底片效果
/// </summary>
/// <param name="img">图片</param>
/// <returns>处理后的图片</returns>
public static Bitmap ReImg(Bitmap img)
{
byte r, g, b;
for (int i = 0; i < img.Width; i++)
{
for (int j = 0; j < img.Height; j++)
{
r = (byte)(255 - img.GetPixel(i, j).R);
g = (byte)(255 - img.GetPixel(i, j).G);