示例#1
0
static void setup_gui_texture()
{
	unsigned int width, height;
	unsigned short int bits;
	unsigned char *bgr;
	GLenum format;

	glGenTextures(1, &gui.background.texture);
	glBindTexture(GL_TEXTURE_2D, gui.background.texture);

	bgr = load_bmp(gui.background.filename, &width, &height, &bits);
	format = (bits == 24? GL_BGR: GL_BGRA);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, bgr);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
	glGenerateMipmap(GL_TEXTURE_2D);

	for(int i=0; i<2; ++i)
	{
		for(int j=0; j<gui.button_num; ++j)
		{
			glGenTextures(1, &gui.buttons[j].texture[i]);
			glBindTexture(GL_TEXTURE_2D, gui.buttons[j].texture[i]);

			bgr = load_bmp(gui.buttons[j].filename[i], &width, &height, &bits);
			format = (bits == 24? GL_BGR: GL_BGRA);
			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, bgr);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
			glGenerateMipmap(GL_TEXTURE_2D);
		}
	}

	delete [] bgr;
}
示例#2
0
文件: Film.cpp 项目: mansehr/legacy
void main()
{
   allegro_init();
   install_keyboard();
   install_timer();
   set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);

   explosion = load_bmp("explosion.bmp",pal);
   starShip = load_bmp("rymdskepp.bmp",pal);
   theWorld = load_bmp("theWorld.bmp",pal);
   screenBuffer = create_bitmap(SCREEN_W, SCREEN_H);

   set_pallete(pal);

   int X = 0, initX = retrace_count + 1100;
   int textX, initTextX = retrace_count + 40;
   char *text;
   while (X < 500 && !key[KEY_ESC])
   {
      X = (retrace_count-initX)/3;
      textX = 640-(retrace_count-initTextX);

      blit(theWorld, screenBuffer, 0, 0, 0, 0, 640, 480);

      if (X > 300)
      {
         blit(explosion, screen, 0, 0, 0, 0, 640, 480);
      }
      else
      {
         draw_sprite(screenBuffer, starShip, X, 220);
      }

      sprintf(text,"StarshipX: %d  TextX: %d", X, textX );
      textout(screenBuffer, font, text, 5, 5, 13);
      textout(screenBuffer, font, "The year is 2569, the date is 12 of february! The time 12:34 local!..
This happends............................Bzzz Were going too chrash. Bzzz....Watchout....................
Bzzzzzz.....Bzzzzz............NOOOOOOOOOOOOOOOOOOOOOOOOO" , textX, 60, 200);

      blit(screenBuffer, screen, 0, 0, 0, 0, 640, 480);
   }


   textout(screen, font, "Scary isnt it......" , 120, 40, 200);
   textout(screen, font, "Press [A Key] to exit.." , 100, 180, 200);

   readkey();


   destroy_bitmap(screenBuffer);
   destroy_bitmap(theWorld);
   destroy_bitmap(explosion);
   destroy_bitmap(starShip);
}
示例#3
0
/**
	desc:load transparent texture from bmp image.In order to crate a transparent texute, you need to do the following things.
	1.load bmp image to structure of  AUX_RGBImageRec
	2.read bmp image to buffer, and according to the color set the alpha value.
	3.enable opengl alpha test.
*/
int ctexture::load_transp_textures(const char** filename,int n)
{
	assert(filename!=NULL && n>0);
	glGenTextures(n,&textureObjects[num]);
	for(int i=0;i<n;i++){
		AUX_RGBImageRec* textureImage[1];
		if(textureImage[0]=load_bmp(*(filename+i))){		
			unsigned char* image;
			int width=0,height=0;
			width = textureImage[0]->sizeX;
			height = textureImage[0]->sizeY;
			FILE *fp;
			fp = fopen(*(filename+i),"rb");
			if(!fp) return -1;
			fseek(fp,54,SEEK_SET);
			image = (unsigned char*)malloc(width*height*3);
			int rc =fread(image,sizeof(unsigned char),width*height*3,fp);
			fclose(fp);
			create(image,width,height,i+num);
		}
		if(textureImage[0]){
			if(textureImage[0]->data){
				free(textureImage[0]->data);
			}
			free(textureImage[0]);
		}
	}
	num+=n;
	return 0;
}
示例#4
0
文件: menu.c 项目: joakim-d/GroBoy
void load_gui(SDL_Surface *sdl_screen) {
    static Uint8 *keystate;
    int play = 0;

    if(load_bmp("fonts/gui_font.bmp") == -1) {
        printf("Loading bmp font error\n");
    }

    bg_color = SDL_MapRGB(sdl_screen->format, 255, 255, 255);
    display_menu(sdl_screen);
    cursor_pos = 0;
    while (!play) {
        SDL_PumpEvents();
        keystate = SDL_GetKeyState(NULL);
        if(keystate[SDLK_UP]) {
            move_cursor(sdl_screen, UP);
        }
        if(keystate[SDLK_DOWN]) {
            if(strcmp(selected_game, "") == 0 && cursor_pos < 2) move_cursor(sdl_screen, DOWN);
            else if (strcmp(selected_game, "") != 0 && cursor_pos < 3) move_cursor(sdl_screen, DOWN);
        }
        if(keystate[SDLK_RETURN]) play = menu_action(sdl_screen);
        if(keystate[SDLK_ESCAPE]) break;
        SDL_Flip(sdl_screen);
        SDL_Delay(100);
    }
}
void enc_astc_file(char* filename, char* dst_filename)
{
    rgba_surface src_img;
    load_bmp(&src_img, filename);
    flip_image(&src_img);

    int block_width = 6;
    int block_height = 6;

    rgba_surface output_tex;
    output_tex.width = idiv_ceil(src_img.width, block_width);
    output_tex.height = idiv_ceil(src_img.height, block_height);
    output_tex.stride = output_tex.width * 16;
    output_tex.ptr = (uint8_t*)malloc(output_tex.height * output_tex.stride);

    rgba_surface edged_img;
    fill_borders(&edged_img, &src_img, block_width, block_height);

    printf("encoding <%s>...", filename);

    compress_astc_tex(&output_tex, &edged_img, block_width, block_height);

    printf("done.\n");

    output_tex.width = src_img.width;
    output_tex.height = src_img.height;
    store_astc(&output_tex, block_width, block_height, dst_filename);
}
示例#6
0
int main(const int argc, const char ** const argv)
{
    if (argc < 2) {
        printf("Usage: %s image.bmp\n", argv[0]);
        return 1;
    }
 
    static bitmap_info_header_t ih;
    const pixel_t *in_bitmap_data = load_bmp(argv[1], &ih);
    if (in_bitmap_data == NULL) {
        fprintf(stderr, "main: BMP image not loaded.\n");
        return 1;
    }
    printf("Info: %d x %d x %d\n", ih.width, ih.height, ih.bitspp);
 
    const pixel_t *out_bitmap_data =
        canny_edge_detection(in_bitmap_data, &ih, 45, 50, 1.0f);
    if (out_bitmap_data == NULL) {
        fprintf(stderr, "main: failed canny_edge_detection.\n");
        return 1;
    }
 
    if (save_bmp("out.bmp", &ih, out_bitmap_data)) {
        fprintf(stderr, "main: BMP image not saved.\n");
        return 1;
    }
 
    free((pixel_t*)in_bitmap_data);
    free((pixel_t*)out_bitmap_data);
    return 0;
}
示例#7
0
文件: palette.c 项目: pjmodi/projects
void main()
{
  BITMAP bmp;
  int i;

  load_bmp("mset.bmp",&bmp);          /* open the file */

  set_mode(VGA_256_COLOR_MODE);       /* set the video mode. */

  set_palette(bmp.palette);           /* set the palette */

  draw_bitmap(&bmp,                   /* draw the bitmap centered */
    (SCREEN_WIDTH-bmp.width) >>1,
    (SCREEN_HEIGHT-bmp.height) >>1);

  wait(25);

  for(i=0;i<510;i++)                  /* rotate the palette at 30hz */
  {
    wait_for_retrace();
    wait_for_retrace();
    rotate_palette(bmp.palette);
  }

  wait(25);

  free(bmp.data);                     /* free up memory used */

  set_mode(TEXT_MODE);                /* set the video mode back to
                                         text mode. */

  return;
}
示例#8
0
void draw_gameover(void)
{
	short int ret = load_bmp("GO.BMP", &background_bmp);
    short int ret1 = load_bmp("CURSOR.BMP", &cursor_bmp);

	// Draw background to both buffers

	draw_bmp(background_bmp, 0, 240 - background_bmp->bmp_info_header->height,
			false, back_alpha, 1);

	swap_buffers();

	draw_box( 90,  90,  110,  110, back_alpha,  1);
	draw_bmp(background_bmp, 0, 240 - background_bmp->bmp_info_header->height,
				false, back_alpha, 1);

}
/* ----------------------------------------------------------------------------
 * Returns the specified bitmap, by name.
 */
