Пример #1
0
int pacova::inicializa_modo_grafico()
{

  GraphDriver = VGA; 	     	/* Request auto-detection */
  GraphMode = VGAHI;
  initgraph(&GraphDriver, &GraphMode, "");
  ErrorCode = graphresult();		/* Read result of initialization */

  if(ErrorCode != grOk )		/* Error occured during init  */
	return ErrorCode;

  getpalette(&palette);			/* Read the palette from board*/
  max_cores = getmaxcolor() + 1;	/* Numero M�ximo de Cores */

  max_x = getmaxx();
  max_y = getmaxy();		     	/* Tamanho da Tela		  		*/

  return ErrorCode;
}
Пример #2
0
void main()
{
int gd=DETECT,gm,i,j,x,y,color,startcolor,height,width;
struct palettetype palette;
struct viewporttype vp;

initgraph(&gd,&gm,"d:\\tc\\bgi");

getpalette(&palette);

rectangle(0,20,639,479);
outtextxy(200,10,"Palette demonstration");
getviewsettings(&vp);
width=(vp.right-vp.left)/16;
height=(vp.bottom-vp.top-20)/16;
x=0;
y=20;
startcolor=0;
for(j=0;j<=15;j++)
	{
	color=startcolor;
	for(i=0;i<=15;i++)
		{
		setfillstyle(SOLID_FILL,color++);
		bar(x,y,x+width,y+height);
		x=x+width+1;
		}
	startcolor++;
	x=0;
	y+=height+1;
	}
getch();

while(!kbhit())
   setpalette(random(16),random(65));

setallpalette(&palette);

getch();
closegraph();
restorecrtmode();
}
Пример #3
0
void Initialize(void)
{
  int xasp, yasp;			/* Used to read the aspect ratio*/

  int driver = DETECT; 		/* Request auto-detection	*/
  int mode;
	initgraph( &driver, &mode,"e:\\tc\\bgi");
  ErrorCode = graphresult();		/* Read result of initialization*/
  if( ErrorCode != grOk ){		/* Error occured during init	*/
	printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) );
	exit( 1 );
  }

	getpalette( &palette );		/* Read the palette from board	*/
  MaxColors = getmaxcolor() + 1;	/* Read maximum number of colors*/

  MaxXX = getmaxx();
  MaxYY = getmaxy();			/* Read size of screen		*/

  getaspectratio( &xasp, &yasp );	/* read the hardware aspect	*/
  AspectRatio = (double)xasp / (double)yasp; /* Get correction factor	*/

}
Пример #4
0
int main() {
	int unidad = 0,modo,i;
	char s[10];
	struct palettetype palette;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		printf ("Error al tratar de pasar al modo grafico\n");
		getch();
		return 1;
	}
	getpalette (&palette);
	closegraph();
	for (i = 0; i <= palette.size - 1; i++) {
		cout << "Color de la posicion #";
		cout.width (3);
		cout << i << ' ';
		cout.width (3);
		cout << (int)palette.colors[i] << endl;
	}
	getch();
	return 0;
}
Пример #5
0
int main(void)
{
   int gdriver, gmode;

   /* install a user written device driver */
   gdriver = installuserdriver("svga256", detectSVGA256);

   /* must force use of detection routine */
   gdriver = DETECT;

   /* check for any installation errors */
    /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "d:\\prog\\project\\");
   int y1=getmaxy();
   int x=getmaxx();

   struct palettetype pal;
float i, ht, y, xmax;
   getpalette(&pal);
   /* check for any initialization errors */
       /* draw a line */
    for (i=0; i<pal.size; i++)
   setrgbpalette(pal.colors[i], i*4, i*4, i*4);
   setcolor(9);
   line(0, 0, getmaxx(), getmaxy());
    ht = getmaxy() / 255;
