IMAGELIB_ERROR_CODE imagelib_get_frame_data_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect, INT32 _dest_width,INT32 _dest_height, IMAGELIB_EFFECT_PARA _effect_para, DISP_BITMAP** _bitmap_rt) { IMAGE_INSTANCE *decoder_instance,*encoder_instance=NULL; if(_session == NULL || _session->instance_p == NULL) { return IMAGELIB_RAM_EXECPTION; } decoder_instance = _session->instance_p; _session->error_code= image_open_dev_by_imagedata("rab",NULL, 0,&encoder_instance); if(_session->error_code != IMAGELIB_SUCCESS || encoder_instance==NULL) return _session->error_code; _session->state = IMAGELIB_DECODING; _session->error_code = imagelib_main_impl(_session,decoder_instance,encoder_instance,_src_rect,_dest_width,_dest_height,_effect_para); _session->state = IMAGELIB_IDLE; if(_session->error_code != IMAGELIB_SUCCESS) { image_close(encoder_instance,TRUE); *_bitmap_rt = NULL; } else { image_close(encoder_instance,FALSE); *_bitmap_rt = (DISP_BITMAP*)image_get_result(encoder_instance); } return _session->error_code; }
IMAGELIB_ERROR_CODE imagelib_end_decode(IMAGELIB_SESSION*_session) { IMAGELIB_ERROR_CODE error_code= IMAGELIB_SUCCESS; if(_session == NULL) return IMAGELIB_RAM_EXECPTION; if(_session->state != IMAGELIB_DECODING) { error_code = image_close((IMAGE_INSTANCE*)_session->instance_p,TRUE); _session->instance_p = NULL; if(_session->pathname) IMAGE_FREE(_session->pathname); if(_session->decode_sem != NULL) { kill_sem(_session->decode_sem); _session->decode_sem = NULL; } IMAGE_FREE(_session); } else _session->state = IMAGELIB_CLOSED; return error_code; }
static int loadDriver(struct ecosflash_flash_bank *info) { size_t buf_cnt; size_t image_size; struct image image; image.base_address_set = 0; image.start_address_set = 0; struct target *target = info->target; int retval; if ((retval = image_open(&image, info->driverPath, NULL)) != ERROR_OK) { return retval; } info->start_address = image.start_address; image_size = 0x0; int i; for (i = 0; i < image.num_sections; i++) { void *buffer = malloc(image.sections[i].size); if ((retval = image_read_section(&image, i, 0x0, image.sections[i].size, buffer, &buf_cnt)) != ERROR_OK) { free(buffer); image_close(&image); return retval; } target_write_buffer(target, image.sections[i].base_address, buf_cnt, buffer); image_size += buf_cnt; LOG_DEBUG("%zu bytes written at address 0x%8.8" PRIx32 "", buf_cnt, image.sections[i].base_address); free(buffer); } image_close(&image); return ERROR_OK; }
image& image::set_clamped( bl clamped ) { image_open(); this->clamped = clamped; s32 clamping_parameters = get_clamping_params( this->clamped ); glTexParameteri( TEXTURE_2D, TEXTURE_WRAP_S, clamping_parameters ); glTexParameteri( TEXTURE_2D, TEXTURE_WRAP_T, clamping_parameters ); image_close(); RETHIS; }
image& image::set_mipmapped( bl mipmapped ) { image_open(); this->mipmapped = mipmapped; s32 filter_parameters = get_filter_params( filtered, this->mipmapped ); glTexParameteri( TEXTURE_2D, TEXTURE_MIN_FILTER, filter_parameters ); glTexParameteri( TEXTURE_2D, TEXTURE_MAG_FILTER, filter_parameters ); image_close(); RETHIS; }
int main(int argc, const char *argv[]) { int retval = 1; size_t sizes[] = {0, 0, 0, 0}; image_t *im = 0; char *filename = 0; if(argc < 3 || argc >6) { usage(argv); retval = 1; goto end; } sizes[0] = parse_size(argv[2]); if(argc > 3) sizes[1] = parse_size(argv[3]); if(argc > 4) sizes[2] = parse_size(argv[4]); if(argc > 5) sizes[3] = parse_size(argv[5]); filename = strdup(argv[1]); if(!(im = image_new(filename, sizes, 0))) { fprintf(stderr, "%s: Failed to create disk image\n", argv[0]); retval = 1; goto end; } printf(" Image file created with CHS: %d %d %d\n", im->cylinders, im->heads, im->sectors); end: if(im) image_close(im); if(filename) free(filename); return retval; }
IMAGELIB_ERROR_CODE imagelib_draw_frame_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect, INT32 _dest_width,INT32 _dest_height,IMAGELIB_EFFECT_PARA _effect_para, IMAGELIB_DRAW_PARA _draw_para) { IMAGE_INSTANCE *decoder_instance,*encoder_instance=NULL; if(_session == NULL || _session->instance_p == NULL) { return IMAGELIB_RAM_EXECPTION; } decoder_instance = _session->instance_p; _session->error_code = image_open_by_filename(DEFAULT_LCD_BITMAP_FILE, "wb",&_draw_para,&encoder_instance); if(_session->error_code != IMAGELIB_SUCCESS || encoder_instance==NULL) return _session->error_code; _session->state = IMAGELIB_DECODING; _session->error_code = imagelib_main_impl(_session,decoder_instance,encoder_instance,_src_rect,_dest_width,_dest_height,_effect_para); image_close(encoder_instance,TRUE); _session->state = IMAGELIB_IDLE; return _session->error_code; }
IMAGELIB_ERROR_CODE imagelib_save_frame_to_file_sync(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect, const WCHAR* _dest_pathname,INT32 _dest_width,INT32 _dest_height, IMAGELIB_EFFECT_PARA _effect_para ) { IMAGE_INSTANCE *decoder_instance,*encoder_instance=NULL; char utf_pathname[UTA_MAX_PATHNAME_LEN*2+1]; if(_session == NULL || _session->instance_p == NULL) { return IMAGELIB_RAM_EXECPTION; } decoder_instance = _session->instance_p; UnicodeToUtf8(utf_pathname,_dest_pathname); _session->error_code=image_open_by_filename(utf_pathname, "wb",NULL,&encoder_instance); if(_session->error_code != IMAGELIB_SUCCESS || encoder_instance==NULL) return _session->error_code; _session->state = IMAGELIB_DECODING; _session->error_code = imagelib_main_impl(_session,decoder_instance,encoder_instance,_src_rect,_dest_width,_dest_height,_effect_para); _session->state = IMAGELIB_IDLE; image_close(encoder_instance,TRUE); return _session->error_code; }
/*------------------------------------------------------------*/ void eps_finish_output (void) { int byte_count = output_width * components; int row, pos, slot; GLenum format; unsigned char *buffer; char *pix; format = (components == 1) ? GL_LUMINANCE : GL_RGB; image_render(); buffer = malloc (byte_count * sizeof (unsigned char)); for (row = 0; row < output_height; row++) { glReadPixels (0, row, output_width, 1, format, GL_UNSIGNED_BYTE, buffer); pos = 0; pix = (char *) buffer; for (slot = 0; slot < byte_count; slot++) { fprintf (outfile, "%02hx", *pix++); if (++pos >= 32) { fprintf (outfile, "\n"); pos = 0; } } if (pos) fprintf (outfile, "\n"); } free (buffer); PRINT ("%%EndData\n"); PRINT ("grestore\n"); PRINT ("end\n"); image_close(); }
UINT32 imagelib_thread_main(IMAGELIB_MSG_PARA_LIST* msg) { IMAGELIB_MSG_PARA_LIST* para_list = (IMAGELIB_MSG_PARA_LIST*)msg; IMAGELIB_SESSION* session = NULL; if(para_list == NULL || para_list->session==NULL) return 0; session = para_list->session; wait_sem(session->decode_sem); if(para_list->msg_id == IMAGELIB_SAVEFRAMEDATA_MSG ||para_list->msg_id == IMAGELIB_DRAWFRAMEDATA_MSG ) { session->error_code = imagelib_main_impl(session,para_list->src_instance,para_list->dest_instance,para_list->src_rect, para_list->dest_width,para_list->dest_height,para_list->effect_para); if (para_list->dest_instance != NULL) { image_close(para_list->dest_instance,TRUE); } if( session->state == IMAGELIB_DECODING) { session->state = IMAGELIB_IDLE; imagelib_dispose_frame_ending(para_list->ending_cb,session,NULL,para_list->session->error_code); } } else if(para_list->msg_id == IMAGELIB_GETFRAMEDATA_MSG) { DISP_BITMAP* bitmap=NULL; session->error_code =imagelib_main_impl(session,para_list->src_instance,para_list->dest_instance,para_list->src_rect, para_list->dest_width,para_list->dest_height,para_list->effect_para); if (para_list->dest_instance != NULL) { if(session->error_code != IMAGELIB_SUCCESS) { image_close(para_list->dest_instance,TRUE); bitmap = NULL; } else { bitmap =(DISP_BITMAP*)image_get_result(para_list->dest_instance); image_close(para_list->dest_instance,FALSE); } } if( session->state == IMAGELIB_DECODING) { para_list->session->state = IMAGELIB_IDLE; imagelib_dispose_frame_ending(para_list->ending_cb,session,bitmap,para_list->session->error_code); } } if(para_list->session->state == IMAGELIB_CLOSED) { if(session->pathname) IMAGE_FREE(session->pathname); image_close((IMAGE_INSTANCE*)session->instance_p,TRUE); session->instance_p = NULL; if(para_list->session->decode_sem != NULL) { signal_sem(para_list->session->decode_sem); kill_sem(para_list->session->decode_sem); para_list->session->decode_sem = NULL; } IMAGE_FREE(para_list->session); } else signal_sem(session->decode_sem); IMAGE_FREE(para_list); return 0; }
static int load_usb_blaster_firmware(struct jtag_libusb_device_handle *libusb_dev, struct ublast_lowlevel *low) { struct image ublast2_firmware_image; if (!low->firmware_path) { LOG_ERROR("No firmware path specified"); return ERROR_FAIL; } ublast2_firmware_image.base_address = 0; ublast2_firmware_image.base_address_set = 0; int ret = image_open(&ublast2_firmware_image, low->firmware_path, "ihex"); if (ret != ERROR_OK) { LOG_ERROR("Could not load firmware image"); return ret; } /** A host loader program must write 0x01 to the CPUCS register * to put the CPU into RESET, load all or part of the EZUSB * RAM with firmware, then reload the CPUCS register * with ‘0’ to take the CPU out of RESET. The CPUCS register * (at 0xE600) is the only EZ-USB register that can be written * using the Firmware Download command. */ char value = CPU_RESET; jtag_libusb_control_transfer(libusb_dev, LIBUSB_REQUEST_TYPE_VENDOR | \ LIBUSB_ENDPOINT_OUT, USBBLASTER_CTRL_LOAD_FIRM, EZUSB_CPUCS, 0, &value, 1, 100); /* Download all sections in the image to ULINK */ for (int i = 0; i < ublast2_firmware_image.num_sections; i++) { ret = ublast2_write_firmware_section(libusb_dev, &ublast2_firmware_image, i); if (ret != ERROR_OK) { LOG_ERROR("Error while downloading the firmware"); return ret; } } value = !CPU_RESET; jtag_libusb_control_transfer(libusb_dev, LIBUSB_REQUEST_TYPE_VENDOR | \ LIBUSB_ENDPOINT_OUT, USBBLASTER_CTRL_LOAD_FIRM, EZUSB_CPUCS, 0, &value, 1, 100); image_close(&ublast2_firmware_image); return ERROR_OK; }
void visual_tracer_close(void) { if (host.tw != NULL) { image_delete(host.tw); image_close(host.tw); } }
int optimus_burn_with_cfg_file(const char* cfgFile) { extern ConfigPara_t g_sdcBurnPara ; int ret = 0; HIMAGE hImg = NULL; ConfigPara_t* pSdcCfgPara = &g_sdcBurnPara; const char* pkgPath = pSdcCfgPara->burnEx.pkgPath; __hdle hUiProgress = NULL; ret = parse_ini_cfg_file(cfgFile); if (ret) { DWN_ERR("Fail to parse file %s\n", cfgFile); ret = __LINE__; goto _finish; } if (pSdcCfgPara->custom.eraseBootloader && strcmp("1", getenv("usb_update"))) { if (is_bootloader_old()) { DWN_MSG("To erase OLD bootloader !\n"); ret = optimus_erase_bootloader("sdc"); if (ret) { DWN_ERR("Fail to erase bootloader\n"); ret = __LINE__; goto _finish; } #if defined(CONFIG_VIDEO_AMLLCD) //axp to low power off LCD, no-charging DWN_MSG("To close LCD\n"); ret = run_command("video dev disable", 0); if (ret) { printf("Fail to close back light\n"); /*return __LINE__;*/ } #endif// #if defined(CONFIG_VIDEO_AMLLCD) DWN_MSG("Reset to load NEW uboot from ext-mmc!\n"); optimus_reset(OPTIMUS_BURN_COMPLETE__REBOOT_SDC_BURN); return __LINE__;//should never reach here!! } } if (OPTIMUS_WORK_MODE_SDC_PRODUCE == optimus_work_mode_get()) //led not depend on image res, can init early { if (optimus_led_open(LED_TYPE_PWM)) { DWN_ERR("Fail to open led for sdc_produce\n"); return __LINE__; } optimus_led_show_in_process_of_burning(); } hImg = image_open("mmc", "0", "1", pkgPath); if (!hImg) { DWN_ERR("Fail to open image %s\n", pkgPath); ret = __LINE__; goto _finish; } //update dtb for burning drivers ret = optimus_sdc_burn_dtb_load(hImg); if (ITEM_NOT_EXIST != ret && ret) { DWN_ERR("Fail in load dtb for sdc_burn\n"); ret = __LINE__; goto _finish; } if (video_res_prepare_for_upgrade(hImg)) { DWN_ERR("Fail when prepare bm res or init video for upgrade\n"); image_close(hImg); return __LINE__; } show_logo_to_report_burning(); hUiProgress = optimus_progress_ui_request_for_sdc_burn(); if (!hUiProgress) { DWN_ERR("request progress handle failed!\n"); ret = __LINE__; goto _finish; } optimus_progress_ui_direct_update_progress(hUiProgress, UPGRADE_STEPS_AFTER_IMAGE_OPEN_OK); int hasBootloader = 0; u64 datapartsSz = optimus_img_decoder_get_data_parts_size(hImg, &hasBootloader); int eraseFlag = pSdcCfgPara->custom.eraseFlash; if (!datapartsSz) { eraseFlag = 0; DWN_MSG("Disable erase as data parts size is 0\n"); } ret = optimus_storage_init(eraseFlag); if (ret) { DWN_ERR("Fail to init stoarge for sdc burn\n"); return __LINE__; } optimus_progress_ui_direct_update_progress(hUiProgress, UPGRADE_STEPS_AFTER_DISK_INIT_OK); if (datapartsSz) { ret = optimus_progress_ui_set_smart_mode(hUiProgress, datapartsSz, UPGRADE_STEPS_FOR_BURN_DATA_PARTS_IN_PKG(!pSdcCfgPara->burnEx.bitsMap.mediaPath)); if (ret) { DWN_ERR("Fail to set smart mode\n"); ret = __LINE__; goto _finish; } ret = optimus_sdc_burn_partitions(pSdcCfgPara, hImg, hUiProgress, 1); if (ret) { DWN_ERR("Fail when burn partitions\n"); ret = __LINE__; goto _finish; } } if (pSdcCfgPara->burnEx.bitsMap.mediaPath) //burn media image { const char* mediaPath = pSdcCfgPara->burnEx.mediaPath; ret = optimus_sdc_burn_media_partition(mediaPath, NULL);//no progress bar info if have partition image not in package if (ret) { DWN_ERR("Fail to burn media partition with image %s\n", mediaPath); optimus_storage_exit(); ret = __LINE__;goto _finish; } } optimus_progress_ui_direct_update_progress(hUiProgress, UPGRADE_STPES_AFTER_BURN_DATA_PARTS_OK); //TO burn nandkey/securekey/efusekey ret = sdc_burn_aml_keys(hImg, pSdcCfgPara->custom.keyOverwrite); if (ret) { DWN_ERR("Fail in sdc_burn_aml_keys\n"); ret = __LINE__;goto _finish; } #if 1 if (hasBootloader) {//burn bootloader ret = optimus_burn_bootlader(hImg); if (ret) { DWN_ERR("Fail in burn bootloader\n"); goto _finish; } else {//update bootloader ENV only when bootloader image is burned ret = optimus_set_burn_complete_flag(); if (ret) { DWN_ERR("Fail in set_burn_complete_flag\n"); ret = __LINE__; goto _finish; } } } #endif optimus_progress_ui_direct_update_progress(hUiProgress, UPGRADE_STEPS_AFTER_BURN_BOOTLOADER_OK); _finish: image_close(hImg); optimus_progress_ui_report_upgrade_stat(hUiProgress, !ret); optimus_report_burn_complete_sta(ret, pSdcCfgPara->custom.rebootAfterBurn); optimus_progress_ui_release(hUiProgress); //optimus_storage_exit();//temporary not exit storage driver when failed as may continue burning after burn return ret; }
/*------------------------------------------------------------*/ void gifi_finish_output (void) { int row, col, value, r, g, b, error, right, leftbelow, below; unsigned char *buffer, *buf; int *rcurr, *gcurr, *bcurr, *rnext, *gnext, *bnext, *swap; image_render(); buffer = malloc (output_width * 3 * sizeof (unsigned char)); rcurr = malloc ((output_width + 1) * sizeof (int)); gcurr = malloc ((output_width + 1) * sizeof (int)); bcurr = malloc ((output_width + 1) * sizeof (int)); rnext = calloc (output_width + 1, sizeof (int)); gnext = calloc (output_width + 1, sizeof (int)); bnext = calloc (output_width + 1, sizeof (int)); for (row = 0; row < output_height; row++) { swap = rnext; rnext = rcurr; rcurr = swap; swap = gnext; gnext = gcurr; gcurr = swap; swap = bnext; bnext = bcurr; bcurr = swap; for (col = 0; col < output_width; col++) { rnext[col] = 0; gnext[col] = 0; bnext[col] = 0; } glReadPixels (0, output_height - row - 1, output_width, 1, GL_RGB, GL_UNSIGNED_BYTE, buffer); buf = buffer; for (col = 0; col < output_width; col++) { rcurr[col] += *buf++; gcurr[col] += *buf++; bcurr[col] += *buf++; } for (col = 0; col < output_width; col++) { /* error diffusion */ value = rcurr[col]; for (r = 0; 51 * (r + 1) - 26 < value; r++); error = value - r * 51; right = (7 * error) / 16; leftbelow = (3 * error) / 16; below = (5 * error) / 16; rcurr[col+1] += right; if (col > 0) rnext[col-1] += leftbelow; rnext[col] += below; rnext[col+1] = error - right - leftbelow - below; value = gcurr[col]; for (g = 0; 51 * (g + 1) - 26 < value; g++); error = value - g * 51; right = (7 * error) / 16; leftbelow = (3 * error) / 16; below = (5 * error) / 16; gcurr[col+1] += right; if (col > 0) gnext[col-1] += leftbelow; gnext[col] += below; gnext[col+1] = error - right - leftbelow - below; value = bcurr[col]; for (b = 0; 51 * (b + 1) - 26 < value; b++); error = value - b * 51; right = (7 * error) / 16; leftbelow = (3 * error) / 16; below = (5 * error) / 16; bcurr[col+1] += right; if (col > 0) bnext[col-1] += leftbelow; bnext[col] += below; bnext[col+1] = error - right - leftbelow - below; gdImageSetPixel (image, col, row, ((r * 6) + g) * 6 + b); } } free (rnext); free (gnext); free (bnext); free (rcurr); free (gcurr); free (bcurr); free (buffer); gdImageGif (image, outfile); gdImageDestroy (image); image_close(); }
int main(int argc, char *argv[]) { byte keypress; client_init(); if( argc > 1 ) /* Command line arguments */ handle_cl_args(argc, argv); srand( time(NULL) ); calc_lookup_tables(DEGREES); win_init(); entity_init(); if( (ent_img_loaded = (char *)malloc(num_entity_types)) == NULL ) { perror("Malloc"); ERR_QUIT("Error allocating ent_img_loaded array", 1); } else { memset(ent_img_loaded, 0, num_entity_types); } /* Load client preferences from file */ read_config_file( &client ); /* Set view dimensions, which are calculated by tile width & heights */ client.view_w = client.x_tiles * TILE_W; client.view_h = client.y_tiles * TILE_H; /* What the client WISHES their dimensions were (this may not be what it actually is, ie in demo's etc */ client.desired_w = client.view_w; client.desired_h = client.view_h; weapon_type_init(); particle_init(); menu_init(); cl_network_init(); client.state = MENU; if( client.demo == DEMO_PLAY ) { cl_network_connect(NULL, 42); client.state = GAME_LOAD; } for( ; ; ) { switch( client.state ) { case MENU: win_ungrab_pointer(); menu_driver(); break; case GAME_LOAD: win_set_properties(VERSION, client.view_w, client.view_h+STATUS_H); wait_till_expose(5); /* Finished loading, we are ready to play */ cl_change_map(client.map, client.gamemode); break; case GAME_RESUME: /* Resume game from menu */ win_set_properties(VERSION, client.view_w, client.view_h+STATUS_H); wait_till_expose(5); input_clear(); draw_status_bar(); cl_netmsg_send_ready(); /* Tell server new details */ cl_net_finish(); /* Send the NETMSG_READY to the server */ client.state = GAME_JOIN; break; case GAME_JOIN: win_set_cursor( client.mousemode!=MOUSEMODE_ROTATE ); win_set_cursor( 1 ); if( client.mousemode ) { win_grab_pointer(); } text_buf_clear(); particle_clear(); case GAME_PLAY: cl_net_update(); if( client.state == GAME_PLAY ) { /* Maybe changed in net_update */ draw_crosshair( my_entity ); if( client.map_target_active ) draw_map_target( my_entity ); text_buf_update(); if( client.netstats ) cl_net_stats(); win_update(); /* Keyboard Input */ client.dir = my_entity.dir; keypress = get_input(); cl_netmsg_send_cl_update(keypress, client.dir); } cl_net_finish(); /* Send things that need sending */ cap_fps(client.fps); break; case QUIT: game_close(); image_close(); /* Free all the images */ win_close(); write_config_file(&client); if( ent_img_loaded != NULL ) free(ent_img_loaded); exit(EXIT_SUCCESS); break; } } return EXIT_SUCCESS; }