Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualC0lumbo

Posted 14 February 2013 - 02:30 AM

This seems to cover it http://old.nabble.com/monochrome-bitmaps-td21054168.html pretty well.

 

I think your function would look something like this - However, this is untested. I'm a little unsure about the "(cValue & (1 << (x & 7))) != 0" bit, if it doesn't work try replacing with "(cValue & (128 >> (x & 7))) != 0" - because it's not clear to me from a glance at the docs what the bit ordering is.

 

EDIT: Just changed "char cValue = pRow[x];" to "char cValue = pRow[x >> 3];"

 

bool GetPixelValue(const char *pBuffer, int iPitch, int x, int y)
{
    const char *pRow = &pBuffer[y*iPitch];
    char cValue = pRow[x >> 3];
    bool bRet = (cValue & (1 << (x & 7))) != 0;
    return bRet;
}

#1C0lumbo

Posted 14 February 2013 - 02:05 AM

This seems to cover it http://old.nabble.com/monochrome-bitmaps-td21054168.html pretty well.

 

I think your function would look something like this - However, this is untested. I'm a little unsure about the "(cValue & (1 << (x & 7))) != 0" bit, if it doesn't work try replacing with "(cValue & (128 >> (x & 7))) != 0" - because it's not clear to me from a glance at the docs what the bit ordering is.

 

bool GetPixelValue(const char *pBuffer, int iPitch, int x, int y)
{
    const char *pRow = &pBuffer[y*iPitch];
    char cValue = pRow[x];
    bool bRet = (cValue & (1 << (x & 7))) != 0;
    return bRet;
}

PARTNERS