예제 #1
0
void capture_screen(int index)
{
	FILE* fp = NULL;
	int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
	int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
	HWND hDesktopWnd = GetDesktopWindow();
	HDC hDesktopDC = GetDC(hDesktopWnd);
	HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
	char filename[100];
	

	// Create the bitmap object
	HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC,
													nScreenWidth,
													nScreenHeight);
	
	SelectObject(hCaptureDC,hCaptureBitmap);

	BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,
		   hDesktopDC,0,0,SRCCOPY|CAPTUREBLT); 

	// Save the bitmap to file
	sprintf(filename, "C:\\Documents and Settings\\All Users\\Documents\\My Pictures\\Sample_%d.bmp", index);
	save_bitmap(filename, hCaptureBitmap);
	
	// Clean up objects
	ReleaseDC(hDesktopWnd,hDesktopDC);
	DeleteDC(hCaptureDC);
	DeleteObject(hCaptureBitmap);
}
예제 #2
0
파일: myalleg.c 프로젝트: 10crimes/code
void savescreen(String fname) {
#ifdef ALLEGRO
  PALETTE pal;
  get_palette(pal);
  save_bitmap(fname,screen,pal);
  #endif
}
예제 #3
0
void RenderingManager::screenshot()
{
	// get the current time
	time_t rawtime = 0;
	struct tm timeinfo;
	rawtime = time(NULL);
	localtime_s(&timeinfo, &rawtime);

	// build a filename
	char filename[] = "dd-mm-yy hh-mm-ss.bmp";
	filename[0] = (timeinfo.tm_mday/10)%10 + '0';
	filename[1] = timeinfo.tm_mday%10 + '0';
	filename[3] = (timeinfo.tm_mon/10)%10 + '0';
	filename[4] = timeinfo.tm_mon%10 + '0';
	filename[6] = (timeinfo.tm_year/10)%10 + '0';
	filename[7] = timeinfo.tm_year%10 + '0';
	filename[9] = (timeinfo.tm_hour/10)%10 + '0';
	filename[10] = timeinfo.tm_hour%10 + '0';
	filename[12] = (timeinfo.tm_min/10)%10 + '0';
	filename[13] = timeinfo.tm_min%10 + '0';
	filename[15] = (timeinfo.tm_sec/10)%10 + '0';
	filename[16] = timeinfo.tm_sec%10 + '0';

	save_bitmap(filename, m_backbuf, NULL);
}
예제 #4
0
int main(int argc, char **argv)
{
	if(argc != 3)
	{
		std::cout << "doorspr: Door sprite utility\nUsage: doorspr <source> <dest>\n";
		return 0;
	}
	allegro_init();
	set_color_depth(32);
	BITMAP *src = load_bitmap(argv[1], 0);
	BITMAP *newDest;
	if(fex(argv[2]))
	{
		BITMAP *oldDest;
		oldDest = load_bitmap(argv[2], 0);
		newDest = create_bitmap(60, oldDest->h + 45 * 4);
		clear_to_color(newDest, 0xFF00FF);
		draw_sprite(newDest, oldDest, 0, 0);
		destroy_bitmap(oldDest);
	}
	else
	{
		newDest = create_bitmap(60, 45 * 4);
		clear_to_color(newDest, 0xFF00FF);
	}
	for(int i = 0; i < 4; i++)
	{
		blit(src, newDest, 0, i * (src->h / 4), 30 - (src->w / 2), newDest->h - ((3 - i) * 45) - (src->h / 4), src->w, src->h / 4);
	}
	save_bitmap(argv[2], newDest, 0);
	return 0;
}
예제 #5
0
void draw_matrix(matrix_t *m, char *name, char *dirname){
    	
	allegro_init();
    	set_color_depth( 16 );
	BITMAP * obrazek1 = NULL;
	obrazek1 = create_bitmap( m->cn*10, m->rn*10 );
	if( !obrazek1 )
	{
	    set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 );
	    allegro_message( "nie mogę załadować obrazka 1 !" );
	    allegro_exit();
	}
	clear_to_color( obrazek1, makecol( 255, 255, 255 ) );
	int i,j;
	for (i = 0; i < m->rn; i++) 
    		for (j = 0; j < m->cn ; j++)
				if(m->e[i*m->cn+j]==1)
					rectfill( obrazek1, j*10, i*10,  (j*10)+10,(i*10)+10,makecol( 0, 0, 0 ) );
	
	chdir(dirname);
	save_bitmap(name, obrazek1, default_palette);	
	chdir(PARENT_DIRECTORY);	
	
	destroy_bitmap( obrazek1 );
	allegro_exit();

}
예제 #6
0
void user_save()
{
	int a,b,w,px,i=-1;
	char filename[60],ch;
	restrictmouseptr(0,0,xmax,20);
	hidemouseptr();
	a=textwidth("Enter File Name");
	setfillstyle(1,BLUE);
	bar(0,0,xmax,20);
	setcolor(BLACK);
	outtextxy(10,5,"Enter File Name:");
	setfillstyle(1,WHITE);
	bar((a+10),2,(a+410),18);
	setfillstyle(1,CYAN);
	a=textwidth("No");
	bar((xmax-10-a),2,(xmax-10),18);
	b=a+10+textwidth("Save");
	bar((xmax-10-b),2,(xmax-20-a),18);
	setcolor(BLACK);
	outtextxy((xmax-9-b),3,"Save");
	outtextxy((xmax-9-a),3,"No");
	px=textwidth("Enter File Name")+10;
	while(1)
	{
	ch=get_filename(px,4);
	if(ch==13||ch==27)
	break;
	w=textwidth("A");
	px+=w;
	filename[++i]=ch;
	}
	filename[++i]='\0';
	showmouseptr();
	for(;;)
	{
		getmousepos(&button,&mousex,&mousey);
		if(mousex>(xmax-10-a)&&mousex<(xmax-10)&&button==1)       //deny loading/saving
		{
			button_hover((xmax-10-a),2,(xmax-10),18);
			hidemouseptr();
			initmouse();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			break;
		}
	else if(mousex>(xmax-10-b)&&mousex<(xmax-20-a)&&button==1)        //confirm loading/saving
		{
			button_hover((xmax-10-b),2,(xmax-20-a),18);
			save_bitmap(filename);
			hidemouseptr();
			initmouse();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			break;
		}
	}
}
int main(int argc, char *argv[]) {
  argc--;
  argv++;
  if (argc != 4) { fprintf(stderr, "pm_minimal a b ann annd\n"
                                   "Given input images a, b outputs nearest neighbor field 'ann' mapping a => b coords, and the squared L2 distance 'annd'\n"
                                   "These are stored as RGB 24-bit images, with a 24-bit int at every pixel. For the NNF we store (by<<12)|bx.\n"); exit(1); }
  printf("Loading input images\n");
  BITMAP *a = load_bitmap(argv[0]);
  BITMAP *b = load_bitmap(argv[1]);
  BITMAP *ann = NULL, *annd = NULL;
  printf("Running PatchMatch\n");
  patchmatch(a, b, ann, annd);
  printf("Saving output images\n");
  save_bitmap(ann, argv[2]);
  save_bitmap(annd, argv[3]);
  return 0;
}
예제 #8
0
파일: image.c 프로젝트: chenqp14/automat
void painting (matrix_t *matrix,BITMAP *pic1, int nr_im, char img_name[], char *folder , char *format){	
	int p=0;
	clear_to_color( pic1, 255);
	for(p=0;p<(matrix->cn*matrix->rn);p++)
		if(matrix->e[p]=='1') rectfill(pic1,50*(p%matrix->cn),50*(p/matrix->cn),50*(p%matrix->cn)+50,50*(p/matrix->cn)+50,0);		
	im_name(nr_im,img_name,folder, format);
	save_bitmap(img_name, pic1 , default_palette );
}
예제 #9
0
void TileRepository::exportBitmap(const char *filename, int tile_w, int tile_h, int tile_spacing, int tiles_in_row)
{
	list<TileType*> tiles_to_save;
	map<const char*, TileType*, ltstr>::iterator i;
	list<TileType*>::iterator j;
	char tempTilename[256];
	char tempFilename[256];
	replace_extension(tempFilename, get_filename(filename), "", 256);

	if (!(tiles_in_row > 0 && tile_w > 0 && tile_h > 0)) {
		allegro_message("WARNING: tiles_in_row (%d), tile_w (%d) and tile_h (%d) must all be larger than 0.", tiles_in_row, tile_w, tile_h);
		return;
	}

	for (i = tileTypes.begin(); i != tileTypes.end(); i++)
	{
		TileType* tempTileType = (*i).second;
		replace_extension(tempTilename, tempTileType->getName(), "", 256);
		if (ustrcmp(tempFilename, tempTilename) == 0) {
			tiles_to_save.push_back(tempTileType);
		}
	}

	if (tiles_to_save.empty()) {
		allegro_message("WARNING: No tiles to save in %s.", filename);
		return;
	}

	BITMAP *tile_bitmap;
	PALETTE pal;

	tile_bitmap = create_bitmap
	(
		tiles_in_row * tile_w,
		(tiles_to_save.size() / tiles_in_row +
		 tiles_to_save.size() % tiles_in_row) * tile_h
	);
	int x = 0;
	int y = 0;

	for (j = tiles_to_save.begin(); j != tiles_to_save.end(); j++)
	{
		blit((*j)->getBitmap(), tile_bitmap, 0, 0, x * tile_w, y * tile_h, tile_w, tile_h);
		x++;
		if (x == tiles_in_row) {
			y++;
			x = 0;
		}
	}

	get_palette(pal);
	save_bitmap(filename, tile_bitmap, pal);

	destroy_bitmap(tile_bitmap);
}
예제 #10
0
//=================================================================================
// pkl_output
//=================================================================================
PKLExport int pkl_output(PKLImage pkl, FILE *out, PKL_FORMAT format)
{
	switch(format){
		case PKL_FORMAT_JPEG:
			return save_jpeg(pkl, out);
		case PKL_FORMAT_PNG:
			return save_png(pkl, out);
		case PKL_FORMAT_BITMAP:
			return save_bitmap(pkl, out);
		default:
			return(1);
	}
	return(1);
}
예제 #11
0
파일: screenshot.c 프로젝트: rydzus/Aron
void screenshot()
{
	chdir("zrzuty_ekranu");
	time_t now;
	struct tm *ts;
	char buf[80];

	now = time(NULL);

	ts = localtime(&now);
	strftime(buf, sizeof(buf), "aron_%H-%M-%S_%d-%m-%Y", ts);
	save_bitmap(strcat(buf, ".bmp"), screen, default_palette);
	chdir("..");
}
예제 #12
0
int main (int argc, char **argv)
{
    SkAutoGraphics ag;
    
    SkBitmap bitmap = make_bitmap(80, 80);
    
    drawInBitmap(bitmap);
    
    if (!save_bitmap("/Users/phryne/Desktop/c0071fce_icon.png", bitmap))
    {
        cout << "Failed to generate image " << endl;
    }
    return 0 ;
}
예제 #13
0
void make_screenshot(BITMAP *bmp)
{
  std::string filename;
  char buf[1024];

  for (int c=0; c<10000; ++c) {
    sprintf(buf, "shot%04d.bmp", c);
    filename = redir(buf);
    if (!exists(filename.c_str())) {
      PALETTE pal;
      get_palette(pal);
      save_bitmap(filename.c_str(), bmp, pal);
      break;
    }
  }
}
예제 #14
0
void save_spacesprite2(SpaceSprite *ss, const char *spritename, const char *destination, const char *extension)
{
	STACKTRACE;
	int i;
	char buf[512];

	if (ss->frames() != 64)
		tw_error("save_spacesprite2 - error");

	BITMAP *tmp = create_bitmap(int(ss->width() * 8), int(ss->height() * 8));
	for (i = 0; i < ss->frames(); i += 1) {
		blit(ss->get_bitmap(i), tmp, 0, 0, (i&7) * (int)ss->width(), int((i/8) * ss->height()), (int)ss->width(), (int)ss->height());
		sprintf(buf, "%s%i.%s", spritename, i, extension);
		save_bitmap(buf, tmp, NULL);
	}
	return;
}
예제 #15
0
int matrix()
{
	int tbl[9] = {1,3,5,7,9,2,4,6,8};
	RGBQUAD *color_table[9];
	for(int i=0; i<9; i++)
	{
		color_table[i] = (RGBQUAD*)malloc(sizeof(RGBQUAD) * 1920 * 1080);

		char tmp[MAX_PATH];
		sprintf(tmp, "Z:\\1\\%d_µ÷Õû´óС.bmp", i+1);
		HBITMAP bm = (HBITMAP)LoadImageA(0, tmp, IMAGE_BITMAP, 1920, 1080, LR_LOADFROMFILE);
		GetBitmapBits(bm, 1920*1080*4, color_table[i]);
		DeleteObject(bm);
	}
	RGBQUAD *out = (RGBQUAD*)malloc(sizeof(RGBQUAD) * 1920 * 1080);
	FILE * f = fopen("Z:\\matrix.txt", "wb");
	for(int y=0; y<1080; y++)
	{
		for(int x=0; x<1920; x++)
		{
			int r = tbl[(y*4+x*3+0)%9]-1;
			int g = tbl[(y*4+x*3+1)%9]-1;
			int b = tbl[(y*4+x*3+2)%9]-1;

			RGBQUAD *o = &out[y*1920+x];
			o->rgbRed   = color_table[r][y*1920+x].rgbRed;
			o->rgbGreen = color_table[g][y*1920+x].rgbGreen;
			o->rgbBlue  = color_table[b][y*1920+x].rgbBlue;

			fprintf(f, "%d%d%d", r,g,b);
		}
		fprintf(f, "\r\n");
	}


	save_bitmap((DWORD*)out, L"Z:\\out.bmp", 1920, 1080);

	for(int i=0; i<9; i++)
		free(color_table[i]);
	free(out);


	return 0;
}
void save_animation()
{
    char name[256];
    int i;

    clear(screen);

    for (i=0; i<frame; i++) {
        sprintf(name, "%s%03d.tga", out_file, i);
        strlwr(name);

        textprintf_centre(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(128, 128, 128), "Writing %s...", name);

        if (save_bitmap(name, bmp[i], pal) != 0) {
            set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
            allegro_message("Error writing '%s'\n", name);
            return;
        }
    }
}
예제 #17
0
파일: main.cpp 프로젝트: j-jorge/libclaw
/*----------------------------------------------------------------------------*/
void save( const claw::graphic::image& img, const std::string& filename )
{
  std::cout << "== Saving pcx files ==" << std::endl;
  save_pcx( img, filename );

  std::cout << "== Saving jpg files ==" << std::endl;
  save_jpeg( img, filename );

  std::cout << "== Saving png files ==" << std::endl;
  save_png( img, filename );

  std::cout << "== Saving bitmap files ==" << std::endl;
  save_bitmap( img, filename );

  std::cout << "== Saving targa files ==" << std::endl;
  save_targa( img, filename );

  std::cout << "== Saving xbm files ==" << std::endl;
  save_xbm( img, filename );
}
예제 #18
0
int main( int argc, char **argv )
{
    PALETTE pal;
    int i;


    /* init allegro and init palette */
    install_allegro(SYSTEM_NONE, &errno, atexit);
    set_color_depth(8);
    set_color_conversion(COLORCONV_REDUCE_TO_256);
    for( i = 0; i < 256; i++ )
    {
        /* divided by 4 because the colour value ranges from 0-63 */
        pal[i].r = pal[i].g = pal[i].b = i/4;
    }


    srand(time(NULL));

    do_args(argc, argv);

    if( filename == NULL )
    {
        /* +1 for '\0' char */
        filename = malloc(strlen(DEFT_FILENAME)+1);
        if( filename == NULL )
        {
            fprintf(stderr, "error: can't malloc space for map name.\n");
            exit(EXIT_FAILURE);
        }
        strcpy(filename, DEFT_FILENAME);
    }

    lwmapgen(size, grid_size, func_id);

    save_bitmap(filename, map.map, pal);


    return EXIT_SUCCESS;
}
예제 #19
0
파일: display.cpp 프로젝트: starand/cpp
/*static */
void display_t::save_screen(const char *szFileName)
{
	ASSERTE(szFileName);

	int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
	int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);

	HWND hDesktopWnd = GetDesktopWindow();
	HDC hDesktopDC = GetDC(hDesktopWnd);
	HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);

	HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC, nScreenWidth, nScreenHeight);

	SelectObject(hCaptureDC, hCaptureBitmap); 
	BitBlt(hCaptureDC, 0, 0, nScreenWidth, nScreenHeight, hDesktopDC, 0, 0, SRCCOPY | CAPTUREBLT);

	save_bitmap(szFileName, hCaptureBitmap);

	ReleaseDC(hDesktopWnd,hDesktopDC);
	DeleteDC(hCaptureDC);
	DeleteObject(hCaptureBitmap);
}
예제 #20
0
void save_spacesprite(SpaceSprite *ss, const char *spritename, const char *destination, const char *extension)
{
	STACKTRACE;
	int i;
	char buf[512];

	if (!ss)
		return;

	if (ss->frames()) {
		for (i = 0; i < ss->frames(); i += 1) {
			if (strchr(extension, '.')) {
				sprintf(buf, "tmp/%s%03d%s", spritename, i, extension);
			} else {
				sprintf(buf, "tmp/%s%03d.bmp", spritename, i);
			}

			save_bitmap(buf, ss->get_bitmap(i), NULL);
		}

	}

	sprintf(buf, "tmp/%s.ini", spritename);
	tw_set_config_file(buf);
	set_config_string("Main", "Type", "SpaceSprite");
	set_config_int("SpaceSprite", "Number", (int)ss->frames());
	set_config_int("SpaceSprite", "Width", (int)ss->width());
	set_config_int("SpaceSprite", "Height", (int)ss->height());
	set_config_string("SpaceSprite", "SubType", "Normal");
	set_config_string("SpaceSprite", "Extension", extension);
	chdir("tmp");
	sprintf(buf, "dat ../ships/%s.dat -k -a *", destination);
	//	system(buf);
	sprintf(buf, "move * ..\\ships\\%s", destination);
	system(buf);
	chdir("..");
	return;
}
예제 #21
0
파일: main.c 프로젝트: mairesb/my_epi_work
t_bunny_response	refresh_my_game(void *data)
{
  t_lapin		*lapin;

  lapin = data;
  bunny_set_key_response(&key);
  bunny_set_click_response(&mouse);
  mouse_position(lapin);
  blit_to_window(lapin->window_1, lapin->pixelarray_1);
  size_bar(lapin->window_1, lapin->font, 50, 0);
  print_bar(lapin);
  if (lapin->save == 1)
    {
      save_bitmap(lapin->str, lapin->pixelarray_2);
      return (EXIT_SUCCESS);
    }
  else if (lapin->save == 2)
    {
      save_file_ftn(lapin->pixelarray_2, lapin->str);
      return (EXIT_SUCCESS);
    }
  return (GO_ON);
}
예제 #22
0
int interlace_RGB()
{
	RGBQUAD *src = (RGBQUAD*)malloc(sizeof(RGBQUAD) * 800 * 480);

	HBITMAP bm = (HBITMAP)LoadImageA(0, "Z:\\waterdrop.bmp", IMAGE_BITMAP, 800, 480, LR_LOADFROMFILE);
	GetBitmapBits(bm, 800*480*4, src);
	DeleteObject(bm);


	RGBQUAD *out = (RGBQUAD*)malloc(sizeof(RGBQUAD) * 800 * 480);
	for(int y=0; y<480; y++)
	{
		for(int x=0; x<400; x++)
		{
			RGBQUAD *s1 = &src[y*800+x];
			RGBQUAD *s2 = &src[y*800+x+400];

			RGBQUAD *o = &out[y*800+x*2];
			o->rgbRed   = s1->rgbRed;
			o->rgbGreen = s2->rgbGreen;
			o->rgbBlue  = s1->rgbBlue;

			o++;
			o->rgbRed   = s2->rgbRed;
			o->rgbGreen = s1->rgbGreen;
			o->rgbBlue = s2->rgbBlue;
		}
	}


	save_bitmap((DWORD*)out, L"Z:\\out.bmp", 800, 480);

	free(src);
	free(out);

	return 0;
}
예제 #23
0
bool Bitmap::SaveToFile(const char *filename, const void *palette)
{
	return save_bitmap(filename, _alBitmap, (const RGB*)palette) == 0;
}
예제 #24
0
void handle_key(void){
	if (NeedsPoll) poll_keyboard();


	if (key[syskeys[0]] || key[KEY_ESC]) {
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[0]] || key[KEY_ESC]);
		key_done=1;
	}

if (key[syskeys[1]]) {
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[1]]);

		mute_audio();
		mute_voice();
		abaut();

		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();

			if (key[KEY_ALT] && key[KEY_ENTER]) {
				app_data.fullscreen = app_data.fullscreen ? 0 : 1;
				grmode();
				abaut();
				do {
					rest(5);
					if (NeedsPoll) poll_keyboard();
				} while (key[KEY_ENTER]);
			}		

		} while ((!key[syskeys[1]]) && (!key[KEY_ESC]) && (!key[syskeys[0]]));
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[1]]);
		
		init_sound_stream();
	}		

if (key[syskeys[5]])
	{
		if (savestate(app_data.statefile)==0)
		{
			display_msg("Savefile saved.",5);
		}
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[5]]);

	}

	/* LOAD STATE */
	if (key[syskeys[6]])
	{
		int stateError;
		if ((stateError=loadstate(app_data.statefile))==0)
		{
			display_msg("Savefile loaded.",5);
		}
		else if (stateError>=199)
		{
			if (stateError==199) display_msg("Wrong ROM-File for Savefile.",5);
			else if (stateError==200+ROM_O2) display_msg("Wrong BIOS for Savefile: O2ROM needed.",5);
			else if (stateError==200+ROM_G7400) display_msg("Wrong BIOS for Savefile: G7400 ROM needed.",5);
			else if (stateError==200+ROM_C52) display_msg("Wrong BIOS for Savefile: C52 ROM needed.",5);
			else if (stateError==200+ROM_JOPAC) display_msg("Wrong BIOS for Savefile: JOPAC ROM needed.",5);
			else display_msg("Wrong BIOS for Savefile: UNKNOWN ROM needed.",5);
		}
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[6]]);
	}

	if (key[syskeys[2]]) key_debug=1;

	if (key[syskeys[3]]) {
		init_cpu();
		init_roms();
		init_vpp();
		clearscr();
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[3]]);
	}

    /* SET HIGHSCORE */
	if (key[syskeys[7]])
	{
		set_score(app_data.scoretype, app_data.scoreaddress, app_data.default_highscore);
	}


	if (key[syskeys[4]]) {
		BITMAP *bmp;
		PALETTE pal;
		char *p;
		static char name[1024];
		static int scshot_counter = 0;

		if (strlen(app_data.scshot)>0){
			if ((p=strchr(app_data.scshot,'@'))) {
				*p = 0;
				sprintf(name, "%s%02d%s", app_data.scshot, scshot_counter++, p+1);
				*p = '@';
			} else {
				strcpy(name, app_data.scshot);
			}
			get_palette(pal);
			bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
			save_bitmap(name, bmp, pal);
			destroy_bitmap(bmp);
			do {
				rest(5);
				if (NeedsPoll) poll_keyboard();
			} while (key[syskeys[4]]);
		}
	}

	// switch joystick
	if (key[syskeys[8]]) {
		joyswitch = joyswitch ? 0 : 1;

		set_defjoykeys(0,joyswitch);
		set_defjoykeys(1,joyswitch ? 0 : 1);
		int tmp = app_data.stick[0];
		app_data.stick[0] = app_data.stick[1];
		app_data.stick[1] = tmp;

		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[syskeys[8]]);

	}

	if (key[KEY_ALT] && key[KEY_ENTER]) {
		app_data.fullscreen = app_data.fullscreen ? 0 : 1;
		grmode();
		do {
			rest(5);
			if (NeedsPoll) poll_keyboard();
		} while (key[KEY_ENTER]);
	}		

}
예제 #25
0
파일: julia4d4.c 프로젝트: 10crimes/code
void main() {
  int scrwid=320;
  int scrhei=200;
  int indent=(scrwid-scrhei)/2;
  float cenx=0;
  float ceny=0;
  float wid=1.0;
  float hei=1.0;
  float left=cenx-wid;
  float right=cenx+wid;
  float top=ceny-hei;
  float bottom=ceny+hei;
  float front=-1.0;
  float back=1.0;
  float scale=2.0/(2.0*front);
  float crazy=0.1234567;
  int steps=1000;
  int jump=1;
  JBmp *b=new JBmp(scrwid,scrhei);
  allegrosetup(scrwid,scrhei);
  makepalette(&greypalette);
  _farsetsel(screen->seg);
  randomise();
  Map2d<float> *map=new Map2d<float>(scrhei,scrhei);
  current=*new Quaternion(floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5));
  do {
    current=current*Quaternion(0.99,0,0,0)+Quaternion(floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05));
    
    float dslice=floatrnd(-.3,.3);
    current=*new Quaternion(floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5));
  current=*new Quaternion(-0.488193901,0.572800587,0,0);
    
    for (int i=0;i<scrhei;i+=jump) {
      for (int j=0;j<scrhei;j+=jump) {
        // b->setpixelud(indent+i,j,255);
        // b->writetoscreen();
        int col=0;
        V3d tmpnear=V3d(left+2.0*wid*i/(float)scrhei,top+2.0*hei*j/(float)scrhei,front);
        V3d tmpfar=V3d(tmpnear.x*2.0,tmpnear.y*2.0,back);
        tmpnear=V3d::rotate(tmpnear,V3d(0,1,0),rotation);
        tmpfar=V3d::rotate(tmpfar,V3d(0,1,0),rotation);
        tmpnear=V3d::rotate(tmpnear,V3d(1,0,0),elevation);
        tmpfar=V3d::rotate(tmpfar,V3d(1,0,0),elevation);
        Quaternion near=Quaternion(tmpnear.x,tmpnear.y,tmpnear.z,dslice);
        Quaternion far=Quaternion(tmpfar.x,tmpfar.y,tmpfar.z,dslice);
        map->pos[i][j]=crazy;
        Quaternion last=near-(far-near);
        for (int k=0;k<steps;k++) {
          float dk=(float)k/(float)steps;
          Quaternion next=near*(1.0-dk)+far*dk;
          if (julquat(next)==0) {
            Quaternion res=searchline(last,next);
            // col=255.0*(1.0-(res.c-front)/(forget-front));
            map->pos[i][j]=res.c;
            break;
          }
          last=next;
        }
        if (i>=jump && j>=jump) {
          if (map->pos[i-jump][j-jump]==crazy || map->pos[i-jump][j]==crazy || map->pos[i][j-jump]==crazy)
            col=0;
          else {
            float diff=2.0*map->pos[i-jump][j-jump]-map->pos[i-jump][j]-map->pos[i][j-jump];
            col=chop(128.0+diff*1600.0,0,255);
          }
          for (int x=0;x<jump;x++) {
            for (int y=0;y<jump;y++) {
              b->setpixel(indent+i+x,j+y,col);
            }
          }
        }
        if (key[KEY_SPACE])
          exit(0);
      }
      b->writetoscreen();
    }
    PALETTE pal;
    get_palette(pal);
    save_bitmap(getnextfilename("bmp"),screen,pal);
  } while (!key[KEY_SPACE]);
  allegro_exit();
}
예제 #26
0
/**
 * \ingroup Main
 *
 * \brief Desenha uma rede no Allegro e imprime num arquivo de imagem.
 *
 * \details Esta funcao utiliza a biblioteca grafica Allegro para imprimir uma rede de Petri. 
 *
 * \param[in] rede A variavel \a rede seria a rede de Petri.
 *
 * \param[in] fname A variavel \a fname representa o nome do arquivo que sera gerado.
 *
 * \retval void a funcao retorna nada.
 *
 */
