mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 19:50:11 -07:00
Fixed hard coded Encoder, if sometime the encoder order changes this would have broken the code. Also removed a stream wrapper.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2130 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
b600d72156
commit
5714b59a14
2 changed files with 16 additions and 9 deletions
|
@ -157,10 +157,19 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
|
||||
if (imageFormat == ImageFormat.Jpeg) {
|
||||
EncoderParameters parameters = new EncoderParameters(1);
|
||||
parameters.Param[0] = new System.Drawing.Imaging.EncoderParameter(Encoder.Quality, outputSettings.JPGQuality);
|
||||
ImageCodecInfo[] ies = ImageCodecInfo.GetImageEncoders();
|
||||
imageToSave.Save(targetStream, ies[1], parameters);
|
||||
bool foundEncoder = false;
|
||||
foreach (ImageCodecInfo imageCodec in ImageCodecInfo.GetImageEncoders()) {
|
||||
if (imageCodec.FormatID == imageFormat.Guid) {
|
||||
EncoderParameters parameters = new EncoderParameters(1);
|
||||
parameters.Param[0] = new EncoderParameter(Encoder.Quality, outputSettings.JPGQuality);
|
||||
imageToSave.Save(targetStream, imageCodec, parameters);
|
||||
foundEncoder = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundEncoder) {
|
||||
throw new ApplicationException("No JPG encoder found, this should not happen.");
|
||||
}
|
||||
} else if (imageFormat != ImageFormat.Png && Image.IsAlphaPixelFormat(imageToSave.PixelFormat)) {
|
||||
// No transparency in target format
|
||||
using (Bitmap tmpBitmap = ImageHelper.Clone(imageToSave, PixelFormat.Format24bppRgb)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue