OpenMetaverse.AssetTexture.Decode C# (CSharp) Method

Decode() public method

Decodes the JPEG2000 data in AssetData to the ManagedImage object Image
public Decode ( ) : bool
return bool
        public override bool Decode()
        {
            Components = 0;

            if (OpenJPEG.DecodeToImage(AssetData, out Image))
            {
                if ((Image.Channels & ManagedImage.ImageChannels.Color) != 0)
                    Components += 3;
                if ((Image.Channels & ManagedImage.ImageChannels.Gray) != 0)
                    ++Components;
                if ((Image.Channels & ManagedImage.ImageChannels.Bump) != 0)
                    ++Components;
                if ((Image.Channels & ManagedImage.ImageChannels.Alpha) != 0)
                    ++Components;

                return true;
            }
            else
            {
                return false;
            }
        }

Usage Example

Ejemplo n.º 1
0
Archivo: Asset.cs Proyecto: yooyke/work
        public static void ImageDecompress(AssetBase assetBase)
        {
            if (assetBase == null)
                return;

            AssetType type = (AssetType)assetBase.Type;

            AssetTexture texture = null;
            switch(type)
            {
                case AssetType.ImageJPEG:
                case AssetType.ImageTGA:
                case AssetType.Texture: // Jpeg2000
                case AssetType.TextureTGA:
                    texture = new AssetTexture(new UUID(assetBase.ID), assetBase.Data);
                    break;
            }

            if (texture == null)
                return;

            if (type == AssetType.Texture)
            {
                try
                {
                    if (texture.Decode())
                        assetBase.Data = texture.Image.ExportTGA();
                }
                catch { }
            }
        }
All Usage Examples Of OpenMetaverse.AssetTexture::Decode