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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:35:41+00:00 2026-05-30T03:35:41+00:00

I read this tutorial http://tipsandtricks.runicsoft.com/Cpp/BitmapTutorial.html about bitmap and it really helped..I need to read

  • 0

I read this tutorial http://tipsandtricks.runicsoft.com/Cpp/BitmapTutorial.html about bitmap and it really helped..I need to read color integer values from elements of pixel array. How to do that?
Ok heres the code for putting data into rgb array

BYTE* ConvertBMPToRGBBuffer ( BYTE* Buffer, int width, int height )
{

if ( ( NULL == Buffer ) || ( width == 0 ) || ( height == 0 ) )
    return NULL;

// find the number of padding bytes

int padding = 0;
int scanlinebytes = width * 3;
while ( ( scanlinebytes + padding ) % 4 != 0 )     // DWORD = 4 bytes
    padding++;
// get the padded scanline width
int psw = scanlinebytes + padding;

// create new buffer
BYTE* newbuf = new BYTE[width*height*3];

// now we loop trough all bytes of the original buffer, 
// swap the R and B bytes and the scanlines
long bufpos = 0;   
long newpos = 0;
for ( int y = 0; y < height; y++ )
    for ( int x = 0; x < 3 * width; x+=3 )
    {
        newpos = y * 3 * width + x;     
        bufpos = ( height - y - 1 ) * psw + x;

        newbuf[newpos] = Buffer[bufpos + 2];       
        newbuf[newpos + 1] = Buffer[bufpos+1]; 
        newbuf[newpos + 2] = Buffer[bufpos];     
    }

return newbuf;
    }
  • 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-30T03:35:43+00:00Added an answer on May 30, 2026 at 3:35 am

    It looks like your image is in RGB interleaved format. To get a pixel at (x,y), simply index the array at that location. It would be easiest if your buffer pointed to a structure type. Something like:

    typedef struct RGBPixel {
        BYTE red;
        BYTE green;
        BYTE blue;
    } RGBPixel;
    

    Then you could do something like this:

    RGBPixel* pixels = (RGBPixel*)newbuf;
    

    To get a pixel at (x,y), you’d do this:

    RGBPixel aPixel = pixels [ y * width + x ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently, I read this article: http://download.oracle.com/javase/tutorial/extra/generics/wildcards.html My question is, instead of creating a method
I have a silly question. I read this article about std::exception http://www.cplusplus.com/doc/tutorial/exceptions/ On catch
I read the following line in this Clojure tutorial - http://java.ociweb.com/mark/clojure/article.html#Macros 'Since macros don't
I am using this tutorial: http://developers.facebook.com/docs/opengraph/tutorial/ And I now need to define an action
I've been following the tutorial at http://iphonebyradix.blogspot.com/2011/03/read-and-write-data-from-plist-file.html showing how to extract data from a
I have read the tutorial from ibm about xml parsing (http://www.ibm.com/developerworks/opensource/library/x-android/) In this example,there
Few months ago i read this Swing tutorial http://zetcode.com/tutorials/javaswingtutorial/resizablecomponent/ for understanding how implementing resizable
I read this http://developer.android.com/resources/tutorials/notepad/index.html and now try to create my own simple example. For
I was just reading the http://www.meebo.com/ About Us page, and read this line :
I'm new to JSON and trying this tutorial: http://p-xr.com/android-tutorial-how-to-parse-read-json-data-into-a-android-listview/#comments I'm new to JSON, C

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.