Important alert: (current site time 7/15/2013 5:31:53 PM EDT)
 

VB icon

^!Using DOS Palettes!^

Email
Submitted on: 9/15/2002 11:03:27 PM
By: Josh Nixon  
Level: Beginner
User Rating: By 5 Users
Compatibility: C++ (general)
Views: 22680
author picture
(About the author)
 
     This is a example to show a person how to use more then 16 colors in dos but not all at once.
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :^!Using DOS Palettes!^
//**************************************
#include<graphics.h>
#include<dos.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ^!Using DOS Palettes!^
// Description:This is a example to show a person how to use more then 16 colors in dos but not all at once.
// By: Josh Nixon
//
// Assumes:This is a example to show a person how to use more then 16 colors in dos but not all at once.
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=4780&lngWId=3//for details.//**************************************

#include<graphics.h>
#include<dos.h>
class Colors
{
 private:
 int graphdriver, graphmode;
 //Palettetype Contains palette information for the current graphics driver
 palettetype pal;//Contains palette information for the current graphics driver
 public:
 void Init_Graphics()
{
initgraph(&graphdriver,&graphmode,"..\\BGI\\");
}
 void Intro();
 Colors::Colors()
 {
graphdriver = DETECT;
Init_Graphics();
//getpalette gets information about the current palette
getpalette(&pal);//GetPalette demands that a pointer be passed
 }
};
int main()
{
 Colors Colors;
 Colors.Intro();
 return 0;
}
void Colors::Intro()
{
 for(int I = 0; I < 63; I++)
 {
setbkcolor(1);
//Defines colors for IBM-8514 graphics card
setrgbpalette(pal.colors[1],I,I,I);
delay(100);
 }
 for(I = 63; I > 0; I--)
 {
settextstyle(DEFAULT_FONT,HORIZ_DIR,6);
setrgbpalette(pal.colors[2],I,I,I);
setcolor(2);
 outtextxy(getmaxx()/2-250,getmaxy()/2-20,"Color CRAZY");
 delay(100);
 }//end for
}


Other 35 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
9/17/2002 8:41:06 AM

i tried this code on tow compilers the first (DEV-C++) gave me this error message (#error BGI graphics not ANSI compatible)
the second compiler is (Borland C++ 5)it's message was (BGI graphics not supported under windows)
so what should i do
thank you
(If this comment was disrespectful, please report it.)

 
9/17/2002 7:15:00 PMJosh Nixon

Well this error means that you do not have the BGI drivers need to run the program. Search for grpahics.h on the internet and all its drivers and type the path were it is located. >>initgraph(&graphdriver,&graphmode,"..C:\\BGI\\");
(If this comment was disrespectful, please report it.)

 
1/9/2003 8:42:25 PM

I tried your code and it didn't work, it gave me 16 errors, I tried fixin em but it didn't work. Can ya help me there?
(If this comment was disrespectful, please report it.)

 
1/30/2003 7:10:17 PM

Josh is right, you need to find the Borland drivers and the proper graphics.h header file.
(If this comment was disrespectful, please report it.)

 
2/18/2003 11:01:43 PM

Have gotten graphics.h file for visual c++ 6..requuired _defs.h...heaps of errors, and obselete..help please
(If this comment was disrespectful, please report it.)

 
5/30/2003 10:50:45 AMTony G

"..\\BGI\\" cleared my error.
Thanks, its working on Borland C++ 3.0
(If this comment was disrespectful, please report it.)

 
7/5/2003 12:25:47 PM

Although this is old the thing is that the author uses a DOS compiler NOT A WINDOWS COMPILER! A windows compiler does not support interrupts, therefore you would have to switch compilers.
(If this comment was disrespectful, please report it.)

 
7/5/2003 11:39:31 PMJosh Nixon

Yes this is true why do you get mad at me for this. Its made in dos so why not use the compiler to do it in.
(If this comment was disrespectful, please report it.)

 
9/9/2003 7:05:30 AM

Hi there i have a problem i think you can help me(please) you know i can not include graphic.h in my program i using visual c++ 6.0(how and i find the graphic.h) thanks for your help
(If this comment was disrespectful, please report it.)

 
1/2/2006 2:41:07 PMRyan

This seems like a solid code once you get past all of the already mentioned errors but the absence of commentary makes this code hard to study; please revise.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.