Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:10:09+00:00 2026-06-10T15:10:09+00:00

I use a Gecko .NET WebBrowser control to get the HTML page. Then I

  • 0

I use a Gecko .NET WebBrowser control to get the HTML page.

Then I use this code to make a screenshot of this HTML page:

void LoadingFinished(object sender, EventArgs args)
{
    try
    {
        myBrowser.Document.Body.SetAttribute("style", "overflow:hidden");
        if (screenshotkey != "")
        {
            Bitmap bitmap = new Bitmap(myBrowser.Width, myBrowser.Height);
            myBrowser.DrawToBitmap(bitmap, new Rectangle(0, 0, myBrowser.Width, myBrowser.Height));
            bitmap.Save("Screenshots/" + screenshotkey + ".png", ImageFormat.Png);
        }
    }
    catch (Exception dfkvsn)
    {
        errorloadingpage();
    }
}

I removed some stuff from the code above that is not very important – like setting browser width, etc. Originally the code is 100% functional.

The problem is that when it saves a png screenshot (DrawToBitmap line) – at some places the created picture has the white pixels that should not be there (WebBrowser originally does not have them), see the link.

Same thing was happening when I was using standard .NET WebBrowser control, so it’s not Gecko problem.

I have no idea how to approach this.
Is there a better way to save it to bitmap? Or is this the best .NET can do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:10:11+00:00Added an answer on June 10, 2026 at 3:10 pm

    Fixed it.
    It turned out that pixels that seemed to be white – were just transparent.
    And they were only in places where picture had a deepest black color (RGB 0, 0, 0)
    For some reason .NET couldn’t save this color to the file.
    So I simply added the line of code that makes entire picture black, and on top of that I record my screenshot.
    Since it’s 2 layers now – transparent pixels now seem to be black – just what I wanted – no white pixels.
    Here’s the final code:

    void LoadingFinished(object sender, EventArgs args)
            {
                try
                {
                    myBrowser.Document.Body.SetAttribute("style", "overflow:hidden");
                    if (screenshotkey != "")
                    {
                        panel1.Height = myBrowser.Document.Body.ScrollHeight;
                        panel1.Width = myBrowser.Document.Body.ScrollWidth;
                        this.Size = new System.Drawing.Size(panel1.Width+20, panel1.Height+20);
    
                        if (!Directory.Exists("Screenshots"))
                        {
                            Directory.CreateDirectory("Screenshots");
                        }
    
                        Bitmap bitmap = new Bitmap(myBrowser.Width, myBrowser.Height);
                        for (int Xcount = 0; Xcount < bitmap.Width; Xcount++)
                        {
                            for (int Ycount = 0; Ycount < bitmap.Height; Ycount++)
                            {
    
                                bitmap.SetPixel(Xcount, Ycount, Color.Black);
                            }
                        }
                        myBrowser.DrawToBitmap(bitmap, new Rectangle(0, 0, myBrowser.Width, myBrowser.Height));
                        bitmap.Save("Screenshots/" + screenshotkey + ".png", ImageFormat.Png);
                    }
                }
                catch (Exception dfkvsn)
                {
                    errorloadingpage();
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this: http://datatables.net/release-datatables/examples/api/select_row.html Here is function return selcted rows: function fnGetSelected( oTableLocal )
I am searching for a substitute of the WebBrowser control in .NET which can
I tried to use this script pdfmeat to get data about papers from google
I'm trying to use instead of usual HttpWebRequest // get a login page HttpWebRequest
I'm trying to use HTTPClient to get a page, but it seems to return
Have this code: set_time_limit(100); ini_set('user_agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101
Three questions about the Mozilla engine (Gecko/XUL): Is it possible to use its HTML
Use of gradient images is very common among developers for styling a page. Gradient
ASP.NET 4.0 Need some help with this vexing HTTP POST problem - I have
Well, here's the code: <? // Getting the comic page if (!empty($_GET['c'])) $id =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.