int main(int argc, char* argv[]) { //初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL NGE_Init(INIT_VIDEO); //初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理 //home消息,通常填1正常退出(1.50版的自制程序需要填0) InitInput(btn_down,NULL,1); //最后一个参数是psp swizzle优化,通常填1 p_bg = image_load("images/demo0.jpg",DISPLAY_PIXEL_FORMAT_8888,1); if(p_bg == NULL) { printf("can not open file\n"); } p_logo = image_load("images/nge2logo.png",DISPLAY_PIXEL_FORMAT_4444,1); if(p_logo == NULL) { printf("can not open file\n"); } //创建一个半透明的图片遮罩color logomask1 = CreateColor(255,255,255,128,p_logo->dtype); //随便创建一个图片遮罩color logomask2 = CreateColor(100,100,100,255,p_logo->dtype); while ( !game_quit ) { ShowFps(); InputProc(); DrawScene(); } image_free(p_bg); image_free(p_logo); NGE_Quit(); return 0; }
int fini() { image_free(p_bg); p_bg = NULL; image_free(p_logo); p_logo = NULL; NGE_Quit(); return 0; }
int main(int argc, char* argv[]) { PFont pf[2] ; int i; NGE_Init(INIT_VIDEO); //NGE_SetFontEncoding(NGE_ENCODING_UTF_8); InitInput(btn_down,btn_up,1); int maxid = GetInfoCount(); //创建一个显示image,字就显示在这个上面注意DISPLAY_PIXEL_FORMAT必须与创建字体的DISPLAY_PIXEL_FORMAT一致 pimage_text = image_create(512,512,DISPLAY_PIXEL_FORMAT_4444); //创建字体 pf[0] = create_font_hzk("fonts/GBK14","fonts/ASC14",14,DISPLAY_PIXEL_FORMAT_4444); pf[1] = create_font_freetype("fonts/simfang.ttf",13,DISPLAY_PIXEL_FORMAT_4444); char str[3][128]={"【小萝莉】","众芳摇落独暄妍,占尽风情向小园。","疏影横斜水清浅,暗香浮动月黄昏。"}; //显示GBK Font font_setcolor(pf[0],MAKE_RGBA_4444(128,0,0,255)); font_drawtext(pf[0],str[0],strlen(str[0]),pimage_text,100,195,FONT_SHOW_NORMAL); NGE_SetFontEncoding(NGE_ENCODING_GBK); for(i = 0;i<maxid;i++){ font_drawtext(pf[0],CreateInfoByid(i),strlen(CreateInfoByid(i)),pimage_text,120,200+i*20,FONT_SHOW_SHADOW); font_setcolor(pf[0],MAKE_RGBA_4444(255,0,0,255)); } //显示freetype font_setcolor(pf[1],MAKE_RGBA_4444(128,0,0,255)); NGE_SetFontEncoding(NGE_ENCODING_UTF_8); font_drawtext(pf[1],str[0],strlen(str[0]),pimage_text,100,30,FONT_SHOW_NORMAL); //for(i =1;i<3;i++){ // font_drawtext(pf[1],str[i],strlen(str[i]),pimage_text,120,35+i*20,FONT_SHOW_NORMAL); // font_setcolor(pf[1],MAKE_RGBA_4444(255,0,0,255)); //} pimage_bg = image_load("images/demo1_bg.jpg",DISPLAY_PIXEL_FORMAT_8888,1); if(pimage_bg == NULL) { printf("can not open file\n"); } pimage_box = image_load("images/demo1_box.jpg",DISPLAY_PIXEL_FORMAT_8888,1); if(pimage_box == NULL) { printf("can not open file\n"); } pimage_icon[0] = image_load_colorkey("images/demo1_icon0.bmp",DISPLAY_PIXEL_FORMAT_8888,MAKE_RGB(0,0,0),1); pimage_icon[1] = image_load_colorkey("images/demo1_icon1.png",DISPLAY_PIXEL_FORMAT_8888,MAKE_RGB(0,0,0),1); while ( !game_quit ) { ShowFps(); InputProc(); DrawScene(); } font_destory(pf[0]); font_destory(pf[1]); image_free(pimage_bg); image_free(pimage_text); image_free(pimage_box); NGE_Quit(); return 0; }
int fini() { image_free(p_logo); p_logo = NULL; image_free(p_par); p_par = NULL; SAFE_FREE(mParticle); mParticle = NULL; delete mParticleSys; mParticleSys = NULL; NGE_Quit(); return 0; }
void level_unload(void) /* Unloads current level, if there is one */ { if (current_level) { /* Kill all sprites */ objlist_killall(mech_group); objlist_killall(bullet_group); objlist_killall(effects_group); objlist_killall(foreground_group); objlist_killall(ui_group); /* Kill all triggers/generators */ objlist_killall(generator_group); objlist_killall(trigger_group); if (current_level->reason) free(current_level->reason); image_free(current_level->bg_image); if (current_level->free) current_level->free(current_level); else free(current_level); current_level = NULL; /* clear other level specific options */ bonuses_clear(); players_clear(); objdict_clear(sprite_tags); objdict_clear(trigger_tags); } }
/*------------------------------------------------- main ----- | Function main | | Purpose: Reads input from STDIN using getchar(), iterates over | each character and determines whether the character | denotes the end of a sentence or word. After reaching | EOF, prints output of flesch kincaid algorithm results | and exits. | | | Parameters: argc (IN) -- number of arguments | argv (IN) -- Expects the program name, image file, and triples | | | Returns: Only success *-------------------------------------------------------------------*/ int main(int argc, char ** argv) { context = logging_init("prog08"); if (argc < 5) { error("Incorrect number of arguments. Need a file name and at least one triple"); usage(*argv); exit(EXIT_FAILURE); } if ((argc - 2) % 3) { error("Incorrect number of arguments. Triples have 3 values hence the name"); usage(*argv); exit(EXIT_FAILURE); } char * image_file_name = chararr_get(argv, 1); FILE * image_file = fopen(image_file_name, "r"); Image * image = image_file_init(image_file); printf("Original Image:\n\n"); image_print(image); int changed = each_triple(argc, argv, image, image_fill); printf("A total of %d pixels were changed\n", changed); fclose(image_file); free(image_file_name); image_free(image); logging_dest(context); return EXIT_SUCCESS; }
/* frees the image of an avatar, does nothing if image is NULL */ void avatar_free_image(AVATAR *avatar) { if (avatar->image) { image_free(avatar->image); avatar->image = NULL; } }
component* textinput_create(const text_settings *tconf, const char *text, const char *initialvalue) { component *c = widget_create(); textinput *tb = malloc(sizeof(textinput)); memset(tb, 0, sizeof(textinput)); tb->text = strdup(text); memcpy(&tb->tconf, tconf, sizeof(text_settings)); tb->pos = &tb->pos_; // Background for field int tsize = text_char_width(&tb->tconf); image img; image_create(&img, 15*tsize+2, tsize+3); image_clear(&img, COLOR_MENU_BG); image_rect(&img, 0, 0, 15*tsize+1, tsize+2, COLOR_MENU_BORDER); surface_create_from_image(&tb->sur, &img); image_free(&img); // Copy over the initial value memcpy(tb->buf, initialvalue, strlen(initialvalue)+1); // Widget stuff widget_set_obj(c, tb); widget_set_render_cb(c, textinput_render); widget_set_event_cb(c, textinput_event); widget_set_tick_cb(c, textinput_tick); widget_set_free_cb(c, textinput_free); return c; }
void filter_threshold(struct image *img, int threshold) { struct image *dst; int x, y; int r, g, b; int min = 0, max = 255; dst = image_new(img->width, img->height); if(threshold < 0) { min = 255; max = 0; threshold = -threshold; } threshold *= 3; for(y = 0; y < img->height; y++) for(x = 0; x < img->width; x++) { getpixel(img, x, y, &r, &g, &b); if(r + g + b < threshold) setpixel(dst, x, y, min, min, min); else setpixel(dst, x, y, max, max, max); } image_swap(img, dst); image_free(dst); }
void video_thread_periodic(void) { struct image_t img; image_create(&img, 320, 240, IMAGE_YUV422); int i, j; uint8_t u, v; #ifdef SMARTUAV_SIMULATOR SMARTUAV_IMPORT(&img); #else if (video_thread.is_running) { u = 0; v = 255; } else { u = 255; v = 0; } uint8_t *p = (uint8_t *) img.buf; for (j = 0; j < img.h; j++) { for (i = 0; i < img.w; i += 2) { *p++ = u; *p++ = j; *p++ = v; *p++ = j; } } video_thread.is_running = ! video_thread.is_running; #endif cv_run(&img); image_free(&img); }
void filter_contrast(struct image *img) { struct image *dst; int histo[256]; int x, y, i, min = 255, max = 0; int r, g, b; dst = image_new(img->width, img->height); for(y = 0; y < img->height; y++) for(x = 0; x < img->width; x++) { getgray(img, x, y, &r); if(r < min) min = r; if(r > max) max = r; } if(min == max) histo[min] = 127; else for(i = min; i < max + 1; i++) histo[i] = (i - min) * 255 / (max - min); for(y = 0; y < img->height; y++) for(x = 0; x < img->width; x++) { getgray(img, x, y, &r); setpixel(dst, x, y, histo[r], histo[r], histo[r]); } image_swap(img, dst); image_free(dst); }
void filter_crop(struct image *img, int xmin, int ymin, int xmax, int ymax) { struct image *dst; int x, y; int r, g, b; if(xmin < 0) xmin = 0; if(ymin < 0) ymin = 0; if(xmax >= img->width) xmax = img->width - 1; if(ymax >= img->height) ymax = img->height - 1; if(xmin >= xmax || ymin >= ymax) return; dst = image_new(xmax - xmin, ymax - ymin); for(y = 0; y < dst->height; y++) for(x = 0; x < dst->width; x++) { getpixel(img, xmin + x, ymin + y, &r, &g, &b); setpixel(dst, x, y, r, g, b); } image_swap(img, dst); image_free(dst); }
int trap_FreeImage(lua_State *s) { IMAGE *image; trap_args(s, "FreeImage", "p", &image); image_free(image); return 0; }
/* Main function */ char *decode_authimage(struct image *img) { static struct font *font = NULL; char *result; struct image *tmp; int x, y, r, g, b, i; if(!font) { font = font_load_fixed(DECODER, "font.png", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"); if(!font) exit(-1); } /* authimage captchas have 6 characters */ result = malloc(7 * sizeof(char)); memset(result, '\0', 7); /* double the captcha size for better accuracy in the rotation */ tmp = image_dup(img); filter_scale(tmp, 2.0); getpixel(tmp, 0, 0, &r, &g, &b); filter_threshold(tmp, r * 3 / 4); filter_smooth(tmp); filter_threshold(tmp, 220); for(i = 0; i < 6; i++) { int mindiff = INT_MAX, minch = -1, ch; for(ch = 0; ch < font->size; ch++) { int diff = 0; for(y = 0; y < 7; y++) { for(x = 0; x < 5; x++) { int newx, newy, r2; newx = 35.0 + (x + 6 * i) * 218.0 / 34.0 + y * 5.0 / 6.0 + 0.5; newy = 33.0 - (x + 6 * i) * 18.0 / 34.0 + y * 42.0 / 6.0 + 0.5; getpixel(tmp, newx, newy, &r, &g, &b); getpixel(font->img, x + 6 * ch, y, &r2, &g, &b); diff += (r - r2) * (r - r2); } } if(diff < mindiff) { mindiff = diff; minch = ch; } } result[i] = font->glyphs[minch].c; } image_free(tmp); return result; }
int main(int argc, char* argv[]) { //初始化NGE分为VIDEO,AUDIO,这里是只初始化VIDEO,如果初始化所有用INIT_VIDEO|INIT_AUDIO,或者INIT_ALL NGE_Init(INIT_VIDEO); //初始化按键处理btn_down是按下响应,后面是弹起时的响应,0是让nge处理home消息(直接退出),填1就是让PSP系统处理 //home消息,通常填1正常退出(1.50版的自制程序需要填0) InitInput(btn_down,NULL,1); //最后一个参数是psp swizzle优化,通常填1 p_logo = image_load("images/nge2logo.png",DISPLAY_PIXEL_FORMAT_8888,1); if(p_logo == NULL) printf("can not open file\n"); p_par = image_load("par/particles.png",DISPLAY_PIXEL_FORMAT_8888,1); if(p_par == NULL) printf("can not open file\n"); //设置sprite子图 mParticle = (sprite_p)malloc(sizeof(sprite_t)); memset(mParticle,0,sizeof(sprite_t)); mParticle->sprite_image = p_par; mParticle->sprite_clip.left= 0.0f; mParticle->sprite_clip.top= 0.0f; mParticle->sprite_clip.right= 32.0f; mParticle->sprite_clip.bottom = 32.0f; mParticle->sprite_center.x = 16.0f; mParticle->sprite_center.y = 16.0f; mParticleSys = new hgeParticleSystem("par/particle1.psi", mParticle); mParticleSys->MoveTo(480.0f/2, 272.0f/2,0); mParticleSys->Fire(); timer = timer_create(); timer->start(timer); while ( !game_quit ) { ShowFps(); InputProc(); Update(); DrawScene(); LimitFps(60); } image_free(p_logo); image_free(p_par); SAFE_FREE(mParticle); delete mParticleSys; NGE_Quit(); return 0; }
static void DrawImageResourceAtPoint(gl_context_t* context, char const* image_name, GLfloat xFromLeft, GLfloat yFromTop) { image_t* img = bundle_image_named(image_name); rect2d_t r; r.size = image_size(img); r.origin.x = xFromLeft; r.origin.y = rect_top(context->screen_bounds) - r.size.height - yFromTop; image_draw(img, context, r); image_free(img); }
list_t * push_jobs(list_t * files, clinfo_t * clinfo , Eina_Hash *map_histo) { int code; list_t * job_waits = NULL; int count = 0; int histo_done = eina_hash_population(map_histo); int global = list_size(files); while(files != NULL) { char * filename = files->value; files = files->next; histogram_t *cached_elem = eina_hash_find(map_histo, filename); if(cached_elem) continue; image_t * image = image_init(); image->path = filename; image = read_image(image); if (image == NULL) { continue; } if (image->size[0] > *clinfo->max_width || image->size[1] > *clinfo->max_heigth) { printf("Ignoring %s, width=%i, height=%i\n", filename , image->size[0], image->size[1]); image_free(image); continue; } job_t * job = job_init(); code = init_job_from_image(image, job); if(code == EXIT_FAILURE) { fprintf(stderr, "Could not init job from image %i\n" , code); return NULL; } generate_histogram(clinfo, image, job); clFlush(clinfo->command_queue); count++; if ( count > 50 ) { histogram_t *histo = wait_and_fetch_histo_from_job(job); eina_hash_add(map_histo, strdup(histo->file), histo); histo_done++; count--; if(histo_done % 50 == 0) { printf("Processed %i / %i\n", histo_done, global); write_histogram_to_file(CACHE_FILE, map_histo); } } else { job_waits = list_append(job_waits, job); } } return job_waits; }
static char * save_resized_album_art(image_s *imsrc, const char *path) { int dstw, dsth; image_s *imdst; char *cache_file; char cache_dir[MAXPATHLEN]; if( !imsrc ) return NULL; if( art_cache_exists(path, &cache_file) ) return cache_file; strncpyt(cache_dir, cache_file, sizeof(cache_dir)); make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH); if( imsrc->width > imsrc->height ) { dstw = 160; dsth = (imsrc->height<<8) / ((imsrc->width<<8)/160); } else { dstw = (imsrc->width<<8) / ((imsrc->height<<8)/160); dsth = 160; } imdst = image_resize(imsrc, dstw, dsth); if( !imdst ) goto error; if( image_save_to_jpeg_file(imdst, cache_file) == 0 ) { image_free(imdst); return cache_file; } else image_free(imdst); error: free(cache_file); return NULL; }
int main(int argc, char** argv) { image_t img; image_new(&img); load_ppm("a.ppm", &img); image_median_filter(&img); save_ppm("b.ppm", &img); image_free(&img); return 0; }
void master_run(int world_size) { //Info to be read char image_src_name[IMAGE_NAME_LENGHT], image_dest_name[IMAGE_NAME_LENGHT]; int radius, type; double sigma; //Read info printf("Source image name: "); scanf("%s", image_src_name); printf("Destination image name: "); scanf("%s", image_dest_name); printf("Radius: "); scanf("%d", &radius); printf("Type: "); scanf("%d", &type); printf("Sigma: "); scanf("%lf", &sigma); //Load image from file printf("Loading image \"%s\"...\n", image_src_name); IMAGE *src = image_load(image_src_name); //Send metadata to the slaves printf("Sending metadata...\n"); master_send_metadata(src, type, radius, sigma, world_size-1); //Send pixels printf("Sending data to slaves...\n"); master_send_pixels(src, radius, world_size-1); //Recv image printf("Working...\n"); IMAGE *result = master_recv_blur(src, radius, world_size-1); //Write image to disk printf("Writing image to disk...\n"); image_write(result, image_dest_name); //Free memory image_free(src); image_free(result); //Master finished the work printf("DONE!\n"); }
int main_taiji (int argc, char *argv[]) { Image *image; image = image_new (800, 800); image_fill (image, 0xaa);//先将图片的数据区域填满背景色(灰色) draw_Taijitu (image, 300, 0);//填满背景色(灰色)后再在上面画太极图 value值是0(黑色) image_save (image, "taiji_6.pgm");//保存图片 image_free (image); return 0; }
void filter_smooth(struct image *img) { #define SSIZE 3 struct image *dst; int x, y, i, j, val; int r, g, b; dst = image_new(img->width, img->height); for(y = 0; y < img->height; y++) for(x = 0; x < img->width; x++) { getpixel(img, x, y, &r, &g, &b); setpixel(dst, x, y, r, g, b); } for(y = SSIZE/2; y < img->height - SSIZE/2; y++) for(x = SSIZE/2; x < img->width - SSIZE/2; x++) { val = 0; for(i = 0; i < SSIZE; i++) for(j = 0; j < SSIZE; j++) { getpixel(img, x + j - SSIZE/2, y + i - SSIZE/2, &r, &g, &b); val += r; } i = val / (SSIZE * SSIZE); setpixel(dst, x, y, i, i, i); } /* Remove border */ for(y = 0; y < dst->height; y++) { getpixel(dst, 1, y, &r, &g, &b); setpixel(dst, 0, y, r, g, b); getpixel(dst, dst->width - 2, y, &r, &g, &b); setpixel(dst, dst->width - 1, y, r, g, b); } for(x = 0; x < dst->width; x++) { getpixel(dst, x, 1, &r, &g, &b); setpixel(dst, x, 0, r, g, b); getpixel(dst, x, dst->height - 2, &r, &g, &b); setpixel(dst, x, dst->height - 1, r, g, b); } image_swap(img, dst); image_free(dst); }
void filter_fill_holes(struct image *img) { struct image *dst; int x, y; int r, g, b; dst = image_new(img->width, img->height); for(y = 0; y < img->height; y++) for(x = 0; x < img->width; x++) { getpixel(img, x, y, &r, &g, &b); setpixel(dst, x, y, r, g, b); } for(y = 0; y < dst->height; y++) for(x = 2; x < dst->width - 2; x++) { int c1, c2, c3, c4, c5; getpixel(img, x-2, y, &c1, &g, &b); getpixel(img, x-1, y, &c2, &g, &b); getpixel(img, x, y, &c3, &g, &b); getpixel(img, x+1, y, &c4, &g, &b); getpixel(img, x+2, y, &c5, &g, &b); if(c1 < 127 && c2 < 127 && c3 > 128 && c4 < 127) c3 = (c1 + c2 + c4) / 3; else if(c2 < 127 && c3 > 128 && c4 < 127 && c5 < 127) c3 = (c2 + c4 + c5) / 3; setpixel(dst, x, y, c3, c3, c3); } for(x = 0; x < dst->width; x++) for(y = 2; y < dst->height - 2; y++) { int c1, c2, c3, c4, c5; getpixel(img, x, y-2, &c1, &g, &b); getpixel(img, x, y-1, &c2, &g, &b); getpixel(img, x, y, &c3, &g, &b); getpixel(img, x, y+1, &c4, &g, &b); getpixel(img, x, y+2, &c5, &g, &b); if(c1 < 127 && c2 < 127 && c3 > 128 && c4 < 127) c3 = (c1 + c2 + c4) / 3; else if(c2 < 127 && c3 > 128 && c4 < 127 && c5 < 127) c3 = (c2 + c4 + c5) / 3; setpixel(dst, x, y, c3, c3, c3); } image_swap(img, dst); image_free(dst); }
int Sprite::getPixel(int x, int y, FrameNumber frame) const { int color = 0; if ((x >= 0) && (y >= 0) && (x < m_width) && (y < m_height)) { Image* image = Image::create(m_format, 1, 1); image_clear(image, (m_format == IMAGE_INDEXED ? getTransparentColor(): 0)); render(image, -x, -y, frame); color = image_getpixel(image, 0, 0); image_free(image); } return color; }
/** * This function populates given array of image_t structs with wanted number of padded pyramids based on given input. * @param[in] *input - input image (grayscale only) * @param[out] *output - array of image_t structs containing image pyiramid levels. Level zero contains original image, * followed by `pyr_level` of pyramid. * @param[in] pyr_level - number of pyramids to be built. If 0, original image is padded and outputed. * @param[in] border_size - amount of padding around image. Padding is made by reflecting image elements at the edge * Example: f e d c b a | a b c d e f | f e d c b a */ void pyramid_build(struct image_t *input, struct image_t *output_array, uint8_t pyr_level, uint8_t border_size) { // Pad input image and save it as '0' pyramid level image_add_border(input, &output_array[0], border_size); // Temporary holds 'i' level version of original image to be padded and saved as 'i' pyramid level struct image_t temp; for (uint8_t i = 1; i != pyr_level + 1; i++) { pyramid_next_level(&output_array[i - 1], &temp, border_size); image_add_border(&temp, &output_array[i], border_size); image_free(&temp); } }
static int decode(image& ctx, const std::vector<std::string>& inp_filenames, const std::string& fec_filename, std::string& out_filename) { const std::string& inp_filename = inp_filenames.front(); if (ctx.inplace && ctx.sparse) { FATAL("invalid parameters: inplace cannot be used with sparse " "files\n"); } if (!image_ecc_load(fec_filename, &ctx) || !image_load(inp_filenames, &ctx, !out_filename.empty())) { FATAL("failed to read input\n"); } if (ctx.inplace) { INFO("correcting '%s' using RS(255, %d) from '%s'\n", inp_filename.c_str(), ctx.rs_n, fec_filename.c_str()); out_filename = inp_filename; } else { INFO("decoding '%s' to '%s' using RS(255, %d) from '%s'\n", inp_filename.c_str(), out_filename.empty() ? out_filename.c_str() : "<none>", ctx.rs_n, fec_filename.c_str()); } if (ctx.verbose) { INFO("\traw fec size: %u\n", ctx.fec_size); INFO("\tblocks: %" PRIu64 "\n", ctx.blocks); INFO("\trounds: %" PRIu64 "\n", ctx.rounds); } if (!image_process(decode_rs, &ctx)) { FATAL("failed to process input\n"); } if (ctx.rv) { INFO("corrected %" PRIu64 " errors\n", ctx.rv); } else { INFO("no errors found\n"); } if (!out_filename.empty() && !image_save(out_filename, &ctx)) { FATAL("failed to write output\n"); } image_free(&ctx); return 0; }
void menu_background_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 7; x < w; x += 8) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE); } for(int y = 7; y < h; y += 8) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE); } image_rect(&img, 0, 0, w-1, h-1, COLOR_MENU_BORDER); texture_create_from_img(tex, &img); image_free(&img); }
game_status state_main_menu(SDL_Surface *screen, game* p_game) { bool done=false; image* main_title; main_title = image_load("./res/images/main_title.png"); SDL_Rect srcrect = {0,0,160,144}; SDL_Rect dstrect = set_rect(0,0,SCREEN_HEIGHT,SCREEN_WIDTH); int next_state=STAY; while (!done) { //events SDL_Event event; while (SDL_PollEvent(&event)) { switch ( event.type ) { case SDL_QUIT: done = true; break; default: break; } } image_draw(main_title, get_backbuffer_surface(), 0, 0); SDL_SoftStretch(get_backbuffer_surface(), &srcrect, screen, &dstrect); SDL_Flip(screen); if(next_state == STAY)next_state = menu_main(screen, p_game); else if(next_state!=QUIT){ switch(next_state){ case LOAD: menu_load(screen, &p_game); next_state = state_in_game(screen, p_game); break; case 1: p_game = game_load("./res/scripts/state.xml"); next_state = state_in_game(screen, p_game); break; default: break; } } else if(next_state==QUIT)done=true; } image_free(main_title); return QUIT; }
/** * Removes and destroys the specified image in the stock. */ void UndoTransaction::removeImageFromStock(int image_index) { ASSERT(image_index >= 0); Image* image = m_sprite->getStock()->getImage(image_index); ASSERT(image); if (isEnabled()) m_undoHistory->pushUndoer(new undoers::RemoveImage(m_undoHistory->getObjects(), m_sprite->getStock(), image_index)); m_sprite->getStock()->removeImage(image); image_free(image); }
// the *other* style menu background void menu_background2_create(texture *tex, int w, int h) { image img; image_create(&img, w, h); image_clear(&img, COLOR_MENU_BG); for(int x = 5; x < w; x += 5) { image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE2); } for(int y = 4; y < h; y += 5) { image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE2); } image_rect(&img, 1, 1, w-2, h-2, COLOR_MENU_BORDER2); image_rect(&img, 0, 0, w-2, h-2, COLOR_MENU_BORDER1); texture_create_from_img(tex, &img); image_free(&img); }