Created
June 15, 2011 06:25
-
-
Save anonymous/1026589 to your computer and use it in GitHub Desktop.
Example of different image object behavior in evas 1.0.1 vs. 1.0.0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Evas.h> | |
#include <Evas_Engine_FB.h> | |
#define SCREEN_WIDTH 320 | |
#define SCREEN_HEIGHT 240 | |
#define ICON_FILENAME "gear.png" | |
int main(int argc, char **argv) | |
{ | |
evas_init(); | |
int renderMethod = evas_render_method_lookup("fb"); | |
if (! renderMethod) | |
{ | |
printf("Failed to lookup render method\n"); | |
return -1; | |
} | |
Evas *evas = evas_new(); | |
if (! evas) | |
{ | |
printf("Failed to create evas\n"); | |
return -2; | |
} | |
evas_output_method_set(evas, renderMethod); | |
Evas_Engine_Info_FB *engineInfo = (Evas_Engine_Info_FB *) evas_engine_info_get(evas); | |
engineInfo->info.device_number = 0; | |
evas_engine_info_set(evas, (Evas_Engine_Info *) engineInfo); | |
evas_output_size_set(evas, SCREEN_WIDTH, SCREEN_HEIGHT); | |
evas_output_viewport_set(evas, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); | |
// White background. | |
Evas_Object *bg = evas_object_rectangle_add(evas); | |
evas_object_move(bg, 0, 0); | |
evas_object_resize(bg, SCREEN_WIDTH, SCREEN_HEIGHT); | |
evas_object_color_set(bg, 255, 255, 255, 255); | |
evas_object_show(bg); | |
// Icon | |
Evas_Object *icon = evas_object_image_add(evas); | |
evas_object_image_file_set(icon, ICON_FILENAME, NULL); | |
int iconWidth, iconHeight; | |
evas_object_image_size_get(icon, &iconWidth, &iconHeight); | |
evas_object_image_fill_set(icon, 0, 0, iconWidth, iconHeight); | |
evas_object_move(icon, (SCREEN_WIDTH - iconWidth) / 2, (SCREEN_HEIGHT - iconHeight) / 2); | |
// evas 1.0.0 displays only the right half of the image. | |
// evas 1.0.1 displays the entire image. | |
// Which is the correct behavior when the tile/fill size is larger than the image object's width? | |
evas_object_resize(icon, iconWidth / 2, iconHeight); | |
evas_object_show(icon); | |
evas_render(evas); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment