网站的图片分割问题
下面是我参考的一位大虾的代码,是图片分割的代码。
我是想问代码中的Cropwidth和Cropheight如何确定的。
请问还有其它的方法能把图片分割吗,比如把一张图片分割成9部分,再组合在一起,成为一个9宫图。
public class CropImageManipulator
{
public CropImageManipulator()
{
}
// 不含扩展名的文件名
private string _fileNameWithoutExtension;
// 文件扩展名
private string _fileExtension;
// 文件所属的文件夹
private string _fileDirectory;
public string Cropping(string inputImgPath, int cropWidth, int cropHeight)
{
this._fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(inputImgPath);
this._fileExtension = System.IO.Path.GetExtension(inputImgPath);
this._fileDirectory = System.IO.Path.GetDirectoryName(inputImgPath);
// 装载要分隔的图片
Image inputImg = Image.FromFile(inputImgPath);
int imgWidth = inputImg.Width;
int imgHeight = inputImg.Height;
// 计算要分几格
int widthCount = (int)Math.Ceiling((imgWidth * 1.00) / (cropWidth * 1.00));
int heightCount = (int)Math.Ceiling((imgHeight * 1.00) / (cropHeight * 1.00));
//----------------------------------
ArrayList areaList = new ArrayList();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<table cellpadding='0' cellspacing='0' border='[$border]'>");
sb.Append(System.Environment.NewLine);
int i = 0;
for (int iHeight = 0; iHeight < heightCount ; iHeight ++)
{
sb.Append("<tr>");
sb.Append(System.Environment.NewLine);
for (int iWidth = 0; iWidth < widthCount ; iWidth ++)
{
//string fileName = "<img src='<a target="_blank" href="http://localhost/SRcommBeijingFile/%22">http://localhost/SRcommBeijingFile/"</a> + this._fileNameWithoutExtension + " _" + i.ToString() + this._fileExtension + "'>";
string fileName = string.Format("<img src='<a target="_blank" href="http://localhost/SRcommBeijingFile/%7B0%7D_%7B1%7D%7B2%7D">http://localhost/SRcommBeijingFile/{0}_{1}{2}'</a> />",this._fileNameWithoutExtension,i,this._fileExtension);
sb.Append("<td>" + fileName + "</td>");
sb.Append(System.Environment.NewLine);
int pointX = iWidth * cropWidth;
int pointY = iHeight * cropHeight;
int areaWidth = ((pointX + cropWidth) > imgWidth) ? (imgWidth - pointX) : cropWidth;
int areaHeight = ((pointY + cropHeight) > imgHeight) ? (imgHeight - pointY) : cropHeight;
string s = string.Format("{0};{1};{2};{3}",pointX,pointY