Color pixel swap
:: DarkGDK :: DarkGDK Help
Page 1 of 1
Color pixel swap
So, we're only a few chapters in before we start the real stuff. I need to read all the pixels (x,y) and if they are red, make them blue and vise versa. I'm just not getting the dbDot code right. Can someone take a look and point me in the right direction?
- Code:
//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;
// Width and Height variables.
int width;
int height;
// 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();
// Get the images width and height.
width = dbBitmapWidth(0);
height = dbBitmapWidth(0);
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;
}
}
hifistyle- Posts : 2
Join date : 2012-02-14
:: DarkGDK :: DarkGDK Help
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|