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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:52:57+00:00 2026-05-16T02:52:57+00:00

CImg<unsigned char> src(image.jpg); int width = src.width(); int height = src.height(); unsigned char* ptr

  • 0
CImg<unsigned char> src("image.jpg");
int width = src.width();
int height = src.height();
unsigned char* ptr = src.data(10,10); 

How can I get rgb from ptr?

  • 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-16T02:52:57+00:00Added an answer on May 16, 2026 at 2:52 am

    From the CImg documentation — section 6.13 on page 34, and section 8.1.4.16 on page 120 — it looks like the data method can take four arguments: x, y, z, and c:

    T* data(const unsigned int x, const unsigned int y = 0, 
            const unsigned int z = 0, const unsigned int c = 0)
    

    …where c refers to the color channel. I’m guessing that if your image is indeed an RGB image, then using values of 0, 1, or 2 for c will give you the red, green, and blue components at a given x, y location.

    For example:

    unsigned char *r = src.data(10, 10, 0, 0);
    unsigned char *g = src.data(10, 10, 0, 1);
    unsigned char *b = src.data(10, 10, 0, 2);
    

    (But this is just a guess!)

    Edit:

    It looks like there’s also an operator() for CImg that works in a similar manner:

    unsigned char r = src(10, 10, 0, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

const unsigned int omode = cimg::exception_mode(); cimg::exception_mode() = 0; Never see this kinda syntax
I wish to use the CImg library for image processing in my current project.
Possible Duplicate: What does the explicit keyword in C++ mean? explicit CImg(const char *const
Can anyone recommend a decent C image library? I'm after loaders for bmp, gif,
I have some troubles with saving a image from memorystream. Here is my code:
I use the CImg library to write plugins for an image-editing software I created.
i get this error when i add CIMG library to Xcode: 'cstdio' file not
I wrote a small image processing algorithm using the CImg library and bundled it
I built an application in Qt Creator that does some image processing with CImg.
Below, I have a simple program which uses the CImg library (http://cimg.sourceforge.net/) which iterates

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.