Пример #1
0
        public byte[] EncodeImage(Bitmap[] mipImages, XvrImageParameters parameters)
        {
            int maxMips = parameters.HasMips ? parameters.maximumMips : 1;

            byte[][] mips = new byte[mipImages.Length][];
            //byte[][] mips = new byte[maxMips][];
            //for (int i = 0; i < maxMips; i++)
            for (int i = 0; i < mipImages.Length; i++)
            {
                mips[i] = writeMip(mipImages[i], parameters.width >> i, parameters.height >> i);
            }
            return(mips.SelectMany(mip => mip).ToArray());
        }
Пример #2
0
        public static XvrRasterEncoder GetEncoder(XvrImageParameters parameters)
        {
            switch (PsuTextureTypeMethods.FromByte(parameters.pixelFlags))
            {
            case PsuTextureType.Raster: return(new XvrSimpleFormatEncoder(parameters.PixelFormat));

            /*
             * case PsuTextureType.Dxt1: return new DxtnDecoder(parameters.PixelFormat);
             * case PsuTextureType.Dxt2: return new Dxt2Decoder(parameters.PixelFormat);
             * case PsuTextureType.Dxt3: return new Dxt3Decoder(parameters.PixelFormat);
             * case PsuTextureType.Dxt4: return new Dxt4Decoder(parameters.PixelFormat);
             * case PsuTextureType.Dxt5: return new Dxt5Decoder(parameters.PixelFormat);*/
            default: throw new Exception("Invalid texture format " + parameters.pixelFlags);
            }
        }
Пример #3
0
        public Bitmap[] DecodeImage(byte[] rasterData, XvrImageParameters parameters, bool hasMips = false)
        {
            MemoryStream imageStream = new MemoryStream(rasterData);
            BinaryReader imageReader = new BinaryReader(imageStream);

            imageStream.Seek(parameters.startingOffset, SeekOrigin.Begin);
            int maxMips = hasMips ? parameters.maximumMips : 1;

            Bitmap[] mips = new Bitmap[maxMips];
            for (int i = 0; i < maxMips; i++)
            {
                mips[i] = readMip(imageReader, parameters.width >> i, parameters.height >> i);
            }
            imageReader.Close();
            return(mips);
        }