/// <summary> /// Checks if the mipmap format is an raw compressed format /// </summary> public static bool IsCompressed(this MipmapFormat format) { switch (format) { case MipmapFormat.CompressedDXT5: case MipmapFormat.CompressedDXT3: case MipmapFormat.CompressedDXT1: return(true); default: return(false); } }
private static Image ImageFromRawFormat(MipmapFormat format, byte[] bytes, int width, int height) { switch (format) { case MipmapFormat.R8: return(bytes == null ? new Image <Gray8>(width, height) : Image.LoadPixelData <Gray8>(bytes, width, height)); case MipmapFormat.RG88: return(bytes == null ? new Image <RG88>(width, height) : Image.LoadPixelData <RG88>(bytes, width, height)); case MipmapFormat.RGBA8888: return(bytes == null ? new Image <Rgba32>(width, height) : Image.LoadPixelData <Rgba32>(bytes, width, height)); default: throw new InvalidOperationException($"Mipmap format: {format} is not supported"); } }
public void CompressMipmap( ITexMipmap mipmap, MipmapFormat targetCompressFormat, bool lz4Compress) { if (mipmap == null) { throw new ArgumentNullException(nameof(mipmap)); } if (mipmap.IsLZ4Compressed) { throw new InvalidOperationException("Mipmap is already compressed using LZ4"); } if (targetCompressFormat != mipmap.Format) { throw new NotSupportedException("Changing mipmap format is not yet supported"); } if (lz4Compress) { LZ4Compress(mipmap); } }
/// <summary> /// Checks if the mipmap format is an image format /// </summary> public static bool IsImage(this MipmapFormat format) { return((int)format >= 1000); }
/// <summary> /// Returns file extension for an image format /// </summary> /// <exception cref="ArgumentOutOfRangeException">When mipmap format isn't an image format'</exception> public static string GetFileExtension(this MipmapFormat format) { switch (format) { case MipmapFormat.ImageBMP: return("bmp"); case MipmapFormat.ImageICO: return("ico"); case MipmapFormat.ImageJPEG: return("jpg"); case MipmapFormat.ImageJNG: return("jng"); case MipmapFormat.ImageKOALA: return("koa"); case MipmapFormat.ImageLBM: return("lbm"); case MipmapFormat.ImageIFF: return("iff"); case MipmapFormat.ImageMNG: return("mng"); case MipmapFormat.ImagePBM: case MipmapFormat.ImagePBMRAW: return("pbm"); case MipmapFormat.ImagePCD: return("pcd"); case MipmapFormat.ImagePCX: return("pcx"); case MipmapFormat.ImagePGM: case MipmapFormat.ImagePGMRAW: return("pgm"); case MipmapFormat.ImagePNG: return("png"); case MipmapFormat.ImagePPM: case MipmapFormat.ImagePPMRAW: return("ppm"); case MipmapFormat.ImageRAS: return("ras"); case MipmapFormat.ImageTARGA: return("tga"); case MipmapFormat.ImageTIFF: return("tif"); case MipmapFormat.ImageWBMP: return("wbmp"); case MipmapFormat.ImagePSD: return("psd"); case MipmapFormat.ImageCUT: return("cut"); case MipmapFormat.ImageXBM: return("xbm"); case MipmapFormat.ImageXPM: return("xpm"); case MipmapFormat.ImageDDS: return("dds"); case MipmapFormat.ImageGIF: return("gif"); case MipmapFormat.ImageHDR: return("hdr"); case MipmapFormat.ImageFAXG3: return("g3"); case MipmapFormat.ImageSGI: return("sgi"); case MipmapFormat.ImageEXR: return("exr"); case MipmapFormat.ImageJ2K: return("j2k"); case MipmapFormat.ImageJP2: return("jp2"); case MipmapFormat.ImagePFM: return("pfm"); case MipmapFormat.ImagePICT: return("pict"); case MipmapFormat.ImageRAW: return("raw"); default: throw new ArgumentOutOfRangeException(nameof(format), format, null); } }
/// <summary> /// Checks if the mipmap format is an raw uncompressed format /// </summary> public static bool IsRawFormat(this MipmapFormat format) { var formatId = (int)format; return(formatId >= 1 && formatId <= 3); }