示例#1
0
        public static Tuple <List <byte[]>, ushort[]> GenerateMipList(Bitmap Image, uint TexWidth, uint TexHeight,
                                                                      uint MipCount, TextureFormats Format, PaletteFormats PaletteFormat)
        {
            ushort[] paletteData = new ushort[0];

            List <byte[]> mipmaps = new List <byte[]>();

            for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
            {
                int MipWidth  = Math.Max(1, (int)TexWidth >> mipLevel);
                int MipHeight = Math.Max(1, (int)TexHeight >> mipLevel);

                if (mipLevel != 0)
                {
                    Image = BitmapExtension.Resize(Image, MipWidth, MipHeight);
                }

                var EncodedData = Decode_Gamecube.EncodeData(BitmapExtension.ImageToByte(Image), Format, PaletteFormat, MipWidth, MipHeight);

                mipmaps.Add(EncodedData.Item1);

                if (mipLevel == 0) //Set palette data once
                {
                    paletteData = EncodedData.Item2;
                }
            }
            Image.Dispose();

            return(Tuple.Create(mipmaps, paletteData));
        }
        private int GetImageSizeGCN()
        {
            var platform = (GamecubeSwizzle)Platform;

            int totalSize = 0;

            for (int arrayLevel = 0; arrayLevel < ArrayCount; arrayLevel++)
            {
                for (int mipLevel = 0; mipLevel < MipCount; mipLevel++)
                {
                    uint width  = (uint)Math.Max(1, Width >> mipLevel);
                    uint height = (uint)Math.Max(1, Height >> mipLevel);

                    totalSize += Decode_Gamecube.GetDataSize((uint)platform.Format, width, height);
                }
            }

            return(totalSize);
        }
示例#3
0
        public static int GetDataSizeWithMips(uint format, uint Width, uint Height, uint MipCount)
        {
            if (MipCount == 0)
            {
                MipCount = 1;
            }

            int size = 0;

            for (int m = 0; m < MipCount; m++)
            {
                uint width  = (uint)Math.Max(1, Width >> m);
                uint height = (uint)Math.Max(1, Height >> m);

                size += Decode_Gamecube.GetDataSize(format, width, height);
            }

            return(size);
        }
示例#4
0
        public static byte[] GetMipLevel(byte[] ImageData, uint Width, uint Height, uint MipCount, uint MipLevel, TextureFormats format)
        {
            uint offset = 0;

            for (int m = 0; m < MipCount; m++)
            {
                uint width  = (uint)Math.Max(1, Width >> m);
                uint height = (uint)Math.Max(1, Height >> m);

                uint size = (uint)Decode_Gamecube.GetDataSize(format, (int)width, (int)height);

                if (MipLevel == m)
                {
                    return(ByteUtils.SubArray(ImageData, offset, size));
                }

                offset += size;
            }

            return(ImageData);
        }