xmax = getmaxx();
y = 0;
for (i=0; i<256; i++)
{
   static int t[]={0,0,0,50,50,50,50,0,};
   setfillstyle(SOLID_FILL, i);
   setcolor(0);
   fillpoly(4,t);
   char cnum[10];
   settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
   setcolor(0);
   itoa(i,cnum,10);
   outtextxy(t[0],t[1],cnum);
   for(int i=0;i<8;i+=2)
   t[i]+=50;
   //bar(0, y, xmax, y+ht);
   y += ht;
   if(t[4]>getmaxx())
   {for(int i=0;i<8;i+=2)
   t[i+1]+=50;
   for(i=0;i<4;i+=2)
   t[i]=0;
   for(i=4;i<8;i+=2)
   t[i]=50;}
//   getch();

}    setcolor(59);
   //line(0, 0, getmaxx(), getmaxy());
    //circle(0,0,500);
    printf("%i%i",x+1,y1+1);
    //printf(" hello %i",getpalettesize());
   /* clean up */
    getch();
   closegraph();
   return 0;
}
Пример #6
0
void showlogo()
{
	struct bitfileheader
	{
		int  bfType;
		long bfSize;
		int  bfReserved1;
		int  bfReserved2;
		long bfOffBits;
		long biSize;
		long biWidth;
		long biHeight;
		int  biPlanes;
		int  biBitCount;
		long biCompression;
		long biSizeImage;
		long biXPelsPerMeter;
		long biYPelsPerMeter;
		long biClrUsed;
		long byClrImportant;
	};

	int xmax = getmaxx();
	int ymax = getmaxy();
	bitfileheader testing;
	palettetype pal;
	getpalette(&pal);
	int i, j;
	char blue, green, red, pix1, pix2, pixel, alpha;
	mouse_data mouse;

	cleardevice();

	if(!init_mouse())
	{
		closegraph();
		cout << "Mouse couldn't be initialised";
	}

	hide_mouse();

	fstream bitmap("logo.saq", ios::in);

	bitmap.read((char*)&testing, sizeof testing);

	for (i = 0; i< pal.size; i++)
	{
		bitmap.read(&blue,1);
		bitmap.read(&green,1);
		bitmap.read(&red,1);
		bitmap.read(&alpha,1);
//		setrgbpalette(pal.colors[i],(int)red,(int)green,(int)blue);
	}

	for (i = 1; i<= testing.biHeight; i++)
		for (j = 1; j <= testing.biWidth; j+=2)
		{
			bitmap.read(&pixel, 1);
			pix1 = pixel & 0xF0;
			pix1 >>= 4;
			pix2 = pixel & 0x0F;
			putpixel(j,   testing.biHeight - i,pix1);
			putpixel(j+1, testing.biHeight - i,pix2);
		}

	show_mouse();
	do
	{
		read_mouse(&mouse);
	}while(!kbhit() || !button_press(LEFT_BUTTON, &mouse));
		
}
Пример #7
0
int DBMPLoad( char *FileName )
{
 int Handle;
 unsigned char far *Palette=(unsigned char far *)farmalloc(SIZE_OF_PALETTE); // 4: R+G+B+UNUSED
 unsigned int  DataSize;
 unsigned int i, x=0, y=0, RealWidth, Read;
 tBMPHeader BMPHeader;
 tBITMAPINFOHEADER BITMAPINFOHEADER;
 struct palettetype PaletteType;

 if( !FileName ) return 0;
 if( !Palette ) return 0;

 // read headers
 if (_dos_open(FileName, O_RDWR | O_BINARY, &Handle) != 0) return 1;
 _dos_read( Handle, &BMPHeader, sizeof(BMPHeader), &Read );

 _dos_read( Handle, &BITMAPINFOHEADER, sizeof(BITMAPINFOHEADER), &Read );

 _dos_read( Handle, Palette, SIZE_OF_PALETTE, &Read );

 DataSize=BMPHeader.bfSize-sizeof(BITMAPINFOHEADER)-sizeof(BMPHeader)-SIZE_OF_PALETTE;
 unsigned char far *DataBuffer=(unsigned char far *)farmalloc(DataSize);
 if( DataBuffer==NULL ) return 0;
 _dos_read( Handle, DataBuffer, DataSize, &Read );

 _dos_close(Handle);

 RealWidth=(BMPHeader.bfSize-BMPHeader.bfOffBits)/BITMAPINFOHEADER.biHeight-1;

 if( BMPHeader.bfType!=19778 )   // "BM"=19778
  return 1;

 getpalette(&PaletteType);       // get system pallette
 //   Setting pallette:
 //   INT 10H,  AH=10H, AL=10H, BX = number of register to set
 //			      DH = red value
 //			      CH = green value
 //			      CL = blue value
 union  REGS registr;

 for (i=0; i<256; i++)
  {
   registr.h.bh=0;
   registr.h.bl=i;
   registr.h.dh=Palette[i*4+2]>>2;//    color must be shifted!!!
   registr.h.ch=Palette[i*4+1]>>2;
   registr.h.cl=Palette[i*4+0]>>2;

   registr.h.ah=0x10;
   registr.h.al=0x10;

   int86(0x10,&registr,&registr);
  }

 // drawing picture
 for(i=DataSize; i>0; i--)
 {
  if( x>RealWidth) { y++; x=0; }
  putpixel(RealWidth-x, y,(char)DataBuffer[i-1]);
  x++;
 }

 farfree( DataBuffer );
 farfree( Palette );
 return 0;
}
Пример #8
0
int main() {
	int unidad = 0,modo;
	int fondo,dibujo,i;
	fillsettingstype p;
	viewporttype v;
	palettetype palette;
	linesettingstype linea;
	textsettingstype letra;

	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}

	graphdefaults();

	getfillsettings (&p);
	getviewsettings (&v);
	getpalette (&palette);
	fondo = getbkcolor();
	dibujo = getcolor();
	getlinesettings (&linea);
	gettextsettings (&letra);

	restorecrtmode();

	printf ("%s\n","Patron para colorear y color");
	printf ("%d\n",p.pattern);
	printf ("%d\n",p.color);	// Retorna el numero de la celda...
	printf ("%s\n","Oprima una tecla....");
	getch();
	printf ("%s\n","Dimensiones del viewport");
	printf ("%d %s %d\n",v.left,",",v.top);
	printf ("%d %s %d\n",v.right,",",v.bottom);
	if (v.clip)
		printf ("%s\n","True");
	else printf ("%s\n","False");
	printf ("%s\n","Oprima una tecla....");
	getch();
	printf ("%s\n","Estado original de la palette");
	printf ("%s %d\n","Size=",palette.size);
	for (i = 0; i <= palette.size-1; i++ )
		printf ("%d\n",palette.colors [i]);
	printf ("Oprima una tecla....\n");
	getch();
	printf ("Color de fondo y color para dibujar\n");
	printf ("%d\n",fondo);
	printf ("%d\n",dibujo);
	printf ("Oprima una tecla....\n");
	getch();
	printf ("Estilo de linea y patron\n");
	printf ("%d\n",linea.linestyle);
	printf ("%d\n",linea.upattern);
	printf ("Oprima una tecla....\n");
	getch();
	printf ("Estilo de letra y dimensiones\n");
	printf ("%d\n",letra.font);
	printf ("%d\n",letra.direction);
	printf ("%d\n",letra.charsize);
	printf ("%d\n",letra.horiz);
	printf ("%d\n",letra.vert);
	printf ("Oprima una tecla....\n");
	getch();
	return 0;
}