hifistyle 0 Newbie Poster

We're just getting started on DarkGDK and I thought I was doing okay. The assignment is to "go through" every pixel in an image and "swap" the blue and red one.
My program gets hung up after the first dbWait(), and I'm not sure if any thing is happening so I don't know if the code is even working. I'm also not sure if I should be trying to "write" dbDot color the way that I am.

//Chapter 6 exercise 4, red & blue pixel swap.
#include "DarkGDK.h"

//*************************************************
// DarkGDK function                               *
//*************************************************
void DarkGDK()
{

	// Color constants
	const DWORD  RED = dbRGB(255, 0, 0);
	const DWORD BLUE = dbRGB(0, 0, 255);
	const DWORD GREEN = dbRGB(0,255,0);

	// Variable to hold pixel color.
	DWORD pixelColor = 0;

	// Width and Height variables.
	int width = dbBitmapWidth(0);
	int height = dbBitmapHeight(0);

	// Variables to hold red, green, and blue components of RGB color.
	int redChannel;
	int greenChannel;
	int blueChannel;
	
	
	// Extract the red, gree, and blue
	// components of the color.
	redChannel = dbRGBR(pixelColor);
	greenChannel = dbRGBG(pixelColor);
	blueChannel = dbRGBB(pixelColor);


if ( dbFileExist("record.bmp"))
	{
		dbLoadBitmap("record.bmp",0);
	}
	else
	{
		dbPrint("ERROR: record.bmp does not exist.");
	}

	dbPrint("Press any key to continue");
	dbWaitKey();

	
	for (int x = 0; x < width; x++)
	{
		for(int y = 0; y < height; y++)
		{
			pixelColor = dbPoint(x,y);

			if (pixelColor == BLUE)
			{
				dbDot(x,y);
				RED;
			}
				else if (pixelColor == GREEN)
				{
				dbDot(x,y);
				GREEN;
				}
					else if (pixelColor == RED)
					{
					dbDot(x,y);
					BLUE;
					}

		
		}

	}
	dbWaitKey();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.