diff options
author | UbitUmarov | 2016-09-03 07:51:53 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-03 07:51:53 +0100 |
commit | 9aec227767cf726216514d0494f11b5d8bf5b807 (patch) | |
tree | 8f308f4c1eefa19954fc30a560ac780f8a8e916a /OpenSim/Capabilities/Handlers | |
parent | merge issue (diff) | |
parent | tests making sure evering thing is coerently wrong.. (diff) | |
download | opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.zip opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.gz opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.bz2 opensim-SC-9aec227767cf726216514d0494f11b5d8bf5b807.tar.xz |
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim/Capabilities/Handlers')
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 35 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs | 38 |
2 files changed, 40 insertions, 33 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index ac99692..8215124 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | |||
@@ -354,9 +354,9 @@ namespace OpenSim.Capabilities.Handlers | |||
354 | byte[] data = new byte[0]; | 354 | byte[] data = new byte[0]; |
355 | 355 | ||
356 | MemoryStream imgstream = new MemoryStream(); | 356 | MemoryStream imgstream = new MemoryStream(); |
357 | Bitmap mTexture = new Bitmap(1, 1); | 357 | Bitmap mTexture = null; |
358 | ManagedImage managedImage; | 358 | ManagedImage managedImage = null; |
359 | Image image = (Image)mTexture; | 359 | Image image = null; |
360 | 360 | ||
361 | try | 361 | try |
362 | { | 362 | { |
@@ -365,25 +365,26 @@ namespace OpenSim.Capabilities.Handlers | |||
365 | imgstream = new MemoryStream(); | 365 | imgstream = new MemoryStream(); |
366 | 366 | ||
367 | // Decode image to System.Drawing.Image | 367 | // Decode image to System.Drawing.Image |
368 | if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image)) | 368 | if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) |
369 | { | 369 | { |
370 | // Save to bitmap | 370 | // Save to bitmap |
371 | mTexture = new Bitmap(image); | 371 | mTexture = new Bitmap(image); |
372 | 372 | ||
373 | EncoderParameters myEncoderParameters = new EncoderParameters(); | 373 | using(EncoderParameters myEncoderParameters = new EncoderParameters()) |
374 | myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L); | ||
375 | |||
376 | // Save bitmap to stream | ||
377 | ImageCodecInfo codec = GetEncoderInfo("image/" + format); | ||
378 | if (codec != null) | ||
379 | { | 374 | { |
380 | mTexture.Save(imgstream, codec, myEncoderParameters); | 375 | myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality,95L); |
376 | |||
377 | // Save bitmap to stream | ||
378 | ImageCodecInfo codec = GetEncoderInfo("image/" + format); | ||
379 | if (codec != null) | ||
380 | { | ||
381 | mTexture.Save(imgstream, codec, myEncoderParameters); | ||
381 | // Write the stream to a byte array for output | 382 | // Write the stream to a byte array for output |
382 | data = imgstream.ToArray(); | 383 | data = imgstream.ToArray(); |
384 | } | ||
385 | else | ||
386 | m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format); | ||
383 | } | 387 | } |
384 | else | ||
385 | m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format); | ||
386 | |||
387 | } | 388 | } |
388 | } | 389 | } |
389 | catch (Exception e) | 390 | catch (Exception e) |
@@ -399,7 +400,9 @@ namespace OpenSim.Capabilities.Handlers | |||
399 | 400 | ||
400 | if (image != null) | 401 | if (image != null) |
401 | image.Dispose(); | 402 | image.Dispose(); |
402 | 403 | ||
404 | if(managedImage != null) | ||
405 | managedImage.Clear(); | ||
403 | if (imgstream != null) | 406 | if (imgstream != null) |
404 | { | 407 | { |
405 | imgstream.Close(); | 408 | imgstream.Close(); |
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs index f813471..518f74e 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs | |||
@@ -359,9 +359,9 @@ namespace OpenSim.Capabilities.Handlers | |||
359 | byte[] data = new byte[0]; | 359 | byte[] data = new byte[0]; |
360 | 360 | ||
361 | MemoryStream imgstream = new MemoryStream(); | 361 | MemoryStream imgstream = new MemoryStream(); |
362 | Bitmap mTexture = new Bitmap(1, 1); | 362 | Bitmap mTexture = null; |
363 | ManagedImage managedImage; | 363 | ManagedImage managedImage = null; |
364 | Image image = (Image)mTexture; | 364 | Image image = null; |
365 | 365 | ||
366 | try | 366 | try |
367 | { | 367 | { |
@@ -370,25 +370,26 @@ namespace OpenSim.Capabilities.Handlers | |||
370 | imgstream = new MemoryStream(); | 370 | imgstream = new MemoryStream(); |
371 | 371 | ||
372 | // Decode image to System.Drawing.Image | 372 | // Decode image to System.Drawing.Image |
373 | if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image)) | 373 | if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) |
374 | { | 374 | { |
375 | // Save to bitmap | 375 | // Save to bitmap |
376 | mTexture = new Bitmap(image); | 376 | mTexture = new Bitmap(image); |
377 | 377 | ||
378 | EncoderParameters myEncoderParameters = new EncoderParameters(); | 378 | using(EncoderParameters myEncoderParameters = new EncoderParameters()) |
379 | myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 95L); | ||
380 | |||
381 | // Save bitmap to stream | ||
382 | ImageCodecInfo codec = GetEncoderInfo("image/" + format); | ||
383 | if (codec != null) | ||
384 | { | 379 | { |
385 | mTexture.Save(imgstream, codec, myEncoderParameters); | 380 | myEncoderParameters.Param[0] = new EncoderParameter(Encoder.Quality,95L); |
386 | // Write the stream to a byte array for output | ||
387 | data = imgstream.ToArray(); | ||
388 | } | ||
389 | else | ||
390 | m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format); | ||
391 | 381 | ||
382 | // Save bitmap to stream | ||
383 | ImageCodecInfo codec = GetEncoderInfo("image/" + format); | ||
384 | if (codec != null) | ||
385 | { | ||
386 | mTexture.Save(imgstream, codec, myEncoderParameters); | ||
387 | // Write the stream to a byte array for output | ||
388 | data = imgstream.ToArray(); | ||
389 | } | ||
390 | else | ||
391 | m_log.WarnFormat("[GETTEXTURE]: No such codec {0}", format); | ||
392 | } | ||
392 | } | 393 | } |
393 | } | 394 | } |
394 | catch (Exception e) | 395 | catch (Exception e) |
@@ -405,6 +406,9 @@ namespace OpenSim.Capabilities.Handlers | |||
405 | if (image != null) | 406 | if (image != null) |
406 | image.Dispose(); | 407 | image.Dispose(); |
407 | 408 | ||
409 | if(managedImage != null) | ||
410 | managedImage.Clear(); | ||
411 | |||
408 | if (imgstream != null) | 412 | if (imgstream != null) |
409 | { | 413 | { |
410 | imgstream.Close(); | 414 | imgstream.Close(); |