This question is locked. New answers and comments are not allowed.
I cant upload images to the application
here is the code i am currently with
here is the code i am currently with
public
static void ImageResize(byte[] data, string desPath, int thumbWidth, int thumbHeight, long quality)
{
Stream stream = new MemoryStream(data);
var sourceBitmap = new Bitmap(stream);
var thumbBitmap = new Bitmap(thumbWidth, thumbHeight);
var g = Graphics.FromImage(thumbBitmap);
try
{
g.InterpolationMode =
InterpolationMode.HighQualityBicubic;
g.FillRectangle(
Brushes.White, 0, 0, thumbWidth, thumbHeight);
g.DrawImage(sourceBitmap, 0, 0, thumbWidth, thumbHeight);
var info = ImageCodecInfo.GetImageEncoders();
var param = new EncoderParameters(1);
param.Param[0] =
new EncoderParameter(Encoder.Quality, quality);
string folderToUp = desPath.Substring(0, desPath.LastIndexOf("/") + 1);
try
{
if (Directory.Exists(folderToUp) == false)
{
Directory.CreateDirectory(folderToUp);
}
}
catch
{
}
thumbBitmap.Save(desPath, info[1], param);
}
finally
{
sourceBitmap.Dispose();
thumbBitmap.Dispose();
g.Dispose();
}
}
let me know the flaws of the code too