示例#1
0
        public override Bitmap createBitmap()
        {
            resetMatrix();

            // カメラと視点との距離
            double distance = Math.Sqrt(Math.Pow(cameraX - mapCenterX, 2) + Math.Pow(cameraY, 2) + Math.Pow(cameraZ - mapCenterZ, 2));

            Bitmap mapImage = new Bitmap((int)this.screenWidth, (int)this.screenHeight);

            Graphics imageG = Graphics.FromImage(mapImage);

            List <ViewBackGround> viewBackgroundList = new List <ViewBackGround>();

            foreach (Background background in dataStore.backgroundList)
            {
                Vector4[] disp = calcDisplayLineSegmentCoord(background.upCoord.x, background.upCoord.y, background.dnCoord.x, background.dnCoord.y);

                if (disp == null)
                {
                    continue;
                }

                float x1 = disp[0].X;
                float y1 = disp[0].Y;

                float x2 = disp[1].X;
                float y2 = disp[1].Y;

                if (checkScreen(x1, y1) || checkScreen(x2, y2))
                {
                    ViewBackGround viewBackground = new ViewBackGround(x1, y1, x2, y2, pen_lane);
                    viewBackgroundList.Add(viewBackground);
                }
            }

            if (viewBackgroundList.Count() > 0)
            {
                foreach (ViewBackGround v in viewBackgroundList)
                {
                    imageG.DrawLine(v.pen, v.x1, v.y1, v.x2, v.y2);
                }
            }

            imageG.Dispose();

            return(mapImage);
        }
示例#2
0
        public override Bitmap createBitmap()
        {
            Bitmap   mapImage = new Bitmap((int)this.screenWidth, (int)this.screenHeight);
            Graphics imageG   = Graphics.FromImage(mapImage);

#if PARALLEL
            ParallelOptions options = new ParallelOptions();
            options.MaxDegreeOfParallelism = 10;

            ConcurrentBag <ViewBackGround> viewBackgroundList = new ConcurrentBag <ViewBackGround>();
            Parallel.ForEach(dataStore.backgroundList, options, background =>
            {
                float x1 = calcScreenX(background.upCoord.x);
                float y1 = calcScreenY(background.upCoord.y);

                float x2 = calcScreenX(background.dnCoord.x);
                float y2 = calcScreenY(background.dnCoord.y);

                if (checkScreen(x1, y1) || checkScreen(x2, y2))
                {
                    ViewBackGround viewBackground = new ViewBackGround(x1, y1, x2, y2, pen_lane);
                    viewBackgroundList.Add(viewBackground);
                }
            });

            if (viewBackgroundList.Count() > 0)
            {
                foreach (ViewBackGround v in viewBackgroundList)
                {
                    imageG.DrawLine(v.pen, v.x1, v.y1, v.x2, v.y2);
                }
            }
#else
            List <ViewBackGround> viewBackgroundList = new List <ViewBackGround>();
            foreach (Background background in dataStore.backgroundList)
            {
                float x1 = calcScreenX(background.upCoord.x);
                float y1 = calcScreenY(background.upCoord.y);

                float x2 = calcScreenX(background.dnCoord.x);
                float y2 = calcScreenY(background.dnCoord.y);

                if (checkScreen(x1, y1) || checkScreen(x2, y2))
                {
                    ViewBackGround viewBackground = new ViewBackGround(x1, y1, x2, y2, pen_lane);
                    viewBackgroundList.Add(viewBackground);
                }
            }

            if (viewBackgroundList.Count() > 0)
            {
                foreach (ViewBackGround v in viewBackgroundList)
                {
                    imageG.DrawLine(v.pen, v.x1, v.y1, v.x2, v.y2);
                }
            }
#endif

            imageG.Dispose();

            return(mapImage);
        }