我正在调整上传图片的大小,如下所示:
var bmPhoto = new Bitmap(width, height, PixelFormat.Format16bppRgb555);
using (var grPhoto = Graphics.FromImage(bmPhoto))
{
grPhoto.SmoothingMode = SmoothingMode.HighSpeed;
grPhoto.CompositingQuality = CompositingQuality.HighSpeed;
grPhoto.InterpolationMode = InterpolationMode.Low;
grPhoto.DrawImage(sourceImage, new Rectangle(destX, destY, destWidth, destHeight),
new Rectangle(0, 0, sourceWidth, sourceHeight), GraphicsUnit.Pixel);
}
如何限制生成的文件大小,使其不超过3KB?我正在上传1024x768 JPG,即768KB。使用上面的代码调整大小为100x100时,我不能小于12KB。