Add J2K decoder routine that converts directly to an image.
parent
08fa0a6a8a
commit
813f0da00b
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue