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 7180401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:20:22+00:00 2026-05-28T17:20:22+00:00

I have a program that edits images in different ways… i have a Paint

  • 0

I have a program that edits images in different ways… i have a Paint event that is called every time i do this.Invalidate()…

My paint method looks like this:

 private void EditImage_Paint(object sender, PaintEventArgs e)
    {
        if (isLOaded == true)
        {

                Graphics graphicsWindow;   // reference to the graphic surface of this window
                Graphics graphicsImage;     // reference to in-memory surface

                theImage = new Bitmap(Width, Height);     // bitmap for window surface copy

                graphicsWindow = e.Graphics;   // get our current window's surface
                graphicsImage = Graphics.FromImage(theImage);     // create surfaces from the bitmaps

                graphicsImage.DrawImage(firstLoaded, 0, 0, Width, Height);



                if (isInvert == true)
                {
                    theImage = InvertBitmap(theImage);
                }
                else if (isGrayscale == true)
                {
                    theImage = GrayscaleBitmap(theImage);
                }
                else if (isThreshold == true)
                {
                    theImage = ThresholdBitmap(theImage);
                }
                else if (isResize == true)
                {
                    theImage = resizeImage(theImage, 10, 100);
                }
                else if (isFilterRed == true)
                {
                    theImage = FilterRedBitmap(theImage); 
                }
                else if (isFilterGreen == true)
                {
                    theImage = FilterGreenBitmap(theImage);
                }
                else if (isFilterBlue == true)
                {
                    theImage = FilterBlueBitmap(theImage);
                }

                graphicsWindow.DrawImage(theImage, 0, 0);

        }
    }

i have another area in my code which sets some boolean values to true or false within the Click events….(as my program uses winforms) and hence my program knows which method to call. However, i think putting all of these things inside of paint is just bad design. My issue is that i don’t know how to pass in a bitmap image into a Click event? Is that possible? I would much rather deal with what happens in the Click events rather than within the paint methods. Any idea on how i could design this better?

  • 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-05-28T17:20:23+00:00Added an answer on May 28, 2026 at 5:20 pm

    You should keep your paint events as fast as possible.

    You should store the final image in a field in the class and regenerate it when the options change.
    You can then replace your entire Paint event with a simple PictureBox.

    On a side note, you should either change the various Filter functions to modify the image in-place (preferred), or dispose the old image each time you create a new one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that takes in stacks of TIFF images and is very
I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
I have a program that spits out both standard error and standard out, and
I have a program that creates a Windows user account using the NetUserAdd() API
I have a program that uses the mt19937 random number generator from boost::random. I
I have a program that spits out an Excel workbook in Excel 2003 XML
I have a program that monitors debug messages and I have tried using a
I have a program that will calculate the minimal area taken by fitting rectangles
I have a program that runs osql.exe from microsoft sql server tools directory and

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.