ImageResource::ImageResource(xml_node<>* node, ZipArchive* pZip) : Resource(node, pZip) { std::string file; mSurface = NULL; if (!node) return; if (node->first_attribute("filename")) file = node->first_attribute("filename")->value(); if (ExtractResource(pZip, "images", file, ".png", TMP_RESOURCE_NAME) == 0) { res_create_surface(TMP_RESOURCE_NAME, &mSurface); unlink(TMP_RESOURCE_NAME); } else if (ExtractResource(pZip, "images", file, "", TMP_RESOURCE_NAME) == 0) { // JPG includes the .jpg extension in the filename so extension should be blank res_create_surface(TMP_RESOURCE_NAME, &mSurface); unlink(TMP_RESOURCE_NAME); } else res_create_surface(file.c_str(), &mSurface); }
static void load_pngs(){ int i,ret; ret=res_create_surface(keyboard_file, &keyboards); if(DEBUG) printf("INFO: Create surface %s returned %d\n",keyboard_file, ret); ret=res_create_surface("checkmark", &checkmark); if(DEBUG) printf("INFO: Create surface 'checkmark' returned %d\n", ret); }
void ui_init(void) { gr_init(); ev_init(); text_col = text_row = 0; text_rows = gr_fb_height() / CHAR_HEIGHT; if (text_rows > MAX_ROWS) text_rows = MAX_ROWS; text_top = 1; text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1; int i; for (i = 0; BITMAPS[i].name != NULL; ++i) { int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface); if (result < 0) { if (result == -2) { LOGI("Bitmap %s missing header\n", BITMAPS[i].name); } else { LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result); } *BITMAPS[i].surface = NULL; } } pthread_t t; pthread_create(&t, NULL, progress_thread, NULL); pthread_create(&t, NULL, input_thread, NULL); }
static void ui_get_virtualkey_size() { if (virtualkey_h == 0) { int result = res_create_surface("virtual_keys", &gVirtualKeys); if (result == 0) { gr_surface surface = gVirtualKeys; virtualkey_h = gr_get_height(surface); virtualkey_w = gr_get_width(surface); LOGI("virtualkey size: %dx%d\n", virtualkey_w, virtualkey_h); } } }
AnimationResource::AnimationResource(xml_node<>* node, ZipArchive* pZip) : Resource(node, pZip) { std::string file; int fileNum = 1; if (!node) return; if (node->first_attribute("filename")) file = node->first_attribute("filename")->value(); for (;;) { std::ostringstream fileName; fileName << file << std::setfill ('0') << std::setw (3) << fileNum; gr_surface surface; if (pZip) { if (ExtractResource(pZip, "images", fileName.str(), ".png", TMP_RESOURCE_NAME) != 0) break; if (res_create_surface(TMP_RESOURCE_NAME, &surface)) break; unlink(TMP_RESOURCE_NAME); } else { if (res_create_surface(fileName.str().c_str(), &surface)) break; } mSurfaces.push_back(surface); fileNum++; } }
static void gr_init_font(void) { gr_font = calloc(sizeof(*gr_font), 1); int res = res_create_surface("font", (void**)&(gr_font->texture)); if (res == 0) { // The font image should be a 96x2 array of character images. The // columns are the printable ASCII characters 0x20 - 0x7f. The // top row is regular text; the bottom row is bold. gr_font->cwidth = gr_font->texture->width / 96; gr_font->cheight = gr_font->texture->height / 2; } else { printf("failed to read font: res=%d\n", res); // fall back to the compiled-in font. gr_font->texture = malloc(sizeof(*gr_font->texture)); gr_font->texture->width = font.width; gr_font->texture->height = font.height; gr_font->texture->stride = font.width; unsigned char* bits = malloc(font.width * font.height); gr_font->texture->data = (void*) bits; unsigned char data; unsigned char* in = font.rundata; while((data = *in++)) { memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); bits += (data & 0x7f); } gr_font->cwidth = font.cwidth; gr_font->cheight = font.cheight; } // interpret the grayscale as alpha gr_font->texture->format = GGL_PIXEL_FORMAT_A_8; }
void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { int result = res_create_surface(filename, surface); if (result < 0) { LOGE("missing bitmap %s\n(Code %d)\n", filename, result); } }
void ui_init(void) { ui_has_initialized = 1; gr_init(); ev_init(input_callback, NULL); #ifdef BOARD_TOUCH_RECOVERY touch_init(); #endif text_col = text_row = 0; text_rows = gr_fb_height() / CHAR_HEIGHT; max_menu_rows = text_rows - MIN_LOG_ROWS; #ifdef BOARD_TOUCH_RECOVERY max_menu_rows = get_max_menu_rows(max_menu_rows); #endif if (max_menu_rows > MENU_MAX_ROWS) max_menu_rows = MENU_MAX_ROWS; if (text_rows > MAX_ROWS) text_rows = MAX_ROWS; text_top = 1; text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1; int i; for (i = 0; BITMAPS[i].name != NULL; ++i) { int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result); } } gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.indeterminate_frames; ++i) { char filename[40]; // "indeterminate01.png", "indeterminate02.png", ... sprintf(filename, "indeterminate%02d", i+1); int result = res_create_surface(filename, gProgressBarIndeterminate+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } if (ui_parameters.installing_frames > 0) { gInstallationOverlay = malloc(ui_parameters.installing_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.installing_frames; ++i) { char filename[40]; // "icon_installing_overlay01.png", // "icon_installing_overlay02.png", ... sprintf(filename, "icon_installing_overlay%02d", i+1); int result = res_create_surface(filename, gInstallationOverlay+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } // Adjust the offset to account for the positioning of the // base image on the screen. if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) { gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING]; ui_parameters.install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2; ui_parameters.install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2; } } else { gInstallationOverlay = NULL; } char enable_key_repeat[PROPERTY_VALUE_MAX]; property_get("ro.cwm.enable_key_repeat", enable_key_repeat, ""); if (!strcmp(enable_key_repeat, "true") || !strcmp(enable_key_repeat, "1")) { boardEnableKeyRepeat = 1; char key_list[PROPERTY_VALUE_MAX]; property_get("ro.cwm.repeatable_keys", key_list, ""); if (strlen(key_list) == 0) { boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_UP; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_DOWN; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEUP; boardRepeatableKeys[boardNumRepeatableKeys++] = KEY_VOLUMEDOWN; } else { char *pch = strtok(key_list, ","); while (pch != NULL) { boardRepeatableKeys[boardNumRepeatableKeys++] = atoi(pch); pch = strtok(NULL, ","); } } } pthread_t t; pthread_create(&t, NULL, progress_thread, NULL); pthread_create(&t, NULL, input_thread, NULL); }
void ui_init(void) { ui_has_initialized = 1; gr_init(); ev_init(input_callback, NULL); text_col = text_row = 0; text_rows = gr_fb_height() / CHAR_HEIGHT; max_menu_rows = text_rows - MIN_LOG_ROWS; if (max_menu_rows > MENU_MAX_ROWS) max_menu_rows = MENU_MAX_ROWS; if (text_rows > MAX_ROWS) text_rows = MAX_ROWS; text_top = 1; text_cols = gr_fb_width() / CHAR_WIDTH; if (text_cols > MAX_COLS - 1) text_cols = MAX_COLS - 1; int i; for (i = 0; BITMAPS[i].name != NULL; ++i) { int result = res_create_surface(BITMAPS[i].name, BITMAPS[i].surface); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", BITMAPS[i].name, result); } } gProgressBarIndeterminate = malloc(ui_parameters.indeterminate_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.indeterminate_frames; ++i) { char filename[40]; // "indeterminate01.png", "indeterminate02.png", ... sprintf(filename, "indeterminate%02d", i+1); int result = res_create_surface(filename, gProgressBarIndeterminate+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } if (ui_parameters.installing_frames > 0) { gInstallationOverlay = malloc(ui_parameters.installing_frames * sizeof(gr_surface)); for (i = 0; i < ui_parameters.installing_frames; ++i) { char filename[40]; // "icon_installing_overlay01.png", // "icon_installing_overlay02.png", ... sprintf(filename, "icon_installing_overlay%02d", i+1); int result = res_create_surface(filename, gInstallationOverlay+i); if (result < 0) { LOGE("Missing bitmap %s\n(Code %d)\n", filename, result); } } // Adjust the offset to account for the positioning of the // base image on the screen. if (gBackgroundIcon[BACKGROUND_ICON_INSTALLING] != NULL) { gr_surface bg = gBackgroundIcon[BACKGROUND_ICON_INSTALLING]; ui_parameters.install_overlay_offset_x += (gr_fb_width() - gr_get_width(bg)) / 2; ui_parameters.install_overlay_offset_y += (gr_fb_height() - gr_get_height(bg)) / 2; } } else { gInstallationOverlay = NULL; } pthread_t t; pthread_create(&t, NULL, progress_thread, NULL); pthread_create(&t, NULL, input_thread, NULL); }