/// <summary>
/// Summary description for ImageManage
/// </summary>
public class ImageManager
{
public static string BLANK = "_blank";
public static string PARENT = "_parent";
public static string SEARCH = "_search";
public static string SELF = "_self";
public static string TOP = "_top";
public static string GetImageFormat(string imagePath,string serverPath, int width, int height)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth +
"px;border-width:0px;\" />";
return returnString;
}
public static string GetImageFormat(string imagePath, string serverPath, int width, int height, string url)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<a target=\"_blank\" href=\"" + url + "\"><img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth +
"px;border-width:0px;\" /></a>";
return returnString;
}
public static string GetImageFormat(string imagePath, string serverPath, int width, int height, string target, string url)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<a target=\"" + target + "\" href=\"" + url + "\"><img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth +
"px;border-width:0px;\" /></a>";
return returnString;
}
public static string GetImageFormatWithTable(string imagePath, string serverPath, int width, int height)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
+ "\r\n <tr>"
+ "\r\n <td align=\"center\" valign=\"middle\" style=\"width: " + width + "px; height: " + height + "px; background-color: white;\">"
+ "\r\n <img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth + "px;border-width:0px;\" />"
+ "\r\n </td>"
+ "\r\n </tr>"
+ "\r\n </table>";
return returnString;
}
public static string GetImageFormatWithTable(string imagePath, string serverPath, int width, int height, string url)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
+ "\r\n <tr>"
+ "\r\n <td align=\"center\" valign=\"middle\" style=\"width: " + width + "px; height: " + height + "px; background-color: white;\">"
+ "\r\n <a target=\"_blank\" href=\"" + url + "\">"
+ "\r\n <img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth + "px;border-width:0px;\" />"
+ "\r\n </a></td>"
+ "\r\n </tr>"
+ "\r\n </table>";
return returnString;
}
public static string GetImageFormatWithTable(string imagePath, string serverPath, int width, int height, string target, string url)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(serverPath);
int imgWidth = img.Width;
int imgHeight = img.Height;
int showWidth;
int showHeight;
if (imgWidth <= width && imgHeight <= height)
{
showWidth = imgWidth;
showHeight = imgHeight;
}
else
{
if (imgWidth / width > imgHeight / height)
{
showWidth = width;
showHeight = width * imgHeight / imgWidth;
}
else
{
showHeight = height;
showWidth = imgWidth * height / imgHeight;
}
}
string returnString = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"
+ "\r\n <tr>"
+ "\r\n <td align=\"center\" valign=\"middle\" style=\"width: " + width + "px; height: " + height + "px; background-color: white;\">"
+ "\r\n <a target=\"" + target + "\" href=\"" + url + "\">"
+ "\r\n <img src=\"" + imagePath + "\" style=\"height:" + showHeight + "px;width:" + showWidth + "px;border-width:0px;\" />"
+ "\r\n </a></td>"
+ "\r\n </tr>"
+ "\r\n </table>";
return returnString;
}
}

浙公网安备 33010602011771号