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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:40:16+00:00 2026-06-10T03:40:16+00:00

How can I replace specific color(RGB value) in CGBitmapContext that has already drawn? Is

  • 0

How can I replace specific color(RGB value) in CGBitmapContext that has already drawn?

Is there any easy way?

Thanks in advance.

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

    You’ll want to get a pointer to the pixels and information about their format by doing something like this:

    // This assumes the data is RGBA format, 8-bits per channel. 
    // You'll need to verify that by calling CGBitmapContextGetBitsPerPixel (), etc.
    typedef struct RGBA8 {
        UInt8 red;
        UInt8 green;
        UInt8 blue;
        UInt8 alpha;
    } RGBA8;
    
    RGBA8* pixels = CGBitmapContextGetData (context);
    UInt32 height = CGBitmapContextGetHeight (context);
    UInt32 width = CGBitmapContextGetWidth (context);
    UInt32 rowBytes = CGBitmapContextGetBytesPerRow (context);
    UInt32 x, y;
    for (y = 0; y < height; y++)
    {
        RGBA8* currentRow = (RGBA8*)((UInt8*)pixels + y * rowBytes);
        for (x = 0; x < width; x++)
        {
            if ((currentRow->red == replaceRed) && (currentRow->green == replaceGreen) &&
                (currentRow->blue == replaceBlue) && (currentRow->alpha == replaceAlpha))
            {
                currentRow->red = newRed;
                currentRow->green = newGreen;
                currentRow->blue = newBlue;
                currentRow->alpha = newAlpha;
            }
            currentRow++;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if there is any way that I can replace substrings within
Is there any PHP PDF library that can replace placeholder variables in an existing
How can replace arabic number with latin number as that doesn't change number into
How i can replace any character except 0-9 a-z and and array of some
I know that with Vim's substitution command you can specific a range of lines:
How can I select all elements that have a specific CSS property applied, using
I want a function which can replace substring in a big string with specific
In my specific case I have (function(){ and I want to replace that with
My input is javascript code that I can pre-process.. at some specific point in
Note This is not a REBOL-specific question. You can answer it in any language.

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.