Cor, Peter and Jeff,
> The getting an thumbnail from an image is an already long existing method
> from image
>
> http://msdn.microsoft.com/en-us/libr...nailimage.aspx
Thank you for help.
I have almost zero experience using System.Drawing
I tried to create conversion function using sample from
http://blog.rileytech.net/post/2008/...-ninjitsu.aspx
but got 3 strange compile errors shown in comments.
How to fix them ?
Andrus.
// converts jpeg image to jpeg thumbnail
Byte[] MakeMeAGoodThumbnail(Byte[] source)
{
// Argument '1': cannot convert from 'byte[]' to 'string'
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(source);
int width, height;
if (bmp.Height > 320 || bmp.Width > 240)
{
float percent = DeterminePercentageForResize(bmp.Height,
bmp.Width);
float floatWidth = (float)bmp.Width * percent;
float floatHeight = (float)bmp.Height * percent;
width = Convert.ToInt32(floatWidth);
height = Convert.ToInt32(floatHeight);
}
else
{
width = bmp.Width;
height = bmp.Height;
}
//Argument '3': cannot convert from 'bool' to
'System.Drawing.Image.GetThumbnailImageAbort' I:\raamat\Eeva\Eeva
Business\EntityBase\EntityBase.cs 890 79 Business
System.Drawing.Image thumb = bmp.GetThumbnailImage(width,
height, ThumbnailCallback(), IntPtr.Zero);
// Cannot implicitly convert type 'System.Drawing.Bitmap' to
'byte[]'
return new Bitmap(thumb);
}
float DeterminePercentageForResize(int height, int width)
{
int highestValue;
if (height > width)
highestValue = height;
else
highestValue = width;
float percent = 100 / (float)highestValue;
if (percent > 1 && percent != 0)
throw new Exception("Percent cannot be greater than 1 or
equal to zero");
else
return percent;
}
public bool ThumbnailCallback()
{
return false;
}