Beispiel #1
0
 public static byte[] Decode(byte[] data, TextureFormat format, int width, int height)
 {
     return(format switch
     {
         TextureFormat.R8 => RGBADecoders.ReadR8(data, width, height),
         TextureFormat.R16 => RGBADecoders.ReadR16(data, width, height),
         TextureFormat.RG16 => RGBADecoders.ReadRG16(data, width, height),
         TextureFormat.RGB24 => RGBADecoders.ReadRGB24(data, width, height),
         TextureFormat.RGB565 => RGBADecoders.ReadRGB565(data, width, height),
         TextureFormat.RGBA32 => RGBADecoders.ReadRGBA32(data, width, height),
         TextureFormat.ARGB32 => RGBADecoders.ReadARGB32(data, width, height),
         TextureFormat.RGBA4444 => RGBADecoders.ReadRGBA4444(data, width, height),
         TextureFormat.ARGB4444 => RGBADecoders.ReadARGB4444(data, width, height),
         TextureFormat.Alpha8 => RGBADecoders.ReadAlpha8(data, width, height),
         TextureFormat.RHalf => RGBADecoders.ReadRHalf(data, width, height),
         TextureFormat.RGHalf => RGBADecoders.ReadRGHalf(data, width, height),
         TextureFormat.RGBAHalf => RGBADecoders.ReadRGBAHalf(data, width, height),
         TextureFormat.DXT1 => DXTDecoders.ReadDXT1(data, width, height),
         TextureFormat.DXT5 => DXTDecoders.ReadDXT5(data, width, height),
         TextureFormat.BC7 => BC7Decoder.ReadBC7(data, width, height),
         TextureFormat.ETC_RGB4 => ETCDecoders.ReadETC(data, width, height),
         TextureFormat.ETC2_RGB4 => ETCDecoders.ReadETC(data, width, height, true),
         _ => null
     });
Beispiel #2
0
        public static byte[] GetTextureDataFromBytes(byte[] data, TextureFormat texFmt, int width, int height)
        {
            switch (texFmt)
            {
            case TextureFormat.R8:
                return(RGBADecoders.ReadR8(data, width, height));

            case TextureFormat.R16:
                return(RGBADecoders.ReadR16(data, width, height));

            case TextureFormat.RG16:
                return(RGBADecoders.ReadRG16(data, width, height));

            case TextureFormat.RGB24:
                return(RGBADecoders.ReadRGB24(data, width, height));

            case TextureFormat.RGB565:
                return(RGBADecoders.ReadRGB565(data, width, height));

            case TextureFormat.RGBA32:
                return(RGBADecoders.ReadRGBA32(data, width, height));

            case TextureFormat.ARGB32:
                return(RGBADecoders.ReadARGB32(data, width, height));

            case TextureFormat.RGBA4444:
                return(RGBADecoders.ReadRGBA4444(data, width, height));

            case TextureFormat.ARGB4444:
                return(RGBADecoders.ReadARGB4444(data, width, height));

            case TextureFormat.Alpha8:
                return(RGBADecoders.ReadAlpha8(data, width, height));

            case TextureFormat.RHalf:
                return(RGBADecoders.ReadRHalf(data, width, height));

            case TextureFormat.RGHalf:
                return(RGBADecoders.ReadRGHalf(data, width, height));

            case TextureFormat.RGBAHalf:
                return(RGBADecoders.ReadRGBAHalf(data, width, height));

            case TextureFormat.DXT1:
                return(DXTDecoders.ReadDXT1(data, width, height));

            case TextureFormat.DXT5:
                return(DXTDecoders.ReadDXT5(data, width, height));

            case TextureFormat.BC7:
                return(BC7Decoder.ReadBC7(data, width, height));

            case TextureFormat.ETC_RGB4:
                return(ETCDecoders.ReadETC(data, width, height));

            case TextureFormat.ETC2_RGB4:
                return(ETCDecoders.ReadETC(data, width, height, true));

            default:
                return(null);
            }
        }