internal CompressedTexture(AiTexture texture) { _formatHint = texture.FormatHint; if(texture.Width > 0 && texture.Data != IntPtr.Zero) { _data = MemoryHelper.MarshalArray<byte>(texture.Data, (int) texture.Width); } }
/// <summary> /// Constructs a new UnCompressedTexture. /// </summary> /// <param name="texture">Unmanaged AiTexture struct.</param> internal UncompressedTexture(AiTexture texture) { _width = (int) texture.Width; _height = (int) texture.Height; int size = _width * _height; if(size > 0 && texture.Data != IntPtr.Zero) { _data = MemoryHelper.MarshalArray<Texel>(texture.Data, size); } }
/// <summary> /// Creates a new texture based on the unmanaged struct. A height of zero /// indicates a compressed texture. /// </summary> /// <param name="texture">Unmanaged AiTexture struct</param> /// <returns>The embededded texture</returns> internal static Texture CreateTexture(AiTexture texture) { if(texture.Height == 0) { return new CompressedTexture(texture); } else { return new UncompressedTexture(texture); } }