ALLEGRO_BITMAP* bmp_manager::get(
    const string &name, data_node* node,
    const bool report_errors
) {
    if(name.empty()) return load_bmp("", node, report_errors);
    
    if(list.find(name) == list.end()) {
        ALLEGRO_BITMAP* b =
            load_bmp(base_dir + "/" + name, node, report_errors);
        list[name] = bmp_info(b);
        total_calls++;
        return b;
    } else {
        list[name].calls++;
        total_calls++;
        return list[name].b;
    }
};
示例#10
0
void load_image(const char * file_name) {
	bmp image;
	load_bmp(file_name, &image);
	LOG_MSG("Loading image from %s", file_name);
	pthread_mutex_lock(&images_mutex);
	images[available_images_count++] = image;
	LOG_MSG("image from %s loaded in index %d", file_name, available_images_count - 1);
	pthread_mutex_unlock(&images_mutex);
}
示例#11
0
image_file::image_file( const string256& filename , file_type type  ) : _data(0)
{
	if( type == tga )
		load_tga( filename );
	else if( type == bmp )
		load_bmp( filename );
	else
		CRAP_ASSERT_ERROR( "Only TGA and BMP supported yet" );
}
示例#12
0
bool fundo::carregar(string arquivo)
{
    if(!egl_init)
        return false;
    if(bmp)
        destroy_bitmap(bmp);
    bmp = load_bmp(arquivo.c_str(),0);
    if(!bmp)
        return false;
    return true;
}
示例#13
0
int	main(int ac, char **av)
{
  t_data		data;

  ac = ac;
  if ((data.image = load_bmp(&data, av[1])) == NULL)
    return (1);
  data.window = bunny_start(data.bmp.width, data.bmp.height, 0, "load_functions, It Woks Well");
  bunny_set_loop_main_function(main_loop);
  bunny_loop(data.window, 60, &data);
  return (0);
}
示例#14
0
int main(int argc, char* argv)
{
	turn_on_debug_output();
	create_image_world();
	
	// Write your code here
	int v = load_bmp("plane.bmp");
	put_image(v, (get_screen_width() / 2) - (get_image_width(v) / 2), (get_screen_height() / 2) - (get_image_height(v) / 2));
	
	return p1world_shutdown();

}
//default constructor which initializes tiles in order from 1 - 15
TileShop::TileShop()
{
    moves = 0;
    pictures = load_bmp("tiles.bmp", NULL);
    click = load_sample("click.wav");
    for (int i = 0; i < 16; i++)
    {
        tiles[i] = Tile(i, pictures);
    }
    sortTiles();

}
示例#16
0
int main(void)
{
	//Create game object
	zephyrjc_t *game = zephyrjc_init();

	//Init graphics
	zephyrjc_init_graphics(game, 640, 480, 32);

	//Init keyboard
	zephyrjc_keyboard_init(game);

	//Create scenario and set as current
	scenario_t *test_scenario = scenario_create(game);
	zephyrjc_set_current_scenario(game, test_scenario);

	//Create an abstract object
	object_t *obj = object_create(test_scenario);

	//Add transform component to object
	component_t *transform = transform_create(obj);

	//Add tilemap
	component_t *tileengine = tileengine_create(obj);
	tilepool_t *tp = create_tilepool("tiles.png", 16, 16, 0, 0, 55, 36);

	uint16_t test_array[36][55];
	for(int y=0;y<36;y++)
	{
		for (int x=0;x<55;x++)
		{
			test_array[y][x] = x+y*55;
		}
	}

	tilemap_t *tilemap = create_tilemap(tp, (uint16_t*) *test_array, 55, 36, 0);
	tileengine_t *cte = (tileengine_t*) tileengine;
	cte->current_tilemap = tilemap;
	cte->source.x = 0;
	cte->source.y = 0;
	cte->source.w = 640;
	cte->source.h = 480;

	//Add sprite component to object. Set sprite
	sprite_t *sp = (sprite_t*) sprite_create(obj);
	spriteBuffer_t *sprite = create_sprite();
	load_bmp(sprite, "mario.png");
	sprite_set(sp, sprite);

	//Start Zephyr Jarlsberg & Chedar engine
	zephyrjc_start(game);
	return 0;
}
示例#17
0
文件: main.cpp 项目: JPTIZ/cpp-utils
int main(int argc, const char* argv[]) {
    std::cout << "argc = " << argc << std::endl;
    for (auto i = 0u; i < argc; ++i) {
        std::cout << argv[i] << std::endl;
    }
    BMP bmp;
    load_bmp(bmp, argv[1]);
    show_bmp_data(bmp);
    convert_to_16bpp(bmp);
    save_header(bmp, argv[1]);
    nice();
    return 0;
}
示例#18
0
void init_fonts() {
    int font_ranges[] = {
        0x0020, 0x007E, // ASCII
        0x00A0, 0x00A1, // Non-breaking space and inverted !
        0x00BF, 0x00FF, // Inverted ? and European vowels and such
    };
    int counter_font_ranges[] = {
        0x002D, 0x002D, // Dash
        0x002F, 0x0039, // Slash and numbers
        0x0078, 0x0078, // x
    };
    int value_font_ranges[] = {
        0x0024, 0x0024, // Dollar sign
        0x002D, 0x002D, // Dash
        0x0030, 0x0039, // Numbers
    };
    
    // We can't load the font directly because we want to set the ranges.
    // So we load into a bitmap first.
    ALLEGRO_BITMAP* temp_font_bitmap = load_bmp("Font.png");
    if(temp_font_bitmap) font = al_grab_font_from_bitmap(temp_font_bitmap, 3, font_ranges);
    al_destroy_bitmap(temp_font_bitmap);
    
    temp_font_bitmap = load_bmp("Area_name_font.png");
    if(temp_font_bitmap) font_area_name = al_grab_font_from_bitmap(temp_font_bitmap, 3, font_ranges);
    al_destroy_bitmap(temp_font_bitmap);
    
    temp_font_bitmap = load_bmp("Counter_font.png");
    if(temp_font_bitmap) font_counter = al_grab_font_from_bitmap(temp_font_bitmap, 3, counter_font_ranges);
    al_destroy_bitmap(temp_font_bitmap);
    
    temp_font_bitmap = load_bmp("Value_font.png");
    if(temp_font_bitmap) font_value = al_grab_font_from_bitmap(temp_font_bitmap, 3, value_font_ranges);
    al_destroy_bitmap(temp_font_bitmap);
    
    if(font) font_h = al_get_font_line_height(font);
    if(font_counter) font_counter_h = al_get_font_line_height(font_counter);
}
示例#19
0
文件: tiles.c 项目: jia200x/ZephyrJC
tilepool_t *create_tilepool(char *filename, uint16_t tw, uint16_t th, uint16_t xoff, uint16_t yoff, uint16_t cols, uint16_t rows)
{
	tilepool_t *tp = (tilepool_t*) malloc(sizeof(tilepool_t));	
	tp->_tilemap = create_sprite();
	load_bmp(tp->_tilemap, filename);

	tp->_tw = tw;
	tp->_th = th;
	tp->_xoffset = xoff;
	tp->_yoffset = yoff;
	tp->_cols = cols;
	tp->_rows = rows;
	return tp;
}
示例#20
0
int main(int argc, char **argv) {
    Image img;
    Row *sparse_matrix; 

    if ( argc != 2 ) {
        test_basic();
    } else {
        img = load_bmp(argv[1]);

        sparse_matrix = dense_to_sparse(img.data, img.width, img.height);
        test_sparse(argv[1], sparse_matrix);
        free_sparse(sparse_matrix);
    }
    return 0;
}
示例#21
0
文件: load_image.c 项目: dwdcth/LCUI
static int detect_image(const char *filepath, LCUI_Graph *out)
/* 功能:检测图片格式,并解码图片 */
{
	int result = 1;
	if (result == 1) {
		result = load_png(filepath, out);  
	}
	if (result == 1) {
		result = load_jpeg(filepath, out);  
	}
	if (result == 1) {
		result = load_bmp(filepath, out); 
	}
	return result;
}
示例#22
0
文件: pc_slot.cpp 项目: jonsource/dng
int PCSLOT::setCharacter(Character * cr)
{   PALETTE pal;
    this->character=cr;
    this->state=PC_SLOT_PORTRAIT;
    string str = "data/images/portraits/"+cr->name+".bmp";
    this->portrait = load_bmp(str.c_str(),pal);

    if(this->portrait == NULL)
    {   debug("Portrait "+cr->name+" not found!",10);
        this->portrait = create_bitmap(95,95);
        clear_to_color(this->portrait,makecol(255,128,72));
        return 2;
    }
    return 1;
}
示例#23
0
RoadMapImage roadmap_canvas_agg_load_image (const char *path,
                                            const char *file_name) {

   char *full_name = roadmap_path_join (path, file_name);
   RoadMapImage image;

   if ((strlen(file_name) > 4) &&
      !strcasecmp (file_name + strlen(file_name) - 4, ".png")) {

      image = load_png (full_name);
   } else {
      image = load_bmp (full_name);
   }

   free (full_name);

   return image;
}
示例#24
0
//CARREGAR ARQUIVOS DO JOGO
void load_jogo(){
	jogadorr.inicia();
	//BMPS
	casa_a = load_bmp("imagens/casa_final.bmp", NULL);
	casa_c = load_bmp("imagens/casa_final_colisao.bmp", NULL);
	casa_b = load_bmp("imagens/casa_final_alto.bmp",NULL);
	bosque_a = load_bmp("imagens/bosque1.bmp", NULL);
	bosque_b = load_bmp("imagens/bosque1_ceu.bmp", NULL);
	bosque_c = load_bmp("imagens/bosque1_colisao.bmp", NULL);
	bosque2_a =	load_bmp("imagens/bosque2.bmp", NULL);
	bosque2_b = load_bmp("imagens/bosque2_alto.bmp", NULL);
	bosque2_c = load_bmp("imagens/bosque2_colisao.bmp", NULL);
	
	
	//IMAGENS DO PRIMEIRO CENARIO
	fundo = casa_a;
	colisao = casa_c;
	alto = casa_b;
	lugar = 1;
	
	desloca_mapa_x = 0; //CONTEM O VALOR DO DESLOCAMENTO DO SCROOL X
	desloca_mapa_y = 0; //CONTEM O VALOR DO DESLOCAMENTO DO SCROLL Y
	desloca = false; //ENQUANTO FOR FALSE O MAP NAO TERA O SCROLL
}
示例#25
0
int main(int argc, char *argv[])
{
    image_t *img, *dst;

    if (argc < 3) {
        printf("Usage : <src_path> <dst_path>.\n");
    }

    img = load_bmp(argv[1]);

    dst = gauss_filter(img, 10);

    save_as_bmp(dst, argv[2]);

    img_destroy(img);
    img_destroy(dst);

    return 0;
}
示例#26
0
char			open_palette(t_tekpaint *tekpaint)
{
  t_bunny_position	pos;
  t_palette		*palette;

  palette = &tekpaint->tool.palette;
  palette->win = bunny_start_style(PALETTE_WIDTH, PALETTE_HEIGHT,
				   TITLEBAR | CLOSE_BUTTON,
				   "Palette de couleurs");
  if (NULL == (palette->buffer = load_bmp("res/palette.bmp")))
    return (0);
  pos.x = 0;
  pos.y = 0;
  bunny_blit(&palette->win->buffer, &palette->buffer->clipable, &pos);
  bunny_set_click_response(on_palette_event_click);
  bunny_set_loop_main_function((t_bunny_loop)main_loop_palette);
  bunny_loop(palette->win, 50, tekpaint);
  bunny_stop(palette->win);
  palette_reset(palette);
  return (1);
}
示例#27
0
Err		load_game(t_info *info)
{
  int		i;

  info->selection = DEFAULT_ID;
  info->game.keyshift = 0;
  info->game.keydown = 0;
  info->game.keyup = 0;
  info->game.keyleft = 0;
  info->game.keyright = 0;
  info->game.mousehoriz = 0;
  info->game.mouseverti = 0;
  info->game.exit = 0;
  for (i = 0; i < NB_ITEMS; i++)
    if (gl_items[i].path)
      load_bmp(&(info->img[i]), gl_items[i].path);
    else
      info->img[i] = 0;
  if ((i = init_map(info, info->file)))
    return (i);
  return (load_gamespace(info));
}
示例#28
0
char		on_load_bmp_click(t_tekpaint *tekpaint)
{
  t_explorer	explorer_var;

  explorer_var.extension = ".bmp";
  explorer_var.win_name = "Charger une image BMP";
  tekpaint->tool.current_tool = 0;
  if (explorer(tekpaint, &explorer_var))
    {
      tekpaint->tool.bmp_buffer_tmp = load_bmp(explorer_var.img);
      if (!tekpaint->tool.bmp_buffer_tmp)
	  my_putstr("Erreur durant le chargement de l'image\n");
      else
	{
	  tekpaint->tool.current_tool = BMP_LOAD_TOOL;
	  my_putstr("Image chargé !\n");
	  my_putstr("Cliquez quelque part sur l'écran !\n");
	}
    }
  bunny_set_click_response(on_win_click);
  return (1);
}
示例#29
0
	const BITMAP_ptr tilemap::load_tileset(const TiXmlElement * const texture)
	{
		const TiXmlElement *element = NULL;
		const TiXmlNode *node = NULL;
		std::string path;
		iq::BITMAP_ptr tileset;

		if((element = texture->FirstChildElement("FileName")) == NULL)
			throw std::runtime_error("MAP_TEXTURE XML is missing FileName element.");

		if((node = element->FirstChild()) == NULL || node->Type() != TiXmlNode::TEXT)
			throw std::runtime_error("FileName XML is missing it's text value.");

		path = node->ToText()->ValueStr();

		tileset.reset(load_bmp(path.c_str(), NULL), destroy_bitmap);

		if(tileset.get() == NULL)
			throw std::runtime_error("Failed to load tileset '" + path + "'.");

		return tileset;
	}
