(VC12) Jpeg Quality

//Jpeg 画像の品質レベルの設定サンプル

using namespace System::Drawing;
using namespace System::Drawing::Imaging;

static ImageCodecInfo^ GetEncoderInfo(ImageFormat^ format);

Bitmap^ bmp;
ImageCodecInfo^ myImageCodecInfo;
Encoder^ myEncoder;
EncoderParameter^ myEncoderParameter;
EncoderParameters^ myEncoderParameters;

myImageCodecInfo = GetEncoderInfo(ImageFormat::Jpeg);
myEncoder = Encoder::Quality;
myEncoderParameters = gcnew EncoderParameters(1);

// quality level 75.
myEncoderParameter = gcnew EncoderParameter(myEncoder, __int64(75));
myEncoderParameters->Param[0] = myEncoderParameter;

bmp->Save(“Shapes075.jpg”, myImageCodecInfo, myEncoderParameters);

// —
static ImageCodecInfo^ GetEncoderInfo(ImageFormat^ format){
 int j;
 array^encoders;
 encoders = ImageCodecInfo::GetImageEncoders();
 for (j = 0; j < encoders->Length; ++j){
  if (encoders[j]->FormatID == format->Guid)
  return encoders[j];
  }
 return nullptr;
 }

Jpeg 画質レベルの違いでファイルサイズは
  25 >> 78KB
  75 >> 179KB
 100 >> 1,253KB 程度の差が出る
因みに
bitmap では 6,076KB