- Resizing the image width/height.
- Change image format.
- Decrease image quality to decrease image size.
- We will declare variable for new image width, height, Quality(1-100), extension.
- Create Bitmap from physical file or stream.
- Initialize new bitmap using new width and height.
- Initialize graphic from new image.
- Draw old image with new width and height to new image variable.
- Before we save image we need get encoder of its new type.
- Last step will save image with its new configurations:
|
|
|
|
EncoderParameters imgParams = new EncoderParameters(1); imgParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality,Quality); ImageCodecInfo ici = GetEncoderInfo(sMime); ImageCodecInfo newici = GetEncoderInfo(sNewMime); imgBitMap.Save(newstream, newici,imgParams); |