Example #1
0
        public IEnumerable <Color> Load(byte[] tex)
        {
            using (var br = new BinaryReaderX(new MemoryStream(tex), byteOrder))
            {
                var etc1decoder = new Support.ETC1.Decoder(_3ds_order);

                while (true)
                {
                    yield return(etc1decoder.Get(() =>
                    {
                        var etc1Alpha = alpha ? br.ReadUInt64() : ulong.MaxValue;
                        if (etc1Alpha != 0)
                        {
                            ;
                        }
                        var colorBlock = br.ReadUInt64();
                        var etc1Block = new Support.ETC1.Block
                        {
                            LSB = (ushort)(colorBlock & 0xFFFF),
                            MSB = (ushort)((colorBlock >> 16) & 0xFFFF),
                            flags = (byte)((colorBlock >> 32) & 0xFF),
                            B = (byte)((colorBlock >> 40) & 0xFF),
                            G = (byte)((colorBlock >> 48) & 0xFF),
                            R = (byte)((colorBlock >> 56) & 0xFF)
                        };
                        return new Support.ETC1.PixelData {
                            Alpha = etc1Alpha, Block = etc1Block
                        };
                    }));
                }
            }
        }
Example #2
0
        public IEnumerable <Color> Load(byte[] tex)
        {
            using (var br = new BinaryReaderX(new MemoryStream(tex), byteOrder))
            {
                var etc1decoder = new Support.ETC1.Decoder();

                while (br.BaseStream.Position < br.BaseStream.Length)
                {
                    yield return(etc1decoder.Get(() =>
                    {
                        var etc1Alpha = alpha ? br.ReadUInt64() : ulong.MaxValue;
                        return new Support.ETC1.PixelData {
                            Alpha = etc1Alpha, Block = br.ReadStruct <Support.ETC1.Block>()
                        };
                    }));
                }
            }
        }