示例#30
0
int load_next()
{

    FRESULT res;

    char *fn=0;   /* This function is assuming non-Unicode cfg. */

    do {
	    do {
		    res = f_readdir(&dir, &fno);                   /* Read a directory item */
		    if (res != FR_OK ) {  
		        message("Error reading directory !");
		        die (2,3);
		    }

		    if (fno.fname[0] == 0) { // end of dir ? rescan
		    	f_closedir(&dir);
			    if (f_opendir(&dir, ROOT_DIR) != FR_OK ) {
			    	message("Error reloading directory !");
			    	die (2,4);
			    }
		    }
		} while ( fno.fname[0] == 0 );
		message("debug: next file, now : %s, %d, %x,%x\n",fno.fname,(endsWith(fno.fname,".bmp") || endsWith(fno.fname,".BMP")),fno.fattrib, AM_DIR);


	    if (!(fno.fattrib & AM_DIR)) { // not a dir
	    	// check extension : only keep .bmp files
	    	if (endsWith(fno.fname,".bmp") || endsWith(fno.fname,".BMP")) { // search ignoring case
			    fn = fno.fname; // ok will load it
	    		message("ok, will load %s\n",fn);
	    	}
	    }
	} while (fn==0); 

	message("now loading : %s\n",fn);
	return load_bmp(fn);

}