Google Map Saver. Net проблема сохранения - PullRequest
0 голосов
/ 01 октября 2018

Этот код не сохраняет изображение полностью.Кажется, что scrollLeft и scrollTop не работают должным образом.Фактически, конечный результат - JPG с верхним левым кадром сохраняемого изображения, а все остальное - черным, например: https://imgur.com/a/Cyfuz5a. Как это можно улучшить / исправить, пожалуйста?

    public Bitmap GetEntireContent(RectangleF crop)
    {
        this.UpdateFromBrowser();
        Bitmap bitmap = new Bitmap(this.screenWidth, this.screenHeight, PixelFormat.Format16bppRgb555);
        Bitmap bitmap1 = new Bitmap(this.widthsize + this.URLExtraLeft - this.trimWidth, this.heightsize + this.URLExtraHeight - this.trimHeight, PixelFormat.Format16bppRgb555);
        Graphics graphic = Graphics.FromImage(bitmap1);
        Graphics graphic1 = null;
        Image image = null;
        int num = 0;
        int num1 = 0;
        int num2 = 0;
        IntPtr handle = base.Handle;
        handle.ToInt32();
        IntPtr window = handle;
        window = CaptureBrowser.GetWindow(window, 5);
        StringBuilder stringBuilder = new StringBuilder(256);
        try
        {
            while (num2 * this.screenHeight < this.heightsize)
            {
                int num3 = (this.screenHeight - 5) * num2;
                this.myDoc.Body.SetAttribute("scrollTop", num3.ToString());
                num2++;
            }
            num2--;
            for (int i = 0; i * this.screenWidth < this.widthsize; i++)
            {
                int num4 = (this.screenWidth - 5) * i;
                this.myDoc.Body.SetAttribute("scrollLeft", num4.ToString());
                num1 = short.Parse(this.myDoc.Body.GetAttribute("scrollLeft"));
                for (int j = num2; j >= 0; j--)
                {
                    graphic1 = Graphics.FromImage(bitmap);
                    IntPtr hdc = graphic1.GetHdc();
                    int num5 = (this.screenHeight - 5) * j;
                    this.myDoc.Body.SetAttribute("scrollTop", num5.ToString());
                    num = short.Parse(this.myDoc.Body.GetAttribute("scrollTop"));
                    CaptureBrowser.PrintWindow(window, hdc, 0);
                    graphic1.ReleaseHdc(hdc);
                    graphic1.Flush();
                    image = Image.FromHbitmap(bitmap.GetHbitmap());
                    graphic.DrawImage(image, num1 + this.URLExtraLeft, num + this.URLExtraHeight);
                }
            }
        }
        finally
        {
        }
        return bitmap1;
    }
...