示例#1
0
        public static Bitmap getMapSpeedFile(string fileName)
        {
            Bitmap bmp = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            if (fileExists(fileName))
            {
                fillSpeedColourList();
                byte[]    fileContents = ReadFile(Environment.ExpandEnvironmentVariables(fileName));
                int       index        = 256 * 256;
                Rectangle rect         = new Rectangle();
                rect.Height = 256;
                rect.Width  = 256;
                rect.X      = 0;
                rect.Y      = 0;
                Objects.Colour color = new Objects.Colour();
                color = colourlist[0];
                Graphics.FromImage(bmp).FillRectangle(new SolidBrush(Color.FromArgb(color.r, color.g, color.b)), rect);
                for (int x = 0; x < 256; x++)
                {
                    for (int y = 0; y < 256; y++)
                    {
                        Objects.Colour clr;
                        clr = speedcolourlist[fileContents[index]];
                        if (!(clr.r == color.r && clr.g == color.g && clr.b == color.b))
                        {
                            bmp.SetPixel(x, y, System.Drawing.Color.FromArgb((byte)255, (byte)clr.r, (byte)clr.g, (byte)clr.b));
                        }
                        index++;
                    }
                }
            }
            return(bmp);
        }
示例#2
0
 public static Objects.Colour getClr(int r, int g, int b)
 {
     Objects.Colour Clr = new Objects.Colour();
     Clr.r = r;
     Clr.g = g;
     Clr.b = b;
     return Clr;
 }
示例#3
0
 public static Objects.Colour getClr(int r, int g, int b)
 {
     Objects.Colour Clr = new Objects.Colour();
     Clr.r = r;
     Clr.g = g;
     Clr.b = b;
     return(Clr);
 }
示例#4
0
        public static Bitmap getMapSpeedFileAroundMe(Objects.Location location)
        {
            fillColourList();
            // Format is up, upri, ri, rido, do, dole, le, leup, self
            StringBuilder[] sb = new StringBuilder[9];
            sb = getFileAroundMeNames(location);
            Bitmap[]  bmpList = new Bitmap[9];
            Bitmap    bmp     = new Bitmap(256 * 3, 256 * 3, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Rectangle rect    = new Rectangle();

            rect.Height = 256;
            rect.Width  = 256;
            rect.X      = 0;
            rect.Y      = 0;
            Objects.Colour color = new Objects.Colour();
            color = colourlist[0];
            Graphics.FromImage(bmp).FillRectangle(new SolidBrush(Color.FromArgb(color.r, color.g, color.b)), rect);
            for (int i = 0; i < 9; i++)
            {
                string mapFileName = sb[i].ToString();
                bmpList[i] = getMapSpeedFile(mapFileName);
            }

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.DrawImage(bmpList[0], 0, 0, 256, 256);     // TL
                g.DrawImage(bmpList[1], 256, 0, 256, 256);   // TM
                g.DrawImage(bmpList[2], 512, 0, 256, 256);   // TR
                g.DrawImage(bmpList[3], 0, 256, 256, 256);   // ML
                g.DrawImage(bmpList[4], 256, 256, 256, 256); // MM
                g.DrawImage(bmpList[5], 512, 256, 256, 256); // MR
                g.DrawImage(bmpList[6], 0, 512, 256, 256);   // BL
                g.DrawImage(bmpList[7], 256, 512, 256, 256); // BM
                g.DrawImage(bmpList[8], 512, 512, 256, 256); // BR
            }
            for (int i = 0; i < 9; i++)
            {
                string fileToSave = "C:\\Users\\Owner\\Documents\\MapFiles\\MapFile" + Convert.ToString(i) + ".bmp";
                //bmpList[i].Save(fileToSave);
            }

            return(bmp);
        }
示例#5
0
 public static Bitmap getMapFile(string fileName)
 {
     Bitmap bmp = new Bitmap(256, 256, System.Drawing.Imaging.PixelFormat.Format32bppArgb);;
     if (fileExists(fileName))
     {
         fillColourList();
         byte[] fileContents = ReadFile(Environment.ExpandEnvironmentVariables(fileName));
         int index = 0;
         Rectangle rect = new Rectangle();
         rect.Height = 256;
         rect.Width = 256;
         rect.X = 0;
         rect.Y = 0;
         Objects.Colour color = new Objects.Colour();
         color = colourlist[0];
         Graphics.FromImage(bmp).FillRectangle(new SolidBrush(Color.FromArgb(color.r, color.g, color.b)), rect);
         for (int x = 0; x < 256; x++)
         {
             for (int y = 0; y < 256; y++)
             {
                 Objects.Colour clr;
                 clr = MapReading.colourlist[fileContents[index]];
                 if (!(clr.r == color.r && clr.g == color.g && clr.b == color.b))
                 {
                     bmp.SetPixel(x, y, System.Drawing.Color.FromArgb((byte)255, (byte)clr.r, (byte)clr.g, (byte)clr.b));
                 }
                 index++;
             }
         }
     }
     else
     {
         Rectangle rect = new Rectangle();
         rect.Height = 256;
         rect.Width = 256;
         rect.X = 0;
         rect.Y = 0;
         Objects.Colour color = new Objects.Colour();
         color.r = 255;
         color.g = 255;
         color.b = 0;
         Graphics.FromImage(bmp).FillRectangle(new SolidBrush(Color.FromArgb(color.r, color.g, color.b)), rect);
     }
     return bmp;
 }
示例#6
0
        public static Bitmap getMapSpeedFileAroundMe(Objects.Location location)
        {
            fillColourList();
            // Format is up, upri, ri, rido, do, dole, le, leup, self
            StringBuilder[] sb = new StringBuilder[9];
            sb = getFileAroundMeNames(location);
            Bitmap[] bmpList = new Bitmap[9];
            Bitmap bmp = new Bitmap(256 * 3, 256 * 3, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Rectangle rect = new Rectangle();
            rect.Height = 256;
            rect.Width = 256;
            rect.X = 0;
            rect.Y = 0;
            Objects.Colour color = new Objects.Colour();
            color = colourlist[0];
            Graphics.FromImage(bmp).FillRectangle(new SolidBrush(Color.FromArgb(color.r, color.g, color.b)), rect);
            for (int i = 0; i < 9; i++)
            {
                string mapFileName = sb[i].ToString();
                bmpList[i] = getMapSpeedFile(mapFileName);
            }

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.DrawImage(bmpList[0], 0, 0, 256, 256); // TL
                g.DrawImage(bmpList[1], 256, 0, 256, 256); // TM
                g.DrawImage(bmpList[2], 512, 0, 256, 256); // TR
                g.DrawImage(bmpList[3], 0, 256, 256, 256); // ML
                g.DrawImage(bmpList[4], 256, 256, 256, 256); // MM
                g.DrawImage(bmpList[5], 512, 256, 256, 256); // MR
                g.DrawImage(bmpList[6], 0, 512, 256, 256); // BL
                g.DrawImage(bmpList[7], 256, 512, 256, 256); // BM
                g.DrawImage(bmpList[8], 512, 512, 256, 256); // BR
            }
            for (int i = 0; i < 9; i++)
            {
                string fileToSave = "C:\\Users\\Owner\\Documents\\MapFiles\\MapFile" + Convert.ToString(i) + ".bmp";
                //bmpList[i].Save(fileToSave);
            }

            return bmp;
        }