* Increase WEBMAP tile jpeg quality.

* I'm not sure if this method works on Linux..    but I guess I'll find out :P
0.6.0-stable
Teravus Ovares 2008-06-17 00:55:30 +00:00
parent cb70299092
commit a401b03ab0
1 changed files with 29 additions and 1 deletions

View File

@ -279,8 +279,22 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
// Save to bitmap // Save to bitmap
mapTexture = new Bitmap(image); mapTexture = new Bitmap(image);
ImageCodecInfo myImageCodecInfo;
Encoder myEncoder;
EncoderParameter myEncoderParameter;
EncoderParameters myEncoderParameters = new EncoderParameters();
myImageCodecInfo = GetEncoderInfo("image/jpeg");
myEncoder = Encoder.Quality;
myEncoderParameter = new EncoderParameter(myEncoder, 95L);
myEncoderParameters.Param[0] = myEncoderParameter;
// Save bitmap to stream // Save bitmap to stream
mapTexture.Save(imgstream, ImageFormat.Jpeg); mapTexture.Save(imgstream, myImageCodecInfo, myEncoderParameters);
// Write the stream to a byte array for output // Write the stream to a byte array for output
jpeg = imgstream.ToArray(); jpeg = imgstream.ToArray();
@ -314,5 +328,19 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
return reply; return reply;
} }
// From msdn
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
} }
} }