using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;

using Imaging.DDSReader;

namespace DDS
{
    public class FiestaDDS
    {
        public static Dictionary<Int32, Bitmap> LoadItemImages(String FilePath)
        {
            Dictionary<Int32, Bitmap> ItemImages = new Dictionary<Int32, Bitmap>();

            DDSImage DDSFile = new DDSImage(File.ReadAllBytes(FilePath));

            Int32 ID = 0;
            Int32 X = 0;
            Int32 Y = 0;

            while (Y != 256)
            {
                while (X != 256)
                {
                    Bitmap ImageMap = new Bitmap(32, 32);

                    Graphics ImageDraw = Graphics.FromImage(ImageMap);
                    ImageDraw.DrawImage(DDSFile.BitmapImage, -X, -Y);

                    ItemImages.Add(ID, ImageMap);

                    ID++;
                    X = (X + 32);
                }

                X = 0;
                Y = (Y + 32);
            }

            return ItemImages;
        }

        public static Dictionary<Int32, Bitmap> LoadGrades(String FilePath)
        {
            Dictionary<Int32, Bitmap> Grades = new Dictionary<Int32, Bitmap>();

            DDSImage DDSFile = new DDSImage(File.ReadAllBytes(FilePath));

            Int32 ID = 0;
            Int32 X = 0;
            Int32 Y = 0;

            while (Y != 128)
            {
                while (X != 128)
                {
                    Bitmap ImageMap = new Bitmap(32, 32);

                    Graphics ImageDraw = Graphics.FromImage(ImageMap);
                    ImageDraw.DrawImage(DDSFile.BitmapImage, -X, -Y);

                    Grades.Add(ID, ImageMap);

                    ID++;
                    X = (X + 32);
                }

                X = 0;
                Y = (Y + 32);
            }

            return Grades;
        }
    }
}
