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

  • Home
  • SEARCH
  • 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 3695572
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:38:02+00:00 2026-05-19T04:38:02+00:00

I have a delegate private delegate Color ColorDel(int x, int y); which returns a

  • 0

I have a delegate

private delegate Color ColorDel(int x, int y);

which returns a color at a point, to be used with Bitmap.GetPixel(x,y)

Even though i put the color into the bitmap directly before, as a Color.Red,
the return color is the same to all the ARGB but not on the name, which is ffff0000 instead of Red as the Color.Red actually is.
ToKnownColor doesnt do the trick either.

Any input on the matter?

Edit, code:

class ColorDelegateTest
    {
        private delegate Color ColorDel(int x, int y);

        private static bool FoundColor(int x, int y, Color color, ColorDel dlgt)
        {
            var theColor = dlgt.Invoke(x, y);
            //theColor = "{Name=ffff0000, ARGB=(255, 255, 0, 0)}"
            //Color.Red = "{Name=Red, ARGB=(255, 255, 0, 0)}"
            var r = dlgt.Invoke(x, y) == color; //False
            var t = dlgt.Invoke(x, y) == Color.FromArgb(255, 255, 0, 0); //True
            var f = dlgt.Invoke(x, y) == Color.Red; //False
            if (r || t || f)
                return true;
            return false;
        }
        private static void ItterateColors()
        {
            int xMax = 300;
            int yMax = 300;
            Bitmap bmp = new Bitmap(xMax, yMax);

            ColorDel colorDelegate = new ColorDel(bmp.GetPixel);

            for (int x = 0; x < xMax; x++)
                for (int y = 0; y < yMax; y++)
                {
                    bmp.SetPixel(x, y, Color.Red);
                    FoundColor(x, y, Color.Red, colorDelegate);
                }
        }
    }

Erik

  • 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-19T04:38:03+00:00Added an answer on May 19, 2026 at 4:38 am

    Color.Red includes a bit indicating that it is a known color, while Color.FromArgb(255, 0, 0) does’t so they don’t compare as equal. One way to do the comparison is to just compare with .ToArgb():

    dlgt.Invoke(x, y).ToArgb() == Color.Red.ToArgb()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) {
I have the following code: class myClass { private delegate string myDelegate(Object bj); protected
Does the Java language have delegate features, similar to how C# has support for
I have a UISearchBar and on the delegate method I hide the keyboard when
Here is my setup. In my application delegate, I have a property called currentFoo.
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have a created a following renderer which renders the JTree with checkboxes and
I have a class that serves as a delegate to another. public class Delegate
Have just started using Google Chrome , and noticed in parts of our site,

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.