Changes in uspace/app/viewer/viewer.c [a35b458:5a6cc679] in mainline
- File:
-
- 1 edited
-
uspace/app/viewer/viewer.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/viewer/viewer.c
ra35b458 r5a6cc679 44 44 #include <codec/tga.h> 45 45 #include <task.h> 46 #include <str.h>47 46 48 47 #define NAME "viewer" … … 72 71 kbd_event_t *event = (kbd_event_t *) data; 73 72 bool update = false; 74 73 75 74 if ((event->type == KEY_PRESS) && (event->c == 'q')) 76 75 exit(0); 77 76 78 77 if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_DOWN)) { 79 78 if (imgs_current == imgs_count - 1) … … 81 80 else 82 81 imgs_current++; 83 82 84 83 update = true; 85 84 } 86 85 87 86 if ((event->type == KEY_PRESS) && (event->key == KC_PAGE_UP)) { 88 87 if (imgs_current == 0) … … 90 89 else 91 90 imgs_current--; 92 91 93 92 update = true; 94 93 } 95 94 96 95 if (update) { 97 96 surface_t *lsface; … … 114 113 if (rc != EOK) 115 114 return false; 116 117 vfs_stat_t stat;115 116 struct stat stat; 118 117 rc = vfs_stat(fd, &stat); 119 118 if (rc != EOK) { … … 121 120 return false; 122 121 } 123 122 124 123 void *tga = malloc(stat.size); 125 124 if (tga == NULL) { … … 135 134 return false; 136 135 } 137 136 138 137 vfs_put(fd); 139 138 140 139 *p_local_surface = decode_tga(tga, stat.size, 0); 141 140 if (*p_local_surface == NULL) { … … 143 142 return false; 144 143 } 145 144 146 145 free(tga); 147 146 148 147 surface_get_resolution(*p_local_surface, &img_width, &img_height); 149 148 150 149 return true; 151 150 } … … 165 164 return false; 166 165 } 167 166 168 167 sig_connect(&canvas->keyboard_event, NULL, on_keyboard_event); 169 168 } 170 169 171 170 if (surface != NULL) 172 171 surface_destroy(surface); 173 172 174 173 surface = local_surface; 175 174 return true; … … 188 187 return 1; 189 188 } 190 189 191 190 if (argc < 3) { 192 191 printf("No image files specified.\n"); … … 200 199 return 2; 201 200 } 202 201 203 202 for (int i = 0; i < argc - 2; i++) { 204 203 imgs[i] = str_dup(argv[i + 2]); … … 226 225 return 5; 227 226 } 228 229 227 228 230 229 if (!img_setup(lsface)) { 231 230 printf("Cannot setup image \"%s\".\n", imgs[imgs_current]); … … 244 243 img_height + dheight, WINDOW_PLACEMENT_ANY); 245 244 window_exec(main_window); 246 245 247 246 task_retval(0); 248 247 async_manager(); 249 248 250 249 return 0; 251 250 }
Note:
See TracChangeset
for help on using the changeset viewer.
