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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:36:48+00:00 2026-05-20T14:36:48+00:00

I am using c++, gdi+,WINDOWS. How to check whether a jpeg is a RGB

  • 0

I am using c++, gdi+,WINDOWS.
How to check whether a jpeg is a RGB or CMYK?

  • 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-20T14:36:48+00:00Added an answer on May 20, 2026 at 2:36 pm

    If you use the IJG libjpeg library, you can open the JPEG file, read the header, and see whether is it grayscale (monochrome), RGB, or CMYK. (Actually, there are several free JPEG libraries, but the IJG libjpeg is probably the most commonly used.) You can find libjpeg sources at:

    http://www.ijg.org/files/jpegsrc.v8c.tar.gz

    An approximate example of how to read the header would be something like:

    struct jpeg_decompress_struct dinfo;
    FILE* file = fopen(fname, "r");
    
    /* Step 1: allocate and initialize JPEG decompression object */
    jpeg_create_decompress(&dinfo);
    
    /* Step 2: specify data source (eg, a file) */
    jpeg_stdio_src(&dinfo, file);
    
    /* Step 3: read file parameters with jpeg_read_header() */
    (void) jpeg_read_header(dinfo, TRUE);
    
    /* Step 4: set parameters for decompression
     * In this example, we don't need to change any of the 
     * defaults set by jpeg_read_header(), so we do nothing here.
     */
    if (dinfo->jpeg_color_space == JCS_CMYK || dinfo->jpeg_color_space == JCS_YCCK) {
        // CMYK
    } else if (dinfo->jpeg_color_space == JCS_RGB || dinfo->jpeg_color_space == JCS_YCbCr) {
        // RGB
    } else if (dinfo->jpeg_color_space == JCS_GRAYSCALE) {
        // Grayscale
    } else {
        ERREXIT(dinfo, JERR_CONVERSION_NOTIMPL);
        // error condition here...
    }
    
    /* You can skip the other steps involved in decompressing an image */
    
    /* Step 8: Release JPEG decompression object */
    jpeg_destroy_decompress(dinfo);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to display some text in my program using (say) Windows GDI and
I'm attempting to display some text in my program using (say) Windows GDI and
I'm trying to achieve high frame-per-second on Windows GDI by using Windows Timer Queues.
I have an image i.e. drawn using Windows GDI calls (24 bpp) and I
In Windows XP the Win32 API renders the controls using GDI/GDI+. Now I'm on
I've known about screen capture using Device Contexts and GDI, since windows XP. Is
Summary Using Windows GDI to convert 24-bit color to indexed color, it seems GDI
I'm painting this object in C# using GDI and I need to have precise
I'm developing a graph control in WPF. I have previously developed it using GDI
I noticed using task manager that the following code has a GDI leak in

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.