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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:12:12+00:00 2026-06-04T15:12:12+00:00

I have some C# code that is doing key-color replacement based on hue. On

  • 0

I have some C# code that is doing key-color replacement based on hue. On my local machine, it’s executing perfectly. However when I push it up to the server it replaces “some” but not all of the colors. It’s like it’s just deciding not to run part of the code.

The images are lossless PNGs – they are intact on the server. Is this some kind of threading issue? My code is not threaded here (beyond what the webserver does), but has anyone ever seen anything similar happen?

It might also help if I mention that this code is compiled in a separate library project and then referenced from an MVC3 application.

Thanks, and here is the code sample:

private void _ReplaceImageColor(Image img, Color baseColor, Color newColor)
{
    Bitmap bmp = (Bitmap)img;
    double baseHue = baseColor.GetHue();
    for (int x = 0; x < bmp.Width; x++)
    {
        for (int y = 0; y < bmp.Height; y++)
        {
            double pixelHue, pixelSat, pixelVal;
            ColorProcessor.ColorToHSV(bmp.GetPixel(x, y), out pixelHue, out pixelSat, out pixelVal);
            if (pixelHue == baseHue)
            {
                Color setColor = ColorProcessor.ColorFromHSV(newColor.GetHue(), pixelSat, pixelVal);
                bmp.SetPixel(x, y, setColor);
            }
        }
    }
}

Here’s the methods from ColorProcessor since people asked…

public static void ColorToHSV(Color color, out double hue, out double saturation, out double value)
{
    int max = Math.Max(color.R, Math.Max(color.G, color.B));
    int min = Math.Min(color.R, Math.Min(color.G, color.B));

    hue = color.GetHue();
    saturation = (max == 0) ? 0 : 1d - (1d * min / max);
    value = max / 255d;
}

public static Color ColorFromHSV(double hue, double saturation, double value)
{
    int hi = Convert.ToInt32(Math.Floor(hue / 60)) % 6;
    double f = hue / 60 - Math.Floor(hue / 60);

    value = value * 255;
    int v = Convert.ToInt32(Math.Max(value, 0));
    int p = Convert.ToInt32(Math.Max(value * (1 - saturation), 0));
    int q = Convert.ToInt32(Math.Max(value * (1 - f * saturation), 0));
    int t = Convert.ToInt32(Math.Max(value * (1 - (1 - f) * saturation), 0));

    if (hi == 0)
        return Color.FromArgb(255, v, t, p);
    else if (hi == 1)
        return Color.FromArgb(255, q, v, p);
    else if (hi == 2)
        return Color.FromArgb(255, p, v, t);
    else if (hi == 3)
        return Color.FromArgb(255, p, q, v);
    else if (hi == 4)
        return Color.FromArgb(255, t, p, v);
    else
        return Color.FromArgb(255, v, p, q);
}
  • 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-04T15:12:13+00:00Added an answer on June 4, 2026 at 3:12 pm

    You might want to check very carefully that your dll references are the same on the server as on the dev machine. Hanselman had an article on that very thing recently: Confirm Your Expectations and Version Numbers in Production Environments

    Also, since it is behaving differently on debug versus release mode check that it is using the same bitness in the build to eliminate that potential variation (e.g. x86) which can manifest on floating point numbers.

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

Sidebar

Related Questions

I have some jquery code that is doing an ajax lookup and returning comma
I have some code that sets up a dictionary with some defualt values for
I have some code that gets the current logged in user. userID = request.session.get(_auth_user_id)
I have some code that is using SyncEnumerator. As you can see here ,
I have some code that I'd like to run on a page. My problem
I have some code that inserts a list item into a list... I then
I have some code that dynamically creates a new button through JavaScript that when
I have some code that at one part will get executed a lot, and
I have some code that attempts to test whether my application is running with
I have some code that does MemoryStream ms = new MemoryStream(); ... return Image.FromStream(ms);

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.