📄 impslicetransform.cs
字号:
namespace Imps.Utils
{
using System;
using System.Drawing;
public class ImpSliceTransform : IImageTransform
{
private int _height;
private System.Drawing.Point _point;
private System.Drawing.Size _size;
private int _width;
private int _x;
private int _y;
public ImpSliceTransform(Rectangle rectangle) : this(rectangle.X, rectangle.Y, rectangle.Size)
{
}
public ImpSliceTransform(System.Drawing.Point point, System.Drawing.Size size) : this(point, size.Width, size.Height)
{
this._point = point;
this._size = size;
}
public ImpSliceTransform(System.Drawing.Point point, int width, int height) : this(point.X, point.Y, width, height)
{
}
public ImpSliceTransform(int x, int y, System.Drawing.Size size) : this(x, y, size.Width, size.Height)
{
}
public ImpSliceTransform(int x, int y, int width, int height)
{
this._x = x;
this._y = y;
this._width = width;
this._height = height;
}
public IImage Transform(IImage image)
{
IImage image3;
if (this._x <= image.Width)
{
int height = image.Height;
int num2 = this._y;
}
IImage image2 = null;
try
{
image2 = (IImage) image.Clone();
using (Bitmap bitmap = new Bitmap(this._width, this._height, image.Image.PixelFormat))
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.DrawImage(image.Image, this.DestRectangle, this.SourceRectangle, GraphicsUnit.Pixel);
}
image2.Image = bitmap;
}
image3 = image2;
}
catch (Exception exception)
{
if (image2 != null)
{
image2.Dispose();
}
throw exception;
}
return image3;
}
public Rectangle DestRectangle
{
get
{
return new Rectangle(0, 0, this._width, this._height);
}
}
public int Height
{
get
{
return this._height;
}
set
{
this._height = value;
}
}
public System.Drawing.Point Point
{
get
{
return new System.Drawing.Point(this._x, this._y);
}
}
public System.Drawing.Size Size
{
get
{
return new System.Drawing.Size(this._width, this._height);
}
}
public Rectangle SourceRectangle
{
get
{
return new Rectangle(this._x, this._y, this._width, this._height);
}
}
public int Width
{
get
{
return this._width;
}
set
{
this._width = value;
}
}
public int X
{
get
{
return this._x;
}
set
{
this._x = value;
}
}
public int Y
{
get
{
return this._y;
}
set
{
this._y = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -