Add J2K decoder routine that converts directly to an image.

varregion
Robert Adams 2014-01-19 07:32:41 -08:00
parent 08fa0a6a8a
commit 813f0da00b
2 changed files with 29 additions and 1 deletions

View File

@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Text;
@ -182,6 +183,25 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender
return DoJ2KDecode(assetID, j2kData, out layers, out components);
}
public Image DecodeToImage(byte[] j2kData)
{
if (m_useCSJ2K)
return J2kImage.FromBytes(j2kData);
else
{
ManagedImage mimage;
Image image;
if (OpenJPEG.DecodeToImage(j2kData, out mimage, out image))
{
mimage = null;
return image;
}
else
return null;
}
}
#endregion IJ2KDecoder
/// <summary>

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Drawing;
using OpenMetaverse;
using OpenMetaverse.Imaging;
@ -53,5 +54,12 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="components">number of components</param>
/// <returns>true if decode was successful. false otherwise.</returns>
bool Decode(UUID assetID, byte[] j2kData, out OpenJPEG.J2KLayerInfo[] layers, out int components);
/// <summary>
/// Provides a synchronous decode direct to an image object
/// </summary>
/// <param name="j2kData"></param>
/// <returns>decoded image or 'null' of unsuccessful</returns>
Image DecodeToImage(byte[] j2kData);
}
}