#include #include #include #define _HP_FAST_MACROS #include #include "pict.h" #ifdef VIDEO #define SIZE_X 1280 #define SIZE_Y 1024 #else #define SIZE_X 1024 #define SIZE_Y 768 #endif int display; main (argc, argv) int argc; char *argv[]; { char *device,*driver; int cmap_mode; float fmap[256][3]; int cmapsize; extern char *optarg; extern int optind,opterr; int x,y,w,h,i,j; U_char r,g,b; float *auxb; float *buff; int opcion,center,fix_x,fix_y,mode,info,alpha; Pict pict,pict8; char str[256]; if (argc < 2) { printf("Uso: %s [i][oga][xyc] pict\n",argv[0]); exit(1); } x = 0; y = 0; center = FALSE; info = FALSE; alpha = FALSE; mode = -1; while ( (opcion=getopt(argc,argv,"cx:y:goai")) != EOF ) { switch(opcion) { case 'i': info = TRUE; break; case 'c': center = TRUE; break; case 'x': x = atoi(optarg); break; case 'y': y = atoi(optarg); break; case 'a': alpha = TRUE; break; case 'g': mode = GRAYSCALE; break; case 'o': mode = OPTIMAL; break; } } pict = pict_read_pict(argv[optind]); if (info) { printf("Name: %s\n",argv[optind]); printf("Size: %d x %d\n",pict_height(pict), pict_width(pict)); printf("Mode: "); switch(pict->clr_mode) { case M_MONO: printf("MONO\n"); break; case M_RGB8: printf("RGB 8 Bits\n"); break; case M_RGB24: printf("RGB 24 Bits\n"); break; case M_RGBA32: printf("RGB 24 Bits + ALPHA\n"); break; default: printf("????\n"); } exit(1); } if (alpha && (pict_mode(pict)==M_RGBA32)) { pict8 = pict_24_to_8(pict,ALPHA,5,256); pict_free(pict); pict = pict8; } else if (mode != -1 && (pict_mode(pict)==M_RGBA32 || pict_mode(pict)==M_RGB24)) { pict8 = pict_24_to_8(pict,mode,5,256); pict_free(pict); pict = pict8; } w = pict_width(pict); h = pict_height(pict); if (center) { x = (SIZE_X-w)/2; y = (SIZE_Y-h)/2; } #ifdef VIDEO device = "/dev/crt"; driver = "hp98731"; cmap_mode = CMAP_FULL; #else device = "/dev/graphics"; driver = "hp98710"; if(mode == GRAYSCALE) cmap_mode = CMAP_MONOTONIC; else cmap_mode = CMAP_NORMAL; #endif display=gopen(device,OUTDEV,driver,cmap_mode); if (display == -1) { puts("Error al acceder al dispositivo grafico.\n"); exit(1); } vdc_extent(display,0.0,0.0,0.0,(float)SIZE_X,(float)SIZE_Y,1.0); view_window(display,0.0,(float)SIZE_Y,(float)SIZE_X,0.0); shade_mode(display,cmap_mode|INIT,0); shade_range(display,0,255); #ifdef VIDEO vertex_format(display,3,3,1,0,CLOCKWISE); #endif if (mode == OPTIMAL && cmap_mode == CMAP_NORMAL) { for (i=0; i<256; i++) { fmap[i][0] = pict->map[i][0]/255.0; fmap[i][1] = pict->map[i][1]/255.0; fmap[i][2] = pict->map[i][2]/255.0; } define_color_table(display,0,256,fmap); } buff = (float *)calloc(w,5*sizeof(float)); for (i=0; i=SIZE_Y) break; #ifdef VIDEO auxb=buff; for (j=0; j=SIZE_X) break; pict_pixel_rgba(pict,i,j,&r,&g,&b,NULL); *auxb++ = (float)x+j; *auxb++ = (float)y+i; *auxb++ = r/255.0; *auxb++ = g/255.0; *auxb++ = b/255.0; } polyline2d(display,buff,j,0); #else for (j=0; j=SIZE_X) break; pict_pixel_rgba(pict,i,j,&r,&g,&b,NULL); line_color(display,r/255.0,g/255.0,b/255.0); move2d(display,(float)x+j,(float)y+i); draw2d(display,(float)x+j,(float)y+i); } #endif } gclose(display); }