Beispiel #1
0
void iniciar_graficas(void)
{
   int contr=0;
   int modo=0;
   installuserdriver("svga256",detectar);
   initgraph(&contr,&modo,"");
}
Beispiel #2
0
void inicializar_modo (void) /* Inicializar el modo gr fico */
{
	int controlador = DETECT, modo, codigo_error;

	installuserdriver ("Svga256", DetectarVGA256);

	initgraph (&controlador, &modo, ""); /* Inicializar modo grafico */
	mostrar_error (codigo_error = graphresult ()); /* Verificar que no ha sucedido ning£n error en la inicializaci¢n grafica */
}
Beispiel #3
0
void
plD_init_vga(PLStream *pls)
{
	int driver;

	 pls->termin = 1;            /* is an interactive terminal */
	 pls->icol0 = 1;
	 pls->width = 1;
	 pls->bytecnt = 0;
	 pls->page = 0;
	 pls->graphx = TEXT_MODE;
	 pls->plbuf_write = 1;

	 if (!pls->colorset)
	pls->color = 1;

/* Set up device parameters */

#ifdef TSENG4
  driver =installuserdriver ("TSENG4", Tseng4Mode);
  errorcode = graphresult();

  errorcode = graphresult();
  if (errorcode != grOk) {
	 printf("Graphics error: %s\n", grapherrormsg(errorcode));
	 printf("Press any key to halt:");
	 getch();
	 exit(1); /* terminate with an error code */
  }
#endif

	 bgi_graph(pls);

	 dev->xold = UNDEFINED;
	 dev->yold = UNDEFINED;
	 dev->xmin = 0;
	 dev->xmax = getmaxx();
	 dev->ymin = 0;
	 dev->ymax = getmaxy();

	 plP_setpxl(2.5, 2.5);           /* Pixels/mm. */

	 plP_setphy((PLINT) 0, (PLINT) dev->xmax, (PLINT) 0, (PLINT) dev->ymax);

}
Beispiel #4
0
int DGraphics::Init( int gmode )
{
 int gdriver = VGA,
     errorcode;

 gdriver=installuserdriver("SVGA256",NULL);
 initgraph(&gdriver, &gmode, "");

 if ( (errorcode = graphresult()) != grOk )
  {
    cout << "Error: Graphics - %s\n" << grapherrormsg(errorcode);
    return FALSE;
  }

 ActiveMode=gmode;

 return TRUE;
}
Beispiel #5
0
void InitGraph256()								/***初始化屏幕为256色**/
{
	int graphdriver=DETECT,graphmode;
	int ErrorCode;

	installuserdriver("svga256",DetectVga256);
	initgraph(&graphdriver,&graphmode,"");
	ErrorCode=graphresult();
	if (ErrorCode!=grOk)
	{
		printf("%s\n",grapherrormsg(ErrorCode));
		getch();
		exit(1);
	}

	cleardevice();
	maxx=getmaxx();
	maxy=getmaxy();
}
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;
}
Beispiel #7
0
/******************************************************************************
* Interpret the command line and scan the given GIF file.		      *
******************************************************************************/
void main(int argc, char **argv)
{
    int	i, j, k, Error, NumFiles, Size, Row, Col, Width, Height, ExtCode,
	Count, ColorMapSize, GraphDriver, GraphMode, Sum,
	HelpFlag = FALSE,
	BGIPathFlag = FALSE,
	BGIUserDriverFlag = FALSE,
	ZoomFlag = FALSE;
    GifRecordType RecordType;
    GifByteType *Extension;
    char Str[80], *BGIUserDriverNameMode,
	**FileName = NULL;
    GifRowType *ScreenBuffer;
    GifFileType *GifFile;
    struct text_info TextInfo;      /* So we can restore starting text mode. */

    if ((Error = GAGetArgs(argc, argv, CtrlStr,
		&GifQuitePrint, &BGIPathFlag, &BGIPath,
		&BGIUserDriverFlag, &BGIUserDriverNameMode,
		&ZoomFlag, &ZoomFactor,
		&BeepsDisabled, &HelpFlag,
		&NumFiles, &FileName)) != FALSE ||
		(NumFiles > 1 && !HelpFlag)) {
	if (Error)
	    GAPrintErrMsg(Error);
	else if (NumFiles > 1)
	    GIF_MESSAGE("Error in command line parsing - one GIF file please.");
	GAPrintHowTo(CtrlStr);
	exit(1);
    }

    if (HelpFlag) {
	fprintf(stderr, VersionStr);
	GAPrintHowTo(CtrlStr);
	exit(0);
    }

    if (BGIUserDriverFlag) {
	/* Use the driver supplied by the user! */
        BGIInstallUserDriver(BGIUserDriverNameMode);
        installuserdriver(BGIUserDriverName, detectVGA);
	GraphDriver = BGI_USER_INSTALL;
    }
    else {
        /* Sense type of display we have and attempt to load right driver. */
        detectgraph(&GraphDriver, &GraphMode);
        if (GraphDriver < 0)
	    GIF_EXIT("BGI Auto detect: No graphics device detected.");
    }

    /* Put in the following any graphic driver specific setup: */
    switch (GraphDriver) {
	case CGA:
	    GraphMode = CGAHI;
	    break;
	case EGA:
	    GraphMode = EGAHI;
	    break;
	case EGA64:
	    GraphMode = EGA64HI;
	    break;
	case EGAMONO:
	    GraphMode = EGAMONOHI;
	    break;
	case HERCMONO:
	    GraphMode = HERCMONOHI;
	    break;
	case VGA:
	    GraphMode = VGAHI;
	    break;
	case BGI_USER_INSTALL:
	    GraphDriver = DETECT;
	    GraphMode = BGIUserDriverMode;
	    break;
	default:
	    GIF_EXIT("Requested graphic device is not supported.");
	    break;
    }

    if (NumFiles == 1) {
	GifFileName = *FileName;
	if ((GifFile = DGifOpenFileName(*FileName)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }
    else {
	/* Use the stdin instead: */
	GifFileName = "Stdin";
	setmode(0, O_BINARY);
	if ((GifFile = DGifOpenFileHandle(0)) == NULL) {
	    PrintGifError();
	    exit(-1);
	}
    }

    /* Allocate the screen as vector of column of rows. We cannt allocate    */
    /* the all screen at once, as this broken minded CPU can allocate up to  */
    /* 64k at a time and our image can be bigger than that:		     */
    /* Note this screen is device independent - its the screen as defined by */
    /* the GIF file parameters itself.					     */
    if ((ScreenBuffer = (GifRowType *)
	malloc(GifFile -> SHeight * sizeof(GifRowType *))) == NULL)
	    GIF_EXIT("Failed to allocate memory required, aborted.");

    Size = GifFile -> SWidth * sizeof(GifPixelType);/* Size in bytes of one row.*/
    if ((ScreenBuffer[0] = (GifRowType) malloc(Size)) == NULL)    /* First row. */
	GIF_EXIT("Failed to allocate memory required, aborted.");

    for (i = 0; i < GifFile -> SWidth; i++)  /* Set its color to BackGround. */
	ScreenBuffer[0][i] = GifFile -> SBackGroundColor;
    MaximumScreenHeight = GifFile -> SHeight - 1;
    for (i = 1; i < GifFile -> SHeight; i++) {
	/* Allocate the other rows, and set their color to background too: */
	if ((ScreenBuffer[i] = (GifRowType) malloc(Size)) == NULL) {
	    if (i > 30) {
		/* Free some memory for the BGI driver and auxilary. */
		for (j = 1; j < 28; j++)
	    	    free((char *) ScreenBuffer[i - j]);
	    	MaximumScreenHeight = i - 28;
	    	fprintf(stderr, "\n%s: Failed to allocate all memory required, last line %d.\n",
			PROGRAM_NAME, MaximumScreenHeight);
	    	break;
	    }
	    else
		GIF_EXIT("Failed to allocate memory required, aborted.");
	}

	memcpy(ScreenBuffer[i], ScreenBuffer[0], Size);
    }

    /* Scan the content of the GIF file and load the image(s) in: */
    do {
	if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) {
	    PrintGifError();
	    break;
	}
	switch (RecordType) {
	    case IMAGE_DESC_RECORD_TYPE:
		if (DGifGetImageDesc(GifFile) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}

		Row = GifFile -> ITop; /* Image Position relative to Screen. */
		Col = GifFile -> ILeft;
		Width = GifFile -> IWidth;
		Height = GifFile -> IHeight;
		GifQprintf("\n%s: Image %d at (%d, %d) [%dx%d]:     ",
		    PROGRAM_NAME, ++ImageNum, Col, Row, Width, Height);
		if (GifFile -> ILeft + GifFile -> IWidth > GifFile -> SWidth ||
		   GifFile -> ITop + GifFile -> IHeight > GifFile -> SHeight) {
		    fprintf(stderr, "Image %d is not confined to screen dimension, aborted.\n");
		    exit(-2);
		}
		if (GifFile -> IInterlace) {
		    /* Need to perform 4 passes on the images: */
		    for (Count = i = 0; i < 4; i++)
			for (j = Row + InterlacedOffset[i]; j < Row + Height;
						 j += InterlacedJumps[i]) {
			    GifQprintf("\b\b\b\b%-4d", Count++);
			    if (DGifGetLine(GifFile,
				&ScreenBuffer[MIN(j, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
				PrintGifError();
				exit(-1);
			    }
			}
		}
		else {
		    for (i = 0; i < Height; i++, Row++) {
			GifQprintf("\b\b\b\b%-4d", i);
			if (DGifGetLine(GifFile, &ScreenBuffer[MIN(Row, MaximumScreenHeight)][Col],
				Width) == GIF_ERROR) {
			    PrintGifError();
			    MaximumScreenHeight = MIN(i - 1, MaximumScreenHeight);
			}
		    }
		}
		break;
	    case EXTENSION_RECORD_TYPE:
		/* Skip any extension blocks in file: */
		if (DGifGetExtension(GifFile, &ExtCode, &Extension) == GIF_ERROR) {
		    PrintGifError();
		    exit(-1);
		}
		while (Extension != NULL) {
		    if (DGifGetExtensionNext(GifFile, &Extension) == GIF_ERROR) {
			PrintGifError();
			exit(-1);
		    }
		}
		break;
	    case TERMINATE_RECORD_TYPE:
		break;
	    default:		    /* Should be traps by DGifGetRecordType. */
		break;
	}
    }
    while (RecordType != TERMINATE_RECORD_TYPE);

    /* Lets display it - set the global variables required and do it: */
    BackGround = GifFile -> SBackGroundColor;
    ColorMap = (GifFile -> IColorMap ? GifFile -> IColorMap :
				       GifFile -> SColorMap);
    ColorMapSize = 1 << (GifFile -> IColorMap ? GifFile -> IBitsPerPixel :
						GifFile -> SBitsPerPixel);

    gettextinfo(&TextInfo);	     /* Save current mode so we can recover. */

    initgraph(&GraphDriver, &GraphMode, BGIPath);
    if (graphresult() != grOk)	 	       /* Error occured during init. */
	GIF_EXIT("Graphics System Error, failed to initialize driver.");

    if (getmaxcolor() + 1 < ColorMapSize) {
	sprintf(Str, "GIF Image color map (%d) is too big for device (%d).\n",
					      ColorMapSize, getmaxcolor() + 1);
	closegraph();
	GIF_EXIT(Str);
    }

    /* Initialize hardware pallete and also select fore/background color.    */
    BackGround = ForeGround = 1;
    Sum = ((int) ColorMap[1].Red) +
	  ((int) ColorMap[1].Green) +
	  ((int) ColorMap[1].Blue);
    j = k = Sum;
    for (i = 0; i < ColorMapSize; i++) {
	setrgbpalette(i, ColorMap[i].Red >> 2,
			 ColorMap[i].Green >> 2,
			 ColorMap[i].Blue >> 2);

	Sum = ((int) ColorMap[i].Red) +
	      ((int) ColorMap[i].Green) +
	      ((int) ColorMap[i].Blue);
	if (i != 0 && Sum > j) {			/* Dont use color 0. */
	    ForeGround = i;
	    j = Sum;
	}
	if (i != 0 && Sum <= k) {			/* Dont use color 0. */
	    BackGround = i;
	    k = Sum;
	}
    }

    DeviceMaxX = getmaxx();		    /* Read size of physical screen. */
    DeviceMaxY = getmaxy();
    ScreenWidth = GifFile -> SWidth;
    ScreenHeight = MIN(GifFile -> SHeight, MaximumScreenHeight);

    Tone(500, 10);
    DisplayScreen(ScreenBuffer, GifFile);

    if (DGifCloseFile(GifFile) == GIF_ERROR) {
	PrintGifError();
	closegraph();
	exit(-1);
    }

    closegraph();

    textmode(TextInfo.currmode);
}
Beispiel #8
0
void main()
{
  int  Gd = DETECT, Gm;
  int  Drv;
  char GrErr;

  /* Find out which driver the user wants */
  printf("Which driver would you like to use?\n");
  printf("  0) Svga16\n");
  printf("  1) Svga256\n");
  printf("  2) Svga32k\n");
  printf("  3) Svga64k\n");
  printf("  4) SvgaTC\n");
  printf("  5) SvgaS3\n");
  printf("  6) Tweak256\n");
  printf("  7) Tweak16\n");
  printf("\n> ");
  scanf("%d",&Drv);
  switch(Drv)
  {
    case 0: installuserdriver("Svga16",DetectVGA16);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga16_fdriver);  */
	    break;

    case 1: installuserdriver("Svga256",DetectVGA256);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga256_fdriver); */
	    break;

    case 2: installuserdriver("Svga32k",DetectVGA32k);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga32k_fdriver);  */
	    break;

    case 3: installuserdriver("Svga64k",DetectVGA64k);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Svga64k_fdriver);  */
	    break;

    case 4: installuserdriver("SvgaTC",DetectVGA24bit);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(SvgaTC_fdriver);  */
	    break;

    case 5: installuserdriver("SvgaS3",DetectVGAS3);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(SvgaS3_fdriver);  */
	    break;

    case 6: installuserdriver("Twk16",DetectTwk16);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Twk16_fdriver);  */
	    break;

    case 7: installuserdriver("Twk256",DetectTwk256);
/*  If driver is linked with file, remove comments */
/*          registerfarbgidriver(Twk256_fdriver);  */
	    break;
  }
  initgraph(&Gd,&Gm,"");

  /* Test if mode was initialized successfully */
  GrErr = graphresult();
  if (GrErr != grOk) {
      printf("Graphics error: %s\n",grapherrormsg(GrErr));
      exit(1);
  }

  /* Draw an 'X' on the screen */
  setcolor(RealDrawColor(WhitePixel()));
  line(0,0,getmaxx(),getmaxy());
  line(0,getmaxy(),getmaxx(),0);
  getch();
  closegraph();
}