fix map image encoder parameter

master
UbitUmarov 2020-04-25 20:25:38 +01:00
parent 2d1900165b
commit d44baf20cd
1 changed files with 8 additions and 3 deletions

View File

@ -1239,6 +1239,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// non-async because we know we have the asset immediately. // non-async because we know we have the asset immediately.
AssetBase mapasset = m_scene.AssetService.Get(m_scene.RegionInfo.RegionSettings.TerrainImageID.ToString()); AssetBase mapasset = m_scene.AssetService.Get(m_scene.RegionInfo.RegionSettings.TerrainImageID.ToString());
if(mapasset == null || mapasset.Data == null || mapasset.Data.Length == 0)
{
response.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
// Decode image to System.Drawing.Image // Decode image to System.Drawing.Image
if (OpenJPEG.DecodeToImage(mapasset.Data, out managedImage, out image)) if (OpenJPEG.DecodeToImage(mapasset.Data, out managedImage, out image))
@ -1247,7 +1252,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
mapTexture = new Bitmap(image); mapTexture = new Bitmap(image);
EncoderParameters myEncoderParameters = new EncoderParameters(); EncoderParameters myEncoderParameters = new EncoderParameters();
myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95); myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L);
// Save bitmap to stream // Save bitmap to stream
mapTexture.Save(imgstream, GetEncoderInfo("image/jpeg"), myEncoderParameters); mapTexture.Save(imgstream, GetEncoderInfo("image/jpeg"), myEncoderParameters);
@ -1257,10 +1262,10 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
myMapImageJPEG = jpeg; myMapImageJPEG = jpeg;
} }
} }
catch (Exception) catch (Exception e)
{ {
// Dummy! // Dummy!
m_log.Warn("[WORLD MAP]: Unable to generate Map image"); m_log.Warn("[WORLD MAP]: Unable to generate Map image" + e.Message);
response.StatusCode = (int)HttpStatusCode.NotFound; response.StatusCode = (int)HttpStatusCode.NotFound;
return; return;
} }