The code looks like BGI (ancient Borland graphics interface for MS-DOS) which implies either emulation of BGI or real or emulated MS-DOS. Also it usually use only 16 color modes so you got only 16 indexes for colors from standard EGA/VGA palette. In case you use 256 colors you got standard VGA palette.
In this line:
putpixel(width,height,12);
the number 12 is the color used so you need to find which number is the orange you want. You can do that by rendering the whole palette like:
for (x=0;x<16<<2;x++)
for (y=0;y<16;y++)
putpixel(x,y,x>>2);
and count the index from the left starting with zero (do the 256 colors in more lines so you can still count the colors ...) You can also use this
Taken image from above link:
the numbers are in hex so 12 = 0x0C
which is red-ish. If your output got similar color than you got the same palette ... If not that means you got different palette (may be Linux or WEB palette)
Here also the standard VGA 256 color palette from the same link:
If wanted color is not present you need to redefine palette which can be done by accessing VGA I/O (reading palette) but will not be possible under Windows or Linux without IO priviledge access. Possibly your gfx lib got some functions doing/emulating it....
Another way is to use dithering so you take red and yellow and mix them (some pixels are red some yellow near by).
PS using put pixel is soo slooow you can render filled rectangles directly with BGI instead. It supports basic geometric shapes and more just see the BGI docs there are tons of them out there. I do not liked BGI at that time and did not use it at all as direct VGA/VESA VRAM access was way faster and better in any way. Using/learning it now is silly (unless you are forced to it by school). There are many alternatives see:
If you see the gfxinit()
function in that link there is a routine to change the 256 color VGA palette.
#include<graphics.h>
is not standard C++, and the name is so generic that I have no idea which 3rd-party library you might be talking about. On top of that, the code likely doesn't even compile, unless the mysteriousgraphics.h
header file defines two global variablesheight
andwidth
. – Sumatraputpixel
is (cs.colorado.edu/~main/bgi/doc/putpixel.html). – Tremulant<graphics.h>
. Alf already made a wrong guess - why you don't you finally tell us which library you are using? – Sumatra