Csharp/C Sharp by API/System.Drawing.Imaging/ImageAttributes — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 12:10, 26 мая 2010
ImageAttributes.SetColorMatrix
using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing.Printing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Bitmap bmp = new Bitmap("alphabet.gif");
Graphics g = e.Graphics;
float[][] matrixItems = {
new float[] {0.2f, 0, 0, 0, 0},
new float[] {0, 0.8f, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}};
ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
ImageAttributes imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
TextureBrush tb = new TextureBrush(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), imageAtt);
tb.WrapMode = WrapMode.Tile;
g.FillRectangle(tb, this.ClientRectangle);
bmp.Dispose();
tb.Dispose();
}
public static void Main() {
Application.Run(new Form1());
}
}
new ImageAttributes()
using System;
using System.Collections.Generic;
using System.ruponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Drawing.Printing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Bitmap bmp = new Bitmap("alphabet.gif");
Graphics g = e.Graphics;
float[][] matrixItems = {
new float[] {0.2f, 0, 0, 0, 0},
new float[] {0, 0.8f, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}};
ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
ImageAttributes imageAtt = new ImageAttributes();
imageAtt.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
TextureBrush tb = new TextureBrush(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), imageAtt);
tb.WrapMode = WrapMode.Tile;
g.FillRectangle(tb, this.ClientRectangle);
bmp.Dispose();
tb.Dispose();
}
public static void Main() {
Application.Run(new Form1());
}
}