Hi everybody. Usually I would keep to myself and keep at it until I either figure it out or give up, but I really want to figure this out so I'm here posting and hopefully someone wiser will direct me.
I am going by the book Games and Graphics in C++ by Tony Gaddis and am having some difficulty getting one of the programs to work right. I know from other posts that their is an issue with vista/7 and some of the functions but I am using XP and am having trouble.
The point of this program is to go pixel by pixel through the bitmap and count whether it is a pure blue pixel (0, 0, 255) or not. If it is, increment totalBlue. When done, output the result but the output is always 0. Here is the code word for word from the book.
#include "DarkGDK.h"
void DarkGDK()
{
const DWORD BLUE = dbRGB(0, 0, 255);
DWORD pixelColor;
int width;
int totalBlue = 0;
dbLoadBitmap("BlueBars.bmp", 0);
width = dbBitmapWidth(0);
for (int x = 0; x < width; x++)
{
pixelColor = dbPoint(x, 0);
if (pixelColor == BLUE)
{
totalBlue++;
}
}
dbCenterText(319, 450, "Press any key.");
dbWaitKey();
// Clear the screen and display the number of blue pixels.
dbClear(0, 0, 0);
dbPrint("Number of pure blue pixels in the top row:");
dbPrint( dbStr(totalBlue) );
dbWaitKey();
}
Any help will be appreciated.