示例#1
0
        static void Main(string[] args)
        {
            Bitmap inputImage = new Bitmap("1024cat.png");
            Bitmap overlayImg = new Bitmap("test2.png");

            bitmapfilters.brightness(inputImage, 0.4f).Save("brightness.png");


            return;

            //How to use the heatmaps example

            densitymap denstest = new densitymap(); //setup a new density map
            Random     r        = new Random();

            for (int i = 0; i < (1024 * 2); i++)
            {
                int rposx = r.Next(0, 1024);
                int rposy = r.Next(0, 1024);

                denstest.createHeatMapSplodge(rposx, rposy); //Add all your data, in this case it was random
            }

            denstest.averageBlur3x3(); //Add a bit of kernal blur
            denstest.normalise();      //Normalise the results so they fit between 0-255 (mid point can be adjusted for more interesting effects)


            gradients.gradients.fire.applyToImage(denstest.toBitMap()).Save("test2.png"); //Apply a gradient to it, in this case I added the fire gradient which works well
        }
示例#2
0
        /// <summary>
        /// This method handles all the sequencing required to generate data from the mapData file
        /// </summary>
        /// <param name="mapfile">The mapfile to process</param>
        static void doProcessing(mapData mapfile, DemoParser parser)
        {
            Debug.Success("Starting processing");

            //First step: Make a grey dark version of the radar.
            Bitmap backgroundRadar = bitmapfilters.brightness(bitmapfilters.greyScaleAverage(mapfile.image_radar), 0.3f);

            //Second step: Load the demo into a demodatainstance, so that it parses into different lists.
            demodatainstance demo = new demodatainstance(parser);

            //Third step: Start making heatmaps
            densitymap density_shotsfired = new densitymap();

            //Legacy, Make the camera object
            camera cam = new camera();

            cam.offset = new vector2(mapfile.radar.pos_x, mapfile.radar.pos_y);
            cam.scale  = mapfile.radar.scale;


            foreach (p_Player plyr in demo.players.Values.ToList())
            {
                foreach (p_Round rnd in plyr.rounds)
                {
                    foreach (vector3 shot in rnd.shotsFired)
                    {
                        vector2 screenPos = transforms.worldToScreenSpace(shot, cam);
                        density_shotsfired.createHeatMapSplodge((int)screenPos.x, (int)screenPos.y, 20);
                    }
                }
            }

            density_shotsfired.averageBlur3x3();
            density_shotsfired.normalise(0.4f);

            Bitmap output = density_shotsfired.toBitMap();

            output = gradients.fire.applyToImage(output);

            output = bitmapfilters.alphaOver(backgroundRadar, output);

            output.Save("test_shotsfired.png");
        }
        private void btn_Generate_Click(object sender, RoutedEventArgs e)
        {
            mapData mapfile = demoreading.loadMapFromDisk(refInstance.info.mapname);
            //First step: Make a grey dark version of the radar.
            Bitmap backgroundRadar = bitmapfilters.brightness(bitmapfilters.greyScaleAverage(mapfile.image_radar), 0.3f);
            Bitmap outputImage     = backgroundRadar;

            //Third step: Start making heatmaps
            densitymap density_shotsfired = new densitymap();

            //Legacy, Make the camera object
            camera cam = new camera();

            cam.offset = new vector2(mapfile.radar.pos_x, mapfile.radar.pos_y);
            cam.scale  = mapfile.radar.scale;

            #region shotsfired
            if (toggle_shotsfired.IsChecked.Value)
            {
                foreach (p_Player plyr in refInstance.players.Values.ToList())
                {
                    if (enabledSteamIDS[plyr.steamID]) //Check if that player was enabled
                    {
                        foreach (p_Round rnd in plyr.rounds)
                        {
                            foreach (vector3 shot in rnd.shotsFired)
                            {
                                vector2 screenPos = transforms.worldToScreenSpace(shot, cam);
                                density_shotsfired.createHeatMapSplodgeAccelerated((int)screenPos.x, (int)screenPos.y, (int)val_dialation_slider.Value);
                            }
                        }
                    }
                }


                //If blur is enabled, use the 3x3 blur filter
                if (toggle_blur.IsChecked.Value)
                {
                    density_shotsfired.averageBlur3x3();
                }


                density_shotsfired.normalise((float)val_samplemidpoint_slider.Value / (float)val_samplemidpoint_slider.Maximum);

                Bitmap output = density_shotsfired.toBitMap();
                output = gradients.fire.applyToImage(output);

                outputImage = bitmapfilters.alphaOver(backgroundRadar, output);
            }
            #endregion

            #region playerpaths
            //If draw player paths is enabled
            if (toggle_playerpaths.IsChecked.Value)
            {
                Pen CTpen = new Pen(Color.FromArgb(32, 242, 139, 4), 1);
                Pen Tpen  = new Pen(Color.FromArgb(32, 50, 178, 201), 1);


                foreach (p_Player plyr in refInstance.players.Values.ToList())
                {
                    if (enabledSteamIDS[plyr.steamID])
                    {
                        foreach (p_Round rnd in plyr.rounds)
                        {
                            using (var graphics = Graphics.FromImage(outputImage))
                            {
                                Pen pen;
                                if (rnd.teamPlayedOnRound == p_Team_Identifier.terrorist)
                                {
                                    pen = CTpen;
                                }
                                else
                                {
                                    pen = Tpen;
                                }

                                for (int i = 0; i < rnd.positions.Count(); i++)
                                {
                                    vector2 pa = transforms.worldToScreenSpace(rnd.positions[i], cam);
                                    vector2 pb = transforms.worldToScreenSpace(rnd.positions[(i - 1).Clamp(0, rnd.positions.Count() - 1)], cam);

                                    //F*****g weird shit, I dont know why its recording big jumps like this
                                    if (Math.Abs(pa.x - pb.x) + Math.Abs(pa.y - pb.y) < 128)
                                    {
                                        graphics.DrawLine(pen, pa.x, pa.y.remapF(1024, 0, 0, 1024) - 1024, pb.x, pb.y.remapF(1024, 0, 0, 1024) - 1024);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            #endregion

            target_currentview.set_image(outputImage);
        }