Esempio n. 1
0
        public static byte[] GetARGB32PixelData(PAA paa, Stream paaStream, int mipmapIndex = 0)
        {
            var input = new BinaryReaderEx(paaStream);

            Mipmap mipmap  = paa[mipmapIndex];
            var    rawData = mipmap.GetRawPixelData(input, paa.Type);

            switch (paa.Type)
            {
            case PAAType.RGBA_8888:
            case PAAType.P8:
                return(PixelFormatConversion.P8ToARGB32(rawData, paa.Palette));

            case PAAType.DXT1:
            case PAAType.DXT2:
            case PAAType.DXT3:
            case PAAType.DXT4:
            case PAAType.DXT5:
                return(PixelFormatConversion.DXTToARGB32(rawData, mipmap.Width, mipmap.Height, (int)paa.Type));

            case PAAType.RGBA_4444:
                return(PixelFormatConversion.ARGB16ToARGB32(rawData));

            case PAAType.RGBA_5551:
                return(PixelFormatConversion.ARGB1555ToARGB32(rawData));

            case PAAType.AI88:
                return(PixelFormatConversion.AI88ToARGB32(rawData));

            default:
                throw new Exception($"Cannot retrieve pixel data from this PaaType: {paa.Type}");
            }
        }
Esempio n. 2
0
        public static byte[] GetARGB32PixelData(PAA paa, Stream paaStream, Mipmap mipmap)
        {
            var input   = new BinaryReaderEx(paaStream);
            var rawData = mipmap.GetRawPixelData(input, paa.Type);

            byte[] argbPixels;
            switch (paa.Type)
            {
            case PAAType.RGBA_8888:
            case PAAType.P8:
                return(PixelFormatConversion.P8ToARGB32(rawData, paa.Palette));    //never uses swizzling

            case PAAType.DXT1:
            case PAAType.DXT2:
            case PAAType.DXT3:
            case PAAType.DXT4:
            case PAAType.DXT5:
                argbPixels = PixelFormatConversion.DXTToARGB32(rawData, mipmap.Width, mipmap.Height, (int)paa.Type); break;

            case PAAType.RGBA_4444:
                argbPixels = PixelFormatConversion.ARGB16ToARGB32(rawData); break;

            case PAAType.RGBA_5551:
                argbPixels = PixelFormatConversion.ARGB1555ToARGB32(rawData); break;

            case PAAType.AI88:
                argbPixels = PixelFormatConversion.AI88ToARGB32(rawData); break;

            default:
                throw new Exception($"Cannot retrieve pixel data from this PaaType: {paa.Type}");
            }

            ChannelSwizzling.Apply(argbPixels, paa.Palette.ChannelSwizzle);
            return(argbPixels);
        }