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



Join the forum, it's quick and easy

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

Would you like to react to this message? Create an account in a few clicks or log in to continue.

Color pixel swap

Go down

Color pixel swap Empty Color pixel swap

Post  hifistyle 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?
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

Back to top Go down

Back to top


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