void desenha_rede(petri_t *rede, const char *fname)
{
    float ang,      /* Angulacao antre cada elemento na imagem */
          r_lugar,  /* Raio da circunferencia que representa o lugar */
          smaller,  /* A menor das dimensoes da imagem */
          x,        /* Variavel geral para representar coordenada X */
          y,        /* Variavel geral para representar coordenada Y */
          x1,       /* Variavel geral para representar coordenada X */
          y1,       /* Variavel geral para representar coordenada Y */
          x2,       /* Variavel geral para representar coordenada X */
          y2,       /* Variavel geral para representar coordenada Y */
          x3,       /* Variavel geral para representar coordenada X */
          y3,       /* Variavel geral para representar coordenada Y */
          co,       /* Variavel geral para representar cosseno */
          si;       /* Variavel geral para representar seno */

    unsigned i, q;
    lugar *a_l = rede->l;
    BITMAP *buff;
    PALETTE pal;
    flecha *a_tl = rede->tl,
           *a_lt = rede->lt;
    /* Inicializacao Allegro */
    if(install_allegro(SYSTEM_NONE, &errno, atexit)!=0)
        exit(EXIT_FAILURE);
    set_color_depth(16);
    get_palette(pal);
    buff = create_bitmap(IMG_X,IMG_Y);
    smaller = (float)IMG_X;
    if(smaller > (float)IMG_Y)
        smaller = (float)IMG_Y;
    r_lugar = smaller/4.0*(M_PI/(M_PI+(float)rede->total_l));
    if(buff == NULL)
    {
        printf("Could not create buffer!\n");
        exit(EXIT_FAILURE);
    }
    /* Desenho propriamente dito */

    if(rede->total_l > rede->total_t)
        ang = M_PI/rede->total_l;
    else
        ang = M_PI/rede->total_t;
    if(DEBUG == B || DEBUG == D) printf("Desenhando %u lugares e %u transicoes espacados entre si %.2fº...\n", rede->total_l, rede->total_t, ang*180.0/M_PI);

    /* Desenhando os lugares  */
    for(i=0;i<rede->total_l;i++)
    {
        a_l = buscarLugarPos(rede->l, i);
        q = 0;
        if(a_l != NULL)
            q = a_l->qtd;
        x = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos(2*i*ang);
        y = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin(2*i*ang);
        circle(buff, x, y, r_lugar, CORBRANCO);
        textprintf_ex(buff, font, x, y, CORVERDE, CORPRETO, "%u", q);
        if(DEBUG == B || DEBUG == D) printf("L%u(%u) (posicionada %.2fº)\n", i, q, ang*(2*i)*180.0/M_PI);
        textprintf_ex(buff, font, x, y - r_lugar, CORVERDE, CORPRETO, "L%u", i);
    }

    /* Desenhando as transicoes  */
    for(i=0;i<rede->total_t;i++)
    {
        x = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos((2*i+1)*ang);
        y = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin((2*i+1)*ang);
        line(buff, x, y+r_lugar, x, y-r_lugar, CORBRANCO);
        if(DEBUG == B || DEBUG == D) printf("T%u (posicionado %.2fº)\n", i, ang*(2*i+1)*180.0/M_PI);
        textprintf_ex(buff, font, x, y - r_lugar, CORVERDE, CORPRETO, "T%u", i);
    }

    /* Desenhando as flechas */
    while(a_tl != NULL)
    {
        i = a_tl->de;
        x1 = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos((2*i+1)*ang);
        y1 = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin((2*i+1)*ang);
        i = a_tl->para;
        x = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos(2*i*ang);
        y = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin(2*i*ang);
        co = lcos(x1,y1,x,y);
        si = lsin(x1,y1,x,y);
        x -= r_lugar*co;
        y -= r_lugar*si;
        line(buff, x1, y1, x, y, CORBRANCO);
        textprintf_ex(buff, font, (x+x1)/2, (y+y1)/2, CORVERDE, CORPRETO, "%u", a_tl->tk);
        x2 = x - (r_lugar / 4) * (si + co);
        y2 = y + (r_lugar / 4) * (co - si);
        x3 = x + (r_lugar / 4) * (si - co);
        y3 = y - (r_lugar / 4) * (si + co);
        triangle(buff, x, y, x2, y2, x3, y3, CORBRANCO);
        a_tl = a_tl->prox;
    }
    while(a_lt != NULL)
    {
        i = a_lt->de;
        x1 = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos(2*i*ang);
        y1 = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin(2*i*ang);
        i = a_lt->para;
        x = IMG_X/2.0 + (IMG_X/2.0 - r_lugar)*cos((2*i+1)*ang);
        y = IMG_Y/2.0 + (IMG_Y/2.0 - r_lugar)*sin((2*i+1)*ang);
        co = lcos(x1,y1,x,y);
        si = lsin(x1,y1,x,y);
        x1 += r_lugar*co;
        y1 += r_lugar*si;
        line(buff, x1, y1, x, y, CORBRANCO);
        textprintf_ex(buff, font, (x+x1)/2, (y+y1)/2, CORVERDE, CORPRETO, "%u", a_lt->tk);
        x2 = x - (r_lugar / 4) * (si + co);
        y2 = y + (r_lugar / 4) * (co - si);
        x3 = x + (r_lugar / 4) * (si - co);
        y3 = y - (r_lugar / 4) * (si + co);
        triangle(buff, x, y, x2, y2, x3, y3, CORBRANCO);
        a_lt = a_lt->prox;
    }
    /* Salvando Imagem */
    save_bitmap(fname, buff, pal);
    destroy_bitmap(buff);
    allegro_exit();
    if(!GIF) printf("Imagem %s salva com sucesso!\n", fname);
    return;
}
예제 #27
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
    HWND dwnd;
    HDC hdc, ddc;
    PAINTSTRUCT ps;
    RECT rc, sz;
    OPENFILENAME fn;
    char filename[256];

    switch (message) {

    case WM_PAINT:
        if (GetUpdateRect(hwnd, &rc, FALSE)) {
            hdc = BeginPaint(hwnd, &ps);

            set_palette_to_hdc(hdc, default_palette);

            if (captured) {
                dwnd = GetDesktopWindow();
                ddc = GetDC(dwnd);

                GetWindowRect(dwnd, &sz);

                location.x = MIN(location.x, sz.right-GRAB_W);
                location.y = MIN(location.y, sz.bottom-GRAB_W);

                blit_from_hdc(ddc, grab_region, location.x, location.y, 0, 0, GRAB_W, GRAB_H);

                ReleaseDC(dwnd, ddc);

                GetClientRect(hwnd, &sz);

                stretch_blit_to_hdc(grab_region, hdc, 0, 0, GRAB_W, GRAB_H, 0, 0, sz.right, sz.bottom);
            }
            else {
                FillRect(hdc, &rc, GetStockObject(WHITE_BRUSH));
                TextOut(hdc, 8, 8, "Click here, then drag over desktop", 34);
            }

            EndPaint(hwnd, &ps);
        }
        return 0;

    case WM_LBUTTONDOWN:
        if (!captured) {
            SetCapture(hwnd);
            captured = TRUE;

            location.x = (short)(lParam & 0xFFFF);
            location.y = (short)(lParam >> 16);

            ClientToScreen(hwnd, &location);

            InvalidateRect(hwnd, NULL, FALSE);
        }
        return 0;

    case WM_LBUTTONUP:
        if (captured) {
            ReleaseCapture();
            captured = FALSE;

            InvalidateRect(hwnd, NULL, FALSE);

            memset(&fn, 0, sizeof(fn));

            fn.lStructSize = sizeof(fn);
            fn.hwndOwner = hwnd;
            fn.lpstrFilter = "Bitmap Files (*.bmp;*.pcx;*.tga)\0*.bmp;*.pcx;*.tga\0All Files (*.*)\0*.*\0";
            fn.lpstrFile = filename;
            fn.nMaxFile = sizeof(filename);
            fn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;

            filename[0] = 0;

            if (GetSaveFileName(&fn)) {
                if (save_bitmap(filename, grab_region, pal) != 0)
                    MessageBox(hwnd, "Error saving bitmap file", NULL, MB_OK);
            }
        }
        return 0;

    case WM_MOUSEMOVE:
        if (captured) {
            location.x = (short)(lParam & 0xFFFF);
            location.y = (short)(lParam >> 16);

            ClientToScreen(hwnd, &location);

            InvalidateRect(hwnd, NULL, FALSE);
        }
        return 0;

    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
예제 #28
0
파일: capture.c 프로젝트: dafyddcrosby/meka
//-----------------------------------------------------------------------------
// Capture_Screen(void)
// Capture current screen to a file
//-----------------------------------------------------------------------------
static void		Capture_Screen(void)
{
    //PALETTE     pal;
    BITMAP *    bmp;
    BITMAP *    source;
    char        s1[FILENAME_LEN];
    int         x_start, x_len;
    int         y_start, y_len;

    // Get a filename
    Capture_FileName_Get(s1);
    if (Capture.id_number >= CAPTURE_ID_MAX)
    {
        Msg(MSGT_USER, Msg_Get(MSG_Capture_Error_File));
        return;
    }

	if ((Meka_State == MEKA_STATE_FULLSCREEN) || (!g_Configuration.capture_include_gui)) 
	{
		// Fullscreen
		source = screenbuffer;
		x_start = cur_drv->x_start;
		y_start = cur_drv->y_show_start;
		x_len = cur_drv->x_res;
		y_len = cur_drv->y_res;

		// Crop left column
		if (g_Configuration.capture_crop_scrolling_column)
		{
			if ((cur_drv->id == DRV_SMS) && (tsms.VDP_VideoMode > 4) && (Mask_Left_8))
			{
				x_start += 8;
				x_len -= 8;
			}
		}

		// Automatic crop on tile boundaries (for map making)
		// In total, remove 8 pixels from each axis
		if (g_Configuration.capture_crop_align_8x8)
		{
			const int scroll_x = cur_machine.VDP.scroll_x_latched;
			const int scroll_y = cur_machine.VDP.scroll_y_latched;
			x_start += scroll_x & 7;
			y_start += 8 - (scroll_y & 7);
			x_len -= 8;
			y_len -= 8;
		}
	}
	else if (Meka_State == MEKA_STATE_GUI)
	{
		// GUI mode
		x_start = 0;
		y_start = 0;
		x_len = g_Configuration.video_mode_gui_res_x;
		y_len = g_Configuration.video_mode_gui_res_y;
		source = gui_buffer;
	}
	else
	{
		// Unknown Mode
		assert(0);
		return;
	}

    acquire_bitmap(source);
    bmp = create_sub_bitmap(source, x_start, y_start, x_len, y_len);
    if (bmp == NULL)
    {
        Msg(MSGT_USER, Msg_Get(MSG_Capture_Error));
        return;
    }
    release_bitmap(source);

    //get_palette(pal);
    if (save_bitmap(s1, bmp, NULL) != 0)
    {
        Msg(MSGT_USER, Msg_Get(MSG_Capture_Error));
        destroy_bitmap(bmp);
        return;
    }

    destroy_bitmap(bmp);

    // Verbose
    killpath(s1);
    Msg(MSGT_USER, Msg_Get(MSG_Capture_Done), s1);
}
예제 #29
0
파일: Manual.c 프로젝트: dvelazquez/Coco
int Manual()
{
  int PVi, k;
        K= uatof(Gain);
  /* Things will be drawn more quickly if you always acquire the screen before
     trying to draw onto it. */
  acquire_screen();
  
  Graphics();	/* Call to graphics from a different function to avoid messy code */
  
  int dir = 1;   //since we are receiving data, direction should be 1
  int mode = IEEE1284_MODE_COMPAT; // parameter to set mode 'receive'
  RLE_SPRITE *rle;
  
  /* Set the direction for reception */
  ioctl(fd, PPDATADIR, &dir);
  ioctl(fd, PPWDATA, 0);
  
  PVi= 0;  k= 100;  M=0;
  while (!key[KEY_ESC])	/* Only pressing ESC can Exit */
    {
      M++;
      /* Check if user needs some help */
      if(key[KEY_F1])
	Help();

      k++;
      i= 897;
      
      Captura = create_sub_bitmap(screen, 72, 350, 898, 368);
      rle = get_rle_sprite(Captura);
      destroy_bitmap(Captura);
      draw_rle_sprite(screen, rle, 71, 350);
      destroy_rle_sprite(rle);
      
      /* This line reads data from the interfase which is
	 the process variable(measured variable) of the system */
      ioctl(fd, PPRDATA, &PVi);
      PV= PVi;
      
      if(PV<=40)
	{
	  PV= 51;
	  system("festival --tts Messages/Disconnected&");
	  blit(Disconnected, screen, 0, 0, 70, 290, 887, 52);   
	}
      
      if(PV<=48)
        PVi= 51;
      
      PV= 1.794117647*(PVi-51);
      SP= PV;
      
      if(key[KEY_RIGHT])
	{
          fd = close("/dev/parport0");	
	  Simulator();
        }
      if(key[KEY_PGUP])
	OP= (OP+46);
      
      if(key[KEY_PGDN])
	OP= (OP-46);
      
      if(key[KEY_UP])
	OP= (OP+3.66);
      
      if(key[KEY_DOWN])
	{
	  if(OP>=1)
	    OP= (OP-3.66);
	}
      
      if(key[KEY_PRTSCR])
	{
          Captura = create_sub_bitmap(screen, 0, 0, 1024, 768);
          save_bitmap("images/User/Captura.pcx", Captura, pal);
          destroy_bitmap(Captura);
        }
      
      Timer++;
      
      if(OP<=0)
	OP= 0;
      
      
      if (PV>=40)
	{
	  textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100);	// Medición
	  textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100);	// SP
	  textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100);	// Controlador
	}
      
      if(k>=100)
	{
 	  k= 0;
	  vline(screen, 967, 351, 717, GRAY);
          blit(Clean, screen, 0, 0, 968, 350, 2, 368);
	}
      
      int Recorder;
      Recorder++;
      if(Recorder>=900)
	{
 	  Recorder= 0;
	  Captura = create_sub_bitmap(screen, 258, 350, 715, 368);
	}
      
      Captura = create_sub_bitmap(screen, 248, 350, 705, 368);
      
      
      if(PV>=362) PV= 365;
      if(OP>=367) OP= 365;
      
      if(PV<=0) PV= 0;
      if(OP<=0) OP= 0;
      
      /* Draw the behaviour of the PV, SP and OP over time */
      line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED);	
      PVj= PV;    /* Flag for line y2 as a precedent state */
      line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE);	
      OPj= OP;    /* Flag for line y2 as a precedent state */
      
      fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100));
      rest(Delay);
    }
  int ScreenWide;
  RLE_SPRITE *rle0, *rle1;
  BITMAP *Screen3;

  Screen3 = load_bitmap("images/Close/Base.pcx", pal);
  system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
  rest(5);

  rle0= get_rle_sprite(Screen2);
  rle1= get_rle_sprite(Screen3);
  
  for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5)
    {
      draw_rle_sprite(screen, rle0, 0, 768);
      draw_rle_sprite(screen, rle1, 0, -768+ScreenWide);
    }

  destroy_rle_sprite(rle0);  
  destroy_rle_sprite(rle1);    
  destroy_bitmap(Screen2);
  destroy_bitmap(Screen3);
  destroy_bitmap(Clean);
  destroy_bitmap(Disconnected);
  release_screen();
  Close();
  exit(0);
} 
예제 #30
0
파일: Manual.c 프로젝트: dvelazquez/Coco
int Manual(int argc, unsigned char **argv)
{
  /* Serial port initialization */

  fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd == -1) {
    perror("open_port: Unable to open /dev/ttyS0 - ");
    return 1;
  } else {
    fcntl(fd, F_SETFL, 0);
  }
  getbaud(fd);

  initport(fd);

  int PVi, k;
        K= uatof(Gain);
  /* Things will be drawn more quickly if you always acquire the screen before
     trying to draw onto it. */
  acquire_screen();
  
  Graphics();	/* Call to graphics from a different function to avoid messy code */
  
  RLE_SPRITE *rle;
 
            sCmd[0]= 'C';
            writeport(fd, sCmd);

  PVi= 0;  k= 100;  M=0;
  while (!key[KEY_ESC])	/* Only pressing ESC can Exit */
    {
	char ValveState;
	if(ValveState=='O')
	{
            sCmd[0]= 'A';
            writeport(fd, sCmd);
	}
	if(ValveState=='C')
	{
            sCmd[0]= 'C';
            writeport(fd, sCmd);
	}
	


      M++;
      /* Check if user needs some help */
      if(key[KEY_F1])
	Help();

      k++;
      i= 897;
      
      Captura = create_sub_bitmap(screen, 72, 350, 898, 368);
      rle = get_rle_sprite(Captura);
      destroy_bitmap(Captura);
      draw_rle_sprite(screen, rle, 71, 350);
      destroy_rle_sprite(rle);

      /* This line reads data from the interfase which is
	 the process variable(measured variable) of the system */
          fcntl(fd, F_SETFL, FNDELAY); // don't block serial read
	  readport(fd,sResult);
	  PVi= (int) *sResult;
	  PV= PVi;      
/*
      if(PVi<=40)
	{
	  PV= 51;
	  system("festival --tts Messages/Disconnected&");
	  blit(Disconnected, screen, 0, 0, 70, 290, 887, 52);   
	}
   */   
      if(PV<=48)
        PVi= 51;
      
      PV= 1.794117647*(PVi-51);
      SP= PV;
      
      if(key[KEY_RIGHT])
	{
          //fd = close("/dev/parport0");	
	  Simulator();
        }
      if(key[KEY_PGUP])
	OP= (OP+46);
      
      if(key[KEY_PGDN])
	OP= (OP-46);
      
      if(key[KEY_UP])
	{
	    OP=162; //(OP+3.66);
            sCmd[0]= 'A';
            writeport(fd, sCmd);
	    ValveState='O';
	}

      if(key[KEY_DOWN])
	{
	  if(OP>=1)
	    OP= 0;//(OP-3.66);
            sCmd[0]= 'C';
            writeport(fd, sCmd);
	    ValveState='C';
	}
      
      if(key[KEY_PRTSCR])
	{
          Captura = create_sub_bitmap(screen, 0, 0, 1024, 768);
          save_bitmap("images/User/Captura.pcx", Captura, pal);
          destroy_bitmap(Captura);
        }
      
      Timer++;
      
      if(OP<=0)
	OP= 0;
      
      
//      if (PV>=40)
//	{
	  textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100);	// Medición
	  textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100);	// SP
	  textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100);	// Controlador
//	}
      
      if(k>=100)
	{
 	  k= 0;
	  vline(screen, 967, 351, 717, GRAY);
          blit(Clean, screen, 0, 0, 968, 350, 2, 368);
	}
      
      int Recorder;
      Recorder++;
      if(Recorder>=900)
	{
 	  Recorder= 0;
	  Captura = create_sub_bitmap(screen, 258, 350, 715, 368);
	}
      
      Captura = create_sub_bitmap(screen, 248, 350, 705, 368);
      
      
      if(PV>=362) PV= 365;
      if(OP>=367) OP= 365;
      
      if(PV<=0) PV= 0;
      if(OP<=0)
	 OP= 1;
/*
      OPi= fixtoi(itofix((OP*0.69234783)/255*100));
      sCmd[0]= (unsigned char)OPi+50;
      sCmd[0]= sCmd[0]+0.00;
      writeport(fd, sCmd);
*/
//     textprintf_ex(screen, font, 30, 297, BLACK, WHITE, "%i - %s - %3.1f", PVi, sResult, PV);	// Medición      

      /* Draw the behaviour of the PV, SP and OP over time */
      line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED);	
      PVj= PV;    /* Flag for line y2 as a precedent state */
      line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE);	
      OPj= OP;    /* Flag for line y2 as a precedent state */
      
      fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100));
      rest(Delay);
    }
  int ScreenWide;
  RLE_SPRITE *rle0, *rle1;
  BITMAP *Screen3;

  Screen3 = load_bitmap("images/Close/Base.pcx", pal);
  system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &");
  rest(5);

  rle0= get_rle_sprite(Screen2);
  rle1= get_rle_sprite(Screen3);
  
  for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5)
    {
      draw_rle_sprite(screen, rle0, 0, 768);
      draw_rle_sprite(screen, rle1, 0, -768+ScreenWide);
    }

  destroy_rle_sprite(rle0);  
  destroy_rle_sprite(rle1);    
  destroy_bitmap(Screen2);
  destroy_bitmap(Screen3);
  destroy_bitmap(Clean);
  destroy_bitmap(Disconnected);
  release_screen();
  Close();
  exit(0);
}