Ejemplo n.º 1
0
        public static byte[] CompressImage(Image image, DXTCompression compression)
        {
            Bitmap bitmap = new Bitmap(image);

            byte[] pixels = new byte[image.Width * image.Height * 4];

            List <Color> pixelList = new List <Color>();

            for (int j = 0; j < image.Height; j++)
            {
                for (int i = 0; i < image.Width; i++)
                {
                    Color color = bitmap.GetPixel(i, j);
                    pixelList.Add(color);
                }
            }

            int index = 0;

            for (int i = 0; i < pixelList.Count; i++)
            {
                Color color = pixelList[i];
                pixels[index + 0] = color.B;
                pixels[index + 1] = color.G;
                pixels[index + 2] = color.R;
                pixels[index + 3] = color.A;
                index            += 4;
            }

            byte[] result = CompressionTools.CompressTexture(pixels, image.Width, image.Height, compression);

            return(result);
        }
Ejemplo n.º 2
0
 public static byte[] DecompressImage(byte[] data, int width, int height, DXTCompression compression)
 {
     return(CompressionTools.DecompressTexture(data, width, height, compression));
 }