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

The Archive Base Latest Questions

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

I have been experimenting with the Change HUE/Saturation example found on the EFG website:

  • 0

I have been experimenting with the Change HUE/Saturation example found on the EFG website: http://www.efg2.com/Lab/Library/Delphi/Graphics/Color.htm

enter image description here

I want to use the techniques found in that example to change the color values of some bitmaps (to be used on a TImage). There is one problem I am facing, and that is with TImages that have transparent bitmaps; I don’t want the background color to change its HUE but rather just the actual image data.

Take this sample image we can work with (though any image with transparency can be used):

enter image description here

  • Download the Change HUE/Saturation demo from the link at the top.
  • Now Load the button image above into the ImageOriginal.
  • Set the Delta Saturation to 1.
  • Run the Project.

Some output results:

enter image description here enter image description here

What I would like to happen here is keep the original background color (defined by the bottom left most pixel) and only adjust the hue for the rest of the image. So, the output results would actually look like this (edited in Paint.NET):

enter image description here enter image description here

Allow me to use another sample image to test with that contains more image data:

enter image description here

As before with the first image sample, the results could be something like:

enter image description here enter image description here

When the results I desire should be like so:

enter image description here enter image description here

One idea I had was after the HUE change, replace the bottom left most color with the color from the original, but I am not sure if this is the correct approach or not, and even if it is I am not sure how to replace color X for another color. (Graphics and Math is beyond me).

For example, if I drew two blue color circles on Mickey’s ear (the blue been the original transparent color from bottom left most pixel) and also colored his eyes:

enter image description here

Changing the HUE again may look like:

enter image description here

when in fact it should like this:

enter image description here

Simply put I would like to change the HUE of an image whether it be by the methods used from the EFG demo or another solution. The transparent color as defined by the bottom most left pixel should not be changed when the HUE is changed, this should remain the same as demonstrated in the sample images.

How can I change the HUE of a bitmap whilst retaining the background color?

  • 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-04T03:34:10+00:00Added an answer on June 4, 2026 at 3:34 am

    The code you refer walks all pixels on the image to change hue/saturation. You can modify the code so that it does not interfere if a pixel has a specific color:

    PROCEDURE TFormChangeHS.UpdateBitmap;
        ..
        S              :  TReal;
        V              :  TReal;
    
        FixColor: TRGBTriple;                            // New variable
    BEGIN
      DeltaSaturation := SpinEditDeltaSaturation.Value;
      NewHue := TrackBarHue.Position;
    
      Bitmap := TBitmap.Create;
      TRY
        Bitmap.Width  := ImageOriginal.Width;
        Bitmap.Height := ImageOriginal.Height;
        Bitmap.PixelFormat := ImageOriginal.Picture.Bitmap.PixelFormat;
        ASSERT(Bitmap.PixelFormat = pf24bit);
    
        // save bottom left color
        FixColor := PRGBTripleArray(
                      ImageOriginal.Picture.Bitmap.ScanLine[Bitmap.Height - 1])^[0];
        //--
    
        FOR j := 0 TO Bitmap.Height-1 DO
        BEGIN
          RowIn  := ImageOriginal.Picture.Bitmap.Scanline[j];
          RowOut := Bitmap.Scanline[j];
          FOR i := 0 TO Bitmap.Width-1 DO
          BEGIN
            WITH RowIn[i] DO
            BEGIN
    
              // copy the color to target and continue with next iteration
              if (RowIn[i].rgbtBlue = FixColor.rgbtBlue) and
                  (RowIn[i].rgbtGreen = FixColor.rgbtGreen) and
                  (RowIn[i].rgbtRed = FixColor.rgbtRed) then begin
                RowOut[i] := FixColor;
                Continue;
              end;
              //--
    
              // convert pixel coordinates to HSV
              RGBtoHSV(rgbtRed, rgbtGreen, rgbtBlue, H, S, V);
            END;
            ..
            ..
    

    Output:  

    enter code here

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

Sidebar

Related Questions

I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I have been experimenting with a lot of web development apps like Drupal, Moodle,
I have been experimenting with writing applications that use a local SQL Database to
I have been experimenting with sending messages from two .NET Windows Forms applications using
I have been experimenting with TMask in Delphi 2010 and it seems to work
I have been experimenting some problems with the fully distributed version. First of all
I'm working on building a tree structure in MySQL and have been experimenting with
I have been experimenting with LOAD DATA INFILE and there are a couple things
I have been experimenting with PulpCore, trying to create my own tower defence game
I have been experimenting with async Linux network sockets (aio_read et al in aio.h/librt),

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.