From a401b03ab0cdfb2e98d36e290255e730870890a1 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 17 Jun 2008 00:55:30 +0000 Subject: * Increase WEBMAP tile jpeg quality. * I'm not sure if this method works on Linux.. but I guess I'll find out :P --- .../Modules/World/WorldMap/WorldMapModule.cs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Environment/Modules/World') diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs index 1dc0d0b..c8d2ef6 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs @@ -279,8 +279,22 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap // Save to bitmap 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 - mapTexture.Save(imgstream, ImageFormat.Jpeg); + mapTexture.Save(imgstream, myImageCodecInfo, myEncoderParameters); // Write the stream to a byte array for output jpeg = imgstream.ToArray(); @@ -314,5 +328,19 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap 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; + } + } } -- cgit v1.1