hi
this is my code it is for resizing image
public string img_resize(string picname, int maxHeight, int maxWidth)
{
System.Drawing.Image currentImage = System.Drawing.Image.FromFile(Server.MapPath("image/house\\") + picname);
double imgHeight = 0;
double imgWidth = 0;
imgHeight = currentImage.Height;
imgWidth = currentImage.Width;
if (imgWidth > maxWidth | imgHeight > maxHeight)
{
//Determine what dimension is off by more
double deltaWidth = imgWidth - maxWidth;
double deltaHeight = imgHeight - maxHeight;
double scaleFactor = 0;
if (deltaHeight > deltaWidth)
{
//Scale by the height
scaleFactor = maxHeight / imgHeight;
}
else
{
//Scale by the Width
scaleFactor = maxWidth / imgWidth;
}
imgWidth *= scaleFactor;
imgHeight *= scaleFactor;
}
string html = null;
if (imgHeight != currentImage.Height | imgWidth != currentImage.Width) {
html = "<a href=\"" + IMAGE_DIRECTORY + Path.GetFileName(s) + "\">" + "<img src=\"ShowThumbnail.aspx?img=" + Path.GetFileName(s) + "&w=" + imgWidth + "&h=" + imgHeight + "\" " + "height=\"" + imgHeight + "\" width=\"" + imgWidth + "\" border=1>" + "</a>";
} else {
html = "<a href=\"" + IMAGE_DIRECTORY + Path.GetFileName(s) + "\">" + "<img src=\"ShowThumbnail.aspx?img=" + Path.GetFileName(s) + "\" " + "height=\"" + imgHeight + "\" width=\"" + imgWidth + "\" border=1>" + "</a>";
}
return html;
when i run it this error occur
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'IMAGE_DIRECTORY' does not exist in the current context
Source Error:
|
Line 84:
Line 85: if (imgHeight != currentImage.Height | imgWidth != currentImage.Width) {
Line 86: html = "<a href=\"" + IMAGE_DIRECTORY + Path.GetFileName(s) + "\">" + "<img src=\"ShowThumbnail.aspx?img=" + Path.GetFileName(s) + "&w=" + imgWidth + "&h=" + imgHeight + "\" " + "height=\"" + imgHeight + "\" width=\"" + imgWidth + "\" border=1>" + "</a>"; Line 87: } else {
Line 88:
|
best regards