Welcome to the forum

register! and help us get started! with this new darkgdk forum !

dont forget to introduce yourself Razz

enjoy! and good luck with your programming Smile

Color pixel swap

Go down

Color pixel swap Empty Color pixel swap

Post  hifistyle on Sat Mar 03, 2012 1:11 am

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?
//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"))
      dbPrint("ERROR: record.bmp does not exist.");

   dbPrint("Press any key to continue");

   // 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)
               else if (pixelColor == RED)



Posts : 2
Join date : 2012-02-14

View user profile

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum