.net下image数组使用
来源:互联网 发布:淘宝首页图片之间的缝 编辑:程序博客网 时间:2024/04/28 03:57
.
在VB年代有专门的IMAGE数组控件,在.NET下却没有了这个控件,只能自己来实现。今天看DEVEXPRESS代码摘出来学习了一下
public class ImageCollectionEditor
{
private Image GetImageFromCollection(Image iml, int width, int height, int wIndex, int hIndex)
{
Bitmap res = new Bitmap(width, height);
res.SetResolution(iml.HorizontalResolution, iml.VerticalResolution);
Graphics g = Graphics.FromImage(res);
g.DrawImage(iml, 0, 0, new Rectangle(width * wIndex, height * hIndex, width, height), GraphicsUnit.Pixel);
g.Dispose();
return res;
}
/**//// <summary>
/// 获取IMAGE数组
/// </summary>
/// <param name="sourceImage">源图片</param>
/// <param name="vertical">图片方向</param>
/// <param name="InnerList">IMAGELIST控件</param>
public virtual void AddImageStrip(Image sourceImage, bool vertical,ref System.Windows.Forms.ImageList InnerList)
{
Size size = new Size (18,18);
int index = 0;
for (int i = vertical ? sourceImage.Height : sourceImage.Width; i > 0; i -= vertical ? size.Height : size.Width)
{
InnerList.Images.Add(GetImageFromCollection(sourceImage, size.Width, size.Height, vertical ? 0 : index, vertical ? index : 0));
index++;
}
}
{
private Image GetImageFromCollection(Image iml, int width, int height, int wIndex, int hIndex)
{
Bitmap res = new Bitmap(width, height);
res.SetResolution(iml.HorizontalResolution, iml.VerticalResolution);
Graphics g = Graphics.FromImage(res);
g.DrawImage(iml, 0, 0, new Rectangle(width * wIndex, height * hIndex, width, height), GraphicsUnit.Pixel);
g.Dispose();
return res;
}
/**//// <summary>
/// 获取IMAGE数组
/// </summary>
/// <param name="sourceImage">源图片</param>
/// <param name="vertical">图片方向</param>
/// <param name="InnerList">IMAGELIST控件</param>
public virtual void AddImageStrip(Image sourceImage, bool vertical,ref System.Windows.Forms.ImageList InnerList)
{
Size size = new Size (18,18);
int index = 0;
for (int i = vertical ? sourceImage.Height : sourceImage.Width; i > 0; i -= vertical ? size.Height : size.Width)
{
InnerList.Images.Add(GetImageFromCollection(sourceImage, size.Width, size.Height, vertical ? 0 : index, vertical ? index : 0));
index++;
}
}
MSDN针对DrawImage 的解释
Graphics..::.DrawImage 方法 (Image, array<Point>[]()[])
在指定位置并且按指定形状和大小绘制指定的 Image。
命名空间: System.Drawing
程序集: System.Drawing(在 System.Drawing.dll 中)
C#
public void DrawImage(Image image,Point[] destPoints)
参数
- image
- 类型:System.Drawing..::.Image
要绘制的 Image。
- destPoints
- 类型:array<System.Drawing..::.Point>[]()[]
由三个 Point 结构组成的数组,这三个结构定义一个平行四边形。
DEMO下载
- .net下image数组使用
- 在.NET平台下使用SQL2000 Image类型数据
- 在.NET平台下使用SQL2000 Image类型数据
- asp.net中image控件的使用
- asp.net中image控件的使用
- 关于CCSv5 Debug下image功能使用
- Linux 下SDL2 image安装及使用
- Python下将数组/矩阵转换成Image类
- 使用ASP.NET Image Generation生成图片缩略图及水印
- asp.net使用服务器控件Image/ImageButton显示本地图片
- [VB.Net] 数组的使用
- Net二维数组的使用
- .Net下使用OpenCV
- .NET 下使用 log4net
- Validate Image Type Using Image GUID in ASP.NET(Asp.Net中使用图片GUID验证图片类型)
- eclipse下Image.CreateImage(string filename)的使用
- 关于CCSv5 Debug下image Analyzer功能使用
- .NET Upload & Download image
- SQL2005中关于XML新特性的学习(1)
- 在ASP.NET 中模拟简单数字注册码的生成
- SQL2005中关于XML新特性的学习(2)--创建XML索引及简单查询
- Wnsock编程初涉
- JSP标准标签库
- .net下image数组使用
- 逝去的日子
- 想念儿子
- 七句话被中国人误传了数千年的名言(转载)
- 如何做需求(新年第一篇博客,作为礼物送给博友)
- xvid API
- 关于原码、反码、补码(ZZ)
- 手机电视与奥运将擦肩而过
- equinox环境下web应用资源的部署[最后更新2008-02-27]