示例#1
0
文件: SPR.cs 项目: mrjnumber1/mAthena
        public int Load(byte[] data)
        {
            try
            {
                System.IO.MemoryStream ms = null;
                System.IO.BinaryReader br = null;
                ms = new System.IO.MemoryStream(@data, 0, @data.Length);
                br = new System.IO.BinaryReader(ms);

                Magic        = br.ReadInt16();
                m_Compressed = br.ReadBoolean();
                Version      = br.ReadByte();

                int palcnt = br.ReadInt16();
                int rgbcnt = br.ReadInt16();

                m_PaletteImage = new PaletteImage[palcnt];
                for (int i = 1; i <= palcnt; i++)
                {
                    PaletteImage palImage = new PaletteImage(br, m_Compressed);
                    m_PaletteImage[i - 1] = palImage;
                }

                m_RGBImage = new RGBImage[rgbcnt];
                for (int i = 1; i <= rgbcnt; i++)
                {
                    RGBImage rgbImage = new RGBImage(br);
                    m_RGBImage[i - 1] = rgbImage;
                }

                for (int i = 0; i <= 255; i++)
                {
                    byte red   = br.ReadByte();
                    byte green = br.ReadByte();
                    byte blue  = br.ReadByte();
                    byte res   = br.ReadByte();
                    Palette[i] = System.Drawing.Color.FromArgb(red, green, blue);
                }

                OriginalPalette = Palette;

                br.Close();
                ms.Close();
                ms.Dispose();
                return(0);
            }
            catch (Exception ex)
            {
                return(-2);
            }
        }
示例#2
0
文件: SPR.cs 项目: mrjnumber1/mAthena
        public int Load(string Filename)
        {
            try
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(Filename);
                if (fi.Exists)
                {
                    System.IO.MemoryStream ms = null;
                    System.IO.BinaryReader br = null;
                    System.IO.FileStream   fs = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    byte[] @by = new byte[Convert.ToInt32(fs.Length) + 1];
                    fs.Read(@by, 0, Convert.ToInt32(fs.Length));
                    ms = new System.IO.MemoryStream(@by, 0, @by.Length);
                    br = new System.IO.BinaryReader(ms);
                    fs.Close();
                    fs.Dispose();

                    Magic        = br.ReadInt16();
                    m_Compressed = br.ReadBoolean();
                    Version      = br.ReadByte();

                    int palcnt = br.ReadInt16();
                    int rgbcnt = br.ReadInt16();

                    m_PaletteImage = new PaletteImage[palcnt];
                    for (int i = 1; i <= palcnt; i++)
                    {
                        PaletteImage palImage = new PaletteImage(br, m_Compressed);
                        m_PaletteImage[i - 1] = palImage;
                    }

                    m_RGBImage = new RGBImage[rgbcnt];
                    for (int i = 1; i <= rgbcnt; i++)
                    {
                        RGBImage rgbImage = new RGBImage(br);
                        m_RGBImage[i - 1] = rgbImage;
                    }

                    for (int i = 0; i <= 255; i++)
                    {
                        byte red   = br.ReadByte();
                        byte green = br.ReadByte();
                        byte blue  = br.ReadByte();
                        byte res   = br.ReadByte();
                        Palette[i] = System.Drawing.Color.FromArgb(red, green, blue);
                    }

                    OriginalPalette = Palette;

                    br.Close();
                    ms.Close();
                    ms.Dispose();
                }
                else
                {
                    return(-1);
                }
                return(0);
            }
            catch (Exception ex)
            {
                return(-2);
            }
        }
示例#3
0
        public int Load(byte[] data)
        {
            try
            {
                System.IO.MemoryStream ms = null;
                System.IO.BinaryReader br = null;
                ms = new System.IO.MemoryStream(@data, 0, @data.Length);
                br = new System.IO.BinaryReader(ms);

                Magic = br.ReadInt16();
                m_Compressed = br.ReadBoolean();
                Version = br.ReadByte();

                int palcnt = br.ReadInt16();
                int rgbcnt = br.ReadInt16();

                m_PaletteImage = new PaletteImage[palcnt];
                for (int i = 1; i <= palcnt; i++)
                {
                    PaletteImage palImage = new PaletteImage(br, m_Compressed);
                    m_PaletteImage[i - 1] = palImage;
                }

                m_RGBImage = new RGBImage[rgbcnt];
                for (int i = 1; i <= rgbcnt; i++)
                {
                    RGBImage rgbImage = new RGBImage(br);
                    m_RGBImage[i - 1] = rgbImage;
                }

                for (int i = 0; i <= 255; i++)
                {
                    byte red = br.ReadByte();
                    byte green = br.ReadByte();
                    byte blue = br.ReadByte();
                    byte res = br.ReadByte();
                    Palette[i] = System.Drawing.Color.FromArgb(red, green, blue);
                }

                OriginalPalette = Palette;

                br.Close();
                ms.Close();
                ms.Dispose();
                return 0;
            }
            catch (Exception ex)
            {
                return -2;
            }
        }
示例#4
0
        public int Load(string Filename)
        {
            try
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(Filename);
                if (fi.Exists)
                {
                    System.IO.MemoryStream ms = null;
                    System.IO.BinaryReader br = null;
                    System.IO.FileStream fs = new System.IO.FileStream(fi.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    byte[] @by = new byte[Convert.ToInt32(fs.Length) + 1];
                    fs.Read(@by, 0, Convert.ToInt32(fs.Length));
                    ms = new System.IO.MemoryStream(@by, 0, @by.Length);
                    br = new System.IO.BinaryReader(ms);
                    fs.Close();
                    fs.Dispose();

                    Magic = br.ReadInt16();
                    m_Compressed = br.ReadBoolean();
                    Version = br.ReadByte();

                    int palcnt = br.ReadInt16();
                    int rgbcnt = br.ReadInt16();

                    m_PaletteImage = new PaletteImage[palcnt];
                    for (int i = 1; i <= palcnt; i++)
                    {
                        PaletteImage palImage = new PaletteImage(br, m_Compressed);
                        m_PaletteImage[i - 1] = palImage;
                    }

                    m_RGBImage = new RGBImage[rgbcnt];
                    for (int i = 1; i <= rgbcnt; i++)
                    {
                        RGBImage rgbImage = new RGBImage(br);
                        m_RGBImage[i - 1] = rgbImage;
                    }

                    for (int i = 0; i <= 255; i++)
                    {
                        byte red = br.ReadByte();
                        byte green = br.ReadByte();
                        byte blue = br.ReadByte();
                        byte res = br.ReadByte();
                        Palette[i] = System.Drawing.Color.FromArgb(red, green, blue);
                    }

                    OriginalPalette = Palette;

                    br.Close();
                    ms.Close();
                    ms.Dispose();
                }
                else
                {
                    return -1;
                }
                return 0;
            }
            catch (Exception ex)
            {
                return -2;
            }
        }