static void DrawBitmap64x64From4_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Topleft: 4
             * TopRight: 3
             * BottomLeft: 2
             * BottomRight: 1
             */

            if (bitmaps[3] != null)
            {
                gfx.DrawImage(bitmaps[3], x, y, 32, 32);
            }
            if (bitmaps[2] != null)
            {
                gfx.DrawImage(bitmaps[2], x + 32, y, 32, 32);
            }
            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y + 32, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x + 32, y + 32, 32, 32);
            }
        }
        static void DrawBitmap32x32From1_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Fill: 1
             */

            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x, y, 32, 32);
            }
        }
        static void DrawBitmap32x64From2_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Top: 2
             * Bottom: 1
             */

            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x, y + 32, 32, 32);
            }
        }
        static void DrawBitmap64x32From2_32x32(AsyncGraphics gfx, Bitmap[] bitmaps, int x = 0, int y = 0)
        {
            /*
             * Left: 2
             * Right: 1
             */

            if (bitmaps[1] != null)
            {
                gfx.DrawImage(bitmaps[1], x, y, 32, 32);
            }
            if (bitmaps[0] != null)
            {
                gfx.DrawImage(bitmaps[0], x + 32, y, 32, 32);
            }
        }
        private void InternalSaveStaticBitmaps(RepeatedField <uint> sprites, DrawBitmapsDelegate drawFunc, int parts, int spriteType, int localStart, Assets.ContentSprites sprParser, int width, int height)
        {
            int singleSize = width * height;

            AsyncGraphics gfx = new AsyncGraphics(new Bitmap(Program.SEGMENT_DIMENTION, Program.SEGMENT_DIMENTION));
            string        filename;

            int x = 0, y = 0, z = 0;

            for (int i = 0; i < sprites.Count;)
            {
                Bitmap[] bitmapParts = new Bitmap[parts];
                for (int m = 0; m < parts; m++)
                {
                    if (i + m >= sprites.Count)
                    {
                        break;
                    }

                    bitmapParts[m] = sprParser.GetSprite(sprites[i + m]);
                }

                if (y >= Program.SEGMENT_DIMENTION)
                {
                    filename = string.Format("sprites-{0}-{1}.png", localStart, localStart + (Program.BITMAP_SIZE / singleSize) - 1);
                    m_Tasks.Add(gfx.SaveAndDispose(Path.Combine(m_ClientVersion.ToString(), "result", "sprites", filename)));

                    m_JsonTokens.Add(new SpritesToken()
                    {
                        file          = filename,
                        spritetype    = spriteType,
                        firstspriteid = localStart,
                        lastspriteid  = localStart + (Program.BITMAP_SIZE / singleSize) - 1
                    });

                    localStart += Program.BITMAP_SIZE / singleSize;

                    gfx = new AsyncGraphics(new Bitmap(Program.SEGMENT_DIMENTION, Program.SEGMENT_DIMENTION));
                    x   = y = z = 0;
                }

                var tmpSmallBitmaps = bitmapParts;
                drawFunc(gfx, bitmapParts, x, y);
                m_Tasks.Add(gfx.DisposeOnDone(bitmapParts));

                x += width;
                if (x >= Program.SEGMENT_DIMENTION)
                {
                    y += height;
                    x  = 0;
                }

                if (i == sprites.Count)
                {
                    break;
                }

                i = Math.Min(i + parts, sprites.Count);
                z++;
            }

            // save the last gfx
            int end = localStart + z;

            filename = string.Format("sprites-{0}-{1}.png", localStart, end - 1);
            m_Tasks.Add(gfx.SaveAndDispose(Path.Combine(m_ClientVersion.ToString(), "result", "sprites", filename)));

            m_JsonTokens.Add(new SpritesToken()
            {
                file          = filename,
                spritetype    = spriteType,
                firstspriteid = localStart,
                lastspriteid  = end - 1
            });
        }