P
Phil Johnson
Hi,
I am working on an ASP.NET 1.1 application that creates thumbnails using the
code below.
Problem is that the code loads an entire file into memory to instantiate the
image (file.Data is a memorystream).
This obviously isnt feasible for large files. Does anybody know of a
thumbnail component that doesn't load the entire file into memory?
Image fullImage = Image.FromStream(file.Data);
// maximum height or width is 100
double imgWidth = Convert.ToDouble(fullImage.Width);
double imHeight = Convert.ToDouble(fullImage.Height);
double divisor = 0;
if(fullImage.Height > fullImage.Width)
{
divisor = (100/imHeight);
}
else
{
divisor = (100/imgWidth);
}
Image thumbnail =
fullImage.GetThumbnailImage(Convert.ToInt32(imgWidth*divisor),
Convert.ToInt32(imHeight*divisor),
new System.Drawing.Image.GetThumbnailImageAbort(rtnVal.ThumbnailCallback),
IntPtr.Zero);
--
Regards,
Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com
I am working on an ASP.NET 1.1 application that creates thumbnails using the
code below.
Problem is that the code loads an entire file into memory to instantiate the
image (file.Data is a memorystream).
This obviously isnt feasible for large files. Does anybody know of a
thumbnail component that doesn't load the entire file into memory?
Image fullImage = Image.FromStream(file.Data);
// maximum height or width is 100
double imgWidth = Convert.ToDouble(fullImage.Width);
double imHeight = Convert.ToDouble(fullImage.Height);
double divisor = 0;
if(fullImage.Height > fullImage.Width)
{
divisor = (100/imHeight);
}
else
{
divisor = (100/imgWidth);
}
Image thumbnail =
fullImage.GetThumbnailImage(Convert.ToInt32(imgWidth*divisor),
Convert.ToInt32(imHeight*divisor),
new System.Drawing.Image.GetThumbnailImageAbort(rtnVal.ThumbnailCallback),
IntPtr.Zero);
--
Regards,
Phillip Johnson (MCSD For .NET)
PJ Software Development
www.pjsoftwaredevelopment.com