| 1 | #include "camera.h" |
|---|
| 2 | #include "stdlib.h" |
|---|
| 3 | #include "keyboard.h" |
|---|
| 4 | #include "platform.h" |
|---|
| 5 | #include "histogram.h" |
|---|
| 6 | #include "core.h" |
|---|
| 7 | #include "lang.h" |
|---|
| 8 | #include "conf.h" |
|---|
| 9 | #include "gui.h" |
|---|
| 10 | #include "gui_draw.h" |
|---|
| 11 | #include "gui_lang.h" |
|---|
| 12 | #include "gui_batt.h" |
|---|
| 13 | #include "gui_space.h" |
|---|
| 14 | #include "gui_grid.h" |
|---|
| 15 | #include "gui_osd.h" |
|---|
| 16 | |
|---|
| 17 | //------------------------------------------------------------------- |
|---|
| 18 | typedef struct { |
|---|
| 19 | int title; |
|---|
| 20 | OSD_pos *pos; |
|---|
| 21 | OSD_pos size; |
|---|
| 22 | } OSD_elem; |
|---|
| 23 | |
|---|
| 24 | static OSD_elem osd[]={ |
|---|
| 25 | {LANG_OSD_LAYOUT_EDITOR_HISTO, &conf.histo_pos, {HISTO_WIDTH+2, HISTO_HEIGHT} }, |
|---|
| 26 | {LANG_OSD_LAYOUT_EDITOR_DOF_CALC, &conf.dof_pos, {23*FONT_WIDTH, 2*FONT_HEIGHT} }, |
|---|
| 27 | {LANG_OSD_LAYOUT_EDITOR_STATES, &conf.mode_state_pos, {12*FONT_WIDTH, 4*FONT_HEIGHT} }, |
|---|
| 28 | {LANG_OSD_LAYOUT_EDITOR_RAW, &conf.mode_raw_pos, {7*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 29 | {LANG_OSD_LAYOUT_EDITOR_MISC, &conf.values_pos, {9*FONT_WIDTH, 9*FONT_HEIGHT} }, |
|---|
| 30 | {LANG_OSD_LAYOUT_EDITOR_BAT_ICON, &conf.batt_icon_pos, {28, 12} }, |
|---|
| 31 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_icon_pos, {23, 15} }, |
|---|
| 32 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_ver_pos, {3, 50} }, |
|---|
| 33 | {LANG_OSD_LAYOUT_EDITOR_SPACE_ICON, &conf.space_hor_pos, {50, 3} }, |
|---|
| 34 | {LANG_OSD_LAYOUT_EDITOR_BAT_TEXT, &conf.batt_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 35 | {LANG_OSD_LAYOUT_EDITOR_SPACE_TEXT, &conf.space_txt_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 36 | {LANG_OSD_LAYOUT_EDITOR_CLOCK, &conf.clock_pos, {5*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 37 | {LANG_OSD_LAYOUT_EDITOR_TEMP, &conf.temp_pos, {9*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 38 | {LANG_OSD_LAYOUT_EDITOR_VIDEO, &conf.mode_video_pos, {9*FONT_WIDTH, 4*FONT_HEIGHT} }, |
|---|
| 39 | {LANG_OSD_LAYOUT_EDITOR_EV, &conf.mode_ev_pos, {12*FONT_WIDTH, FONT_HEIGHT} }, |
|---|
| 40 | #if CAM_EV_IN_VIDEO |
|---|
| 41 | {LANG_OSD_LAYOUT_EDITOR_EV_VIDEO, &conf.ev_video_pos, {70,24}}, |
|---|
| 42 | #endif |
|---|
| 43 | {0} |
|---|
| 44 | }; |
|---|
| 45 | static int osd_to_draw; |
|---|
| 46 | static int curr_item; |
|---|
| 47 | static char osd_buf[64]; |
|---|
| 48 | static char osd_buf2[10]; |
|---|
| 49 | static char osd_buf3[10]; |
|---|
| 50 | static char osd_buf4[10]; |
|---|
| 51 | |
|---|
| 52 | static int step; |
|---|
| 53 | |
|---|
| 54 | // Width (in pixels) of half-shoot Canon OSD area of the screen buffer, for restore during |
|---|
| 55 | // Zebra draw, to limit RAM usage of zebra. Only these border areas are stored in RAM. |
|---|
| 56 | // Only top and bottom are restored, not left&right. |
|---|
| 57 | #define ZEBRA_CANONOSD_BORDER_RESTORE 1 |
|---|
| 58 | |
|---|
| 59 | #if defined (CAMERA_sx200is) || defined(CAMERA_g11) || defined (CAMERA_ixus100_sd780) |
|---|
| 60 | //there are no memory for that (the screen buffer is big): 960x270 |
|---|
| 61 | //TODO use a buffer of screen dimensions |
|---|
| 62 | #define ZFIX_TOP 1 |
|---|
| 63 | #define ZFIX_BOTTOM 1 |
|---|
| 64 | #else |
|---|
| 65 | #define ZFIX_TOP 29 |
|---|
| 66 | #define ZFIX_BOTTOM 30 |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | static unsigned char *img_buf, *scr_buf; |
|---|
| 70 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 71 | static unsigned char *cur_buf_top, *cur_buf_bot; |
|---|
| 72 | #else |
|---|
| 73 | static unsigned char *cur_buf; |
|---|
| 74 | #endif |
|---|
| 75 | static int cur_buf_size; |
|---|
| 76 | static int timer = 0; |
|---|
| 77 | static unsigned char *buf = NULL; |
|---|
| 78 | #if defined (CAMERA_sx200is) || defined(CAMERA_g11) || defined (CAMERA_ixus100_sd780) |
|---|
| 79 | static int buffer_size; |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | static DOF_TYPE dof; |
|---|
| 83 | static EXPO_TYPE expo; |
|---|
| 84 | |
|---|
| 85 | #define OSD_STATE 0 |
|---|
| 86 | #define OSD_MISC 1 |
|---|
| 87 | |
|---|
| 88 | unsigned char clip8(signed short x){ if (x<0) x=0; else if (x>255) x=255; return x; } |
|---|
| 89 | |
|---|
| 90 | //------------------------------------------------------------------- |
|---|
| 91 | void gui_osd_init() { |
|---|
| 92 | osd_to_draw = 1; |
|---|
| 93 | curr_item = 0; |
|---|
| 94 | step = 10; |
|---|
| 95 | draw_restore(); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | //------------------------------------------------------------------- |
|---|
| 99 | void gui_osd_draw() { |
|---|
| 100 | if (osd_to_draw) { |
|---|
| 101 | int i; |
|---|
| 102 | draw_restore(); |
|---|
| 103 | gui_osd_draw_histo(); |
|---|
| 104 | gui_osd_draw_dof(); |
|---|
| 105 | gui_batt_draw_osd(); |
|---|
| 106 | gui_space_draw_osd(); |
|---|
| 107 | gui_osd_draw_state(); |
|---|
| 108 | gui_osd_draw_raw_info(); |
|---|
| 109 | gui_osd_draw_values(); |
|---|
| 110 | gui_osd_draw_clock(0,0,0); |
|---|
| 111 | gui_osd_draw_temp(); |
|---|
| 112 | #if CAM_EV_IN_VIDEO |
|---|
| 113 | gui_osd_draw_ev_video(1); |
|---|
| 114 | #endif |
|---|
| 115 | for (i=1; i<=2; ++i) { |
|---|
| 116 | draw_rect((osd[curr_item].pos->x>=i)?osd[curr_item].pos->x-i:0, (osd[curr_item].pos->y>=i)?osd[curr_item].pos->y-i:0, |
|---|
| 117 | osd[curr_item].pos->x+osd[curr_item].size.x+i-1, osd[curr_item].pos->y+osd[curr_item].size.y+i-1, |
|---|
| 118 | COLOR_GREEN); |
|---|
| 119 | } |
|---|
| 120 | sprintf(osd_buf, " %s: x:%d y:%d s:%d ", lang_str(osd[curr_item].title), osd[curr_item].pos->x, osd[curr_item].pos->y, step); |
|---|
| 121 | draw_string(0, (osd[curr_item].pos->x<strlen(osd_buf)*FONT_WIDTH+4 && osd[curr_item].pos->y<FONT_HEIGHT+4)?screen_height-FONT_HEIGHT:0, |
|---|
| 122 | osd_buf, MAKE_COLOR(COLOR_RED, COLOR_WHITE)); |
|---|
| 123 | osd_to_draw = 0; |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | //------------------------------------------------------------------- |
|---|
| 128 | void gui_osd_kbd_process() { |
|---|
| 129 | switch (kbd_get_autoclicked_key()) { |
|---|
| 130 | case KEY_LEFT: |
|---|
| 131 | if (osd[curr_item].pos->x > 0) { |
|---|
| 132 | osd[curr_item].pos->x-=(osd[curr_item].pos->x>=step)?step:osd[curr_item].pos->x; |
|---|
| 133 | osd_to_draw = 1; |
|---|
| 134 | } |
|---|
| 135 | break; |
|---|
| 136 | case KEY_RIGHT: |
|---|
| 137 | if (osd[curr_item].pos->x < screen_width-osd[curr_item].size.x) { |
|---|
| 138 | osd[curr_item].pos->x+=(screen_width-osd[curr_item].size.x-osd[curr_item].pos->x>step)?step:screen_width-osd[curr_item].size.x-osd[curr_item].pos->x; |
|---|
| 139 | osd_to_draw = 1; |
|---|
| 140 | } else |
|---|
| 141 | osd[curr_item].pos->x = screen_width-osd[curr_item].size.x; |
|---|
| 142 | break; |
|---|
| 143 | case KEY_UP: |
|---|
| 144 | if (osd[curr_item].pos->y > 0) { |
|---|
| 145 | osd[curr_item].pos->y-=(osd[curr_item].pos->y>=step)?step:osd[curr_item].pos->y; |
|---|
| 146 | osd_to_draw = 1; |
|---|
| 147 | } |
|---|
| 148 | break; |
|---|
| 149 | case KEY_DOWN: |
|---|
| 150 | if (osd[curr_item].pos->y < screen_height-osd[curr_item].size.y) { |
|---|
| 151 | osd[curr_item].pos->y+=(screen_height-osd[curr_item].size.y-osd[curr_item].pos->y>step)?step:screen_height-osd[curr_item].size.y-osd[curr_item].pos->y; |
|---|
| 152 | osd_to_draw = 1; |
|---|
| 153 | } else |
|---|
| 154 | osd[curr_item].pos->y = screen_height-osd[curr_item].size.y; |
|---|
| 155 | break; |
|---|
| 156 | case KEY_SET: |
|---|
| 157 | ++curr_item; |
|---|
| 158 | if (!osd[curr_item].pos) |
|---|
| 159 | curr_item = 0; |
|---|
| 160 | osd_to_draw = 1; |
|---|
| 161 | break; |
|---|
| 162 | case KEY_DISPLAY: |
|---|
| 163 | step=(step==1)?10:1; |
|---|
| 164 | osd_to_draw = 1; |
|---|
| 165 | break; |
|---|
| 166 | } |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | //------------------------------------------------------------------- |
|---|
| 170 | static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small) { |
|---|
| 171 | register unsigned int i, v, threshold; |
|---|
| 172 | register color cl, cl_over, cl_bg=conf.histo_color>>8; |
|---|
| 173 | coord w=HISTO_WIDTH, h=HISTO_HEIGHT; |
|---|
| 174 | |
|---|
| 175 | switch (hist) { |
|---|
| 176 | case HISTO_R: |
|---|
| 177 | cl=((mode_get()&MODE_MASK) == MODE_REC)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY; |
|---|
| 178 | break; |
|---|
| 179 | case HISTO_G: |
|---|
| 180 | cl=((mode_get()&MODE_MASK) == MODE_REC)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY; |
|---|
| 181 | break; |
|---|
| 182 | case HISTO_B: |
|---|
| 183 | cl=((mode_get()&MODE_MASK) == MODE_REC)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY; |
|---|
| 184 | break; |
|---|
| 185 | case HISTO_RGB: |
|---|
| 186 | case HISTO_Y: |
|---|
| 187 | default: |
|---|
| 188 | cl=conf.histo_color; |
|---|
| 189 | break; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | if (small) { |
|---|
| 193 | h>>=1; w>>=1; |
|---|
| 194 | for (i=0; i<w; ++i) { |
|---|
| 195 | threshold = (histogram[hist][i<<1]+histogram[hist][(i<<1)+1])>>2; |
|---|
| 196 | |
|---|
| 197 | for (v=1; v<h-1; ++v) |
|---|
| 198 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); |
|---|
| 199 | cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; |
|---|
| 200 | for (; v<h; ++v) |
|---|
| 201 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); |
|---|
| 202 | } |
|---|
| 203 | } else { |
|---|
| 204 | for (i=0; i<w; ++i) { |
|---|
| 205 | threshold = histogram[hist][i]; |
|---|
| 206 | |
|---|
| 207 | for (v=1; v<h-3; ++v) |
|---|
| 208 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg); |
|---|
| 209 | cl_over = (threshold==h && conf.show_overexp)?conf.histo_color2>>8:cl; |
|---|
| 210 | for (; v<h; ++v) |
|---|
| 211 | draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg); |
|---|
| 212 | } |
|---|
| 213 | } |
|---|
| 214 | |
|---|
| 215 | draw_rect(x, y, x+1+w, y+h, conf.histo_color2&0xFF); |
|---|
| 216 | //Vertical Lines |
|---|
| 217 | if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+w)*i/5, y, x+(1+w)*i/5, y+h, conf.histo_color2&0xFF); |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | //------------------------------------------------------------------- |
|---|
| 221 | // free and NULL zebra buffers. free(NULL) is always OK. |
|---|
| 222 | static void gui_osd_zebra_free() { |
|---|
| 223 | free(buf); |
|---|
| 224 | buf=NULL; |
|---|
| 225 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 226 | free(cur_buf_top); |
|---|
| 227 | cur_buf_top=NULL; |
|---|
| 228 | free(cur_buf_bot); |
|---|
| 229 | cur_buf_bot=NULL; |
|---|
| 230 | #else |
|---|
| 231 | free(cur_buf); |
|---|
| 232 | cur_buf=NULL; |
|---|
| 233 | #endif |
|---|
| 234 | } |
|---|
| 235 | // prepare zebra resources, or free them |
|---|
| 236 | // returns 1 if zebra should be drawn |
|---|
| 237 | static int gui_osd_zebra_init(int show) { |
|---|
| 238 | unsigned i; |
|---|
| 239 | |
|---|
| 240 | if(show) { |
|---|
| 241 | if (!buf) { |
|---|
| 242 | timer = 0; |
|---|
| 243 | #if defined (CAMERA_sx200is) || defined (CAMERA_g11) || defined (CAMERA_ixus100_sd780) //nandoide sept-2009 |
|---|
| 244 | buffer_size=screen_buffer_size-ZEBRA_HMARGIN0*screen_buffer_width; |
|---|
| 245 | buf = malloc(buffer_size); |
|---|
| 246 | //~ if (!buf) draw_txt_string(0, 14, "Warn: No space to allocate zebra buffer: restart camera", MAKE_COLOR(COLOR_ALT_BG, COLOR_FG)); |
|---|
| 247 | if (!buf) buf=vid_get_bitmap_fb(); //without new buffer: directly into screen buffer: we got some flickering in OSD and histogram but it's usable |
|---|
| 248 | //~ msleep(50); |
|---|
| 249 | #else |
|---|
| 250 | buf = malloc(screen_buffer_size); |
|---|
| 251 | #endif |
|---|
| 252 | |
|---|
| 253 | scr_buf = vid_get_bitmap_fb(); |
|---|
| 254 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 255 | cur_buf_top = malloc(screen_buffer_width * ZFIX_TOP); |
|---|
| 256 | cur_buf_bot = malloc(screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 257 | #if defined (CAMERA_g11) |
|---|
| 258 | if (cur_buf_top) memset(cur_buf_top,0,screen_buffer_width * ZFIX_TOP); |
|---|
| 259 | if (cur_buf_bot) memset(cur_buf_bot,0,screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 260 | #endif |
|---|
| 261 | #else |
|---|
| 262 | cur_buf = malloc(screen_buffer_size); |
|---|
| 263 | #endif |
|---|
| 264 | // cleanup and disable zebra if any mallocs failed |
|---|
| 265 | if(!buf || |
|---|
| 266 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 267 | !cur_buf_top || |
|---|
| 268 | !cur_buf_bot |
|---|
| 269 | #else |
|---|
| 270 | !cur_buf |
|---|
| 271 | #endif |
|---|
| 272 | ) { |
|---|
| 273 | gui_osd_zebra_free(); |
|---|
| 274 | } |
|---|
| 275 | #if CAM_HAS_VARIABLE_ASPECT |
|---|
| 276 | else // in variable aspect, the borders would never be cleared |
|---|
| 277 | memset(buf,0,screen_buffer_size); |
|---|
| 278 | #endif |
|---|
| 279 | } |
|---|
| 280 | } |
|---|
| 281 | else { |
|---|
| 282 | if(buf) // if zebra was previously on, restore |
|---|
| 283 | draw_restore(); |
|---|
| 284 | |
|---|
| 285 | gui_osd_zebra_free(); |
|---|
| 286 | } |
|---|
| 287 | return (buf != NULL); |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | //------------------------------------------------------------------- |
|---|
| 291 | static void draw_pixel_buffered(unsigned int offset, color cl) { |
|---|
| 292 | #if defined (CAMERA_sx200is) |
|---|
| 293 | if (offset < buffer_size) |
|---|
| 294 | buf[offset] = cl; |
|---|
| 295 | #else |
|---|
| 296 | buf[offset] = cl; |
|---|
| 297 | #endif |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | //------------------------------------------------------------------- |
|---|
| 301 | int draw_guard_pixel() { |
|---|
| 302 | unsigned char* buffer1 = vid_get_bitmap_fb()+screen_buffer_size/2; |
|---|
| 303 | unsigned char* buffer2 = buffer1+screen_buffer_size; |
|---|
| 304 | int has_disappeared=0; |
|---|
| 305 | |
|---|
| 306 | if(*buffer1!=COLOR_GREEN) has_disappeared=1; |
|---|
| 307 | if(*buffer2!=COLOR_GREEN) has_disappeared=2; |
|---|
| 308 | *buffer1 = *buffer2 = COLOR_GREEN; |
|---|
| 309 | return has_disappeared; |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | //------------------------------------------------------------------- |
|---|
| 313 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 314 | unsigned char get_cur_buf(unsigned int idx) { |
|---|
| 315 | unsigned int a; |
|---|
| 316 | |
|---|
| 317 | a=screen_buffer_size - screen_buffer_width * ZFIX_BOTTOM; |
|---|
| 318 | |
|---|
| 319 | if (idx < screen_buffer_width * ZFIX_TOP) return(cur_buf_top[idx]); |
|---|
| 320 | if (idx >= a && idx < screen_buffer_size) return(cur_buf_bot[idx - a]); |
|---|
| 321 | return (COLOR_TRANSPARENT); |
|---|
| 322 | } |
|---|
| 323 | #endif |
|---|
| 324 | //------------------------------------------------------------------- |
|---|
| 325 | static void gui_osd_draw_zebra_osd() { |
|---|
| 326 | switch (conf.zebra_draw_osd) { |
|---|
| 327 | case ZEBRA_DRAW_NONE: |
|---|
| 328 | break; |
|---|
| 329 | case ZEBRA_DRAW_OSD: |
|---|
| 330 | if (conf.show_osd) { |
|---|
| 331 | draw_set_draw_proc(draw_pixel_buffered); |
|---|
| 332 | if ((mode_get()&MODE_MASK) == MODE_REC) { |
|---|
| 333 | if (conf.show_dof != DOF_DONT_SHOW) gui_osd_calc_dof(); |
|---|
| 334 | if (conf.show_grid_lines) { |
|---|
| 335 | gui_grid_draw_osd(1); |
|---|
| 336 | } |
|---|
| 337 | if (conf.show_dof == DOF_SHOW_IN_DOF) { |
|---|
| 338 | gui_osd_draw_dof(); |
|---|
| 339 | } |
|---|
| 340 | if (conf.show_state) { |
|---|
| 341 | gui_osd_draw_state(); |
|---|
| 342 | } |
|---|
| 343 | if (conf.show_remaining_raw) { |
|---|
| 344 | gui_osd_draw_raw_info(); |
|---|
| 345 | } |
|---|
| 346 | if (conf.show_values) { |
|---|
| 347 | gui_osd_draw_values(); |
|---|
| 348 | } |
|---|
| 349 | } |
|---|
| 350 | gui_batt_draw_osd(); |
|---|
| 351 | gui_space_draw_osd(); |
|---|
| 352 | if (conf.show_clock) { |
|---|
| 353 | gui_osd_draw_clock(0,0,0); |
|---|
| 354 | } |
|---|
| 355 | if (conf.show_temp>0) { |
|---|
| 356 | gui_osd_draw_temp(); |
|---|
| 357 | } |
|---|
| 358 | draw_set_draw_proc(NULL); |
|---|
| 359 | } |
|---|
| 360 | /* no break here */ |
|---|
| 361 | case ZEBRA_DRAW_HISTO: |
|---|
| 362 | default: |
|---|
| 363 | if (conf.show_histo) { |
|---|
| 364 | draw_set_draw_proc(draw_pixel_buffered); |
|---|
| 365 | gui_osd_draw_histo(); |
|---|
| 366 | draw_set_draw_proc(NULL); |
|---|
| 367 | } |
|---|
| 368 | break; |
|---|
| 369 | } |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | // reyalp - TODO this SHOULD NOT BE CAMERA SPECIFIC. Should be generalized to work with all cameras |
|---|
| 373 | // having a copy/paste/modified version for individual cameras will be a maintenance nightmare. |
|---|
| 374 | #if defined (CAMERA_sx200is) || defined (CAMERA_g11) || defined (CAMERA_ixus100_sd780) |
|---|
| 375 | //nandoide sept-2009 |
|---|
| 376 | // viewport is 360x240 and screen buffer 960x270, we need to expand the x coordinate |
|---|
| 377 | int gui_osd_draw_zebra(int show) { |
|---|
| 378 | unsigned int v, s, x, y, f, over; |
|---|
| 379 | color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; |
|---|
| 380 | static int need_restore=0; |
|---|
| 381 | int viewport_height; |
|---|
| 382 | int viewport_width; |
|---|
| 383 | int mrec = ((mode_get()&MODE_MASK) == MODE_REC); |
|---|
| 384 | int zebra_drawn=0; |
|---|
| 385 | color cls[] = { |
|---|
| 386 | COLOR_TRANSPARENT, |
|---|
| 387 | (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, |
|---|
| 388 | (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, |
|---|
| 389 | (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, |
|---|
| 390 | (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, |
|---|
| 391 | (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, |
|---|
| 392 | (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, |
|---|
| 393 | COLOR_BLACK |
|---|
| 394 | }; |
|---|
| 395 | |
|---|
| 396 | if (!gui_osd_zebra_init(show)) |
|---|
| 397 | return 0; |
|---|
| 398 | |
|---|
| 399 | if(timer==0) { |
|---|
| 400 | draw_guard_pixel(); |
|---|
| 401 | timer=1; |
|---|
| 402 | return 0; |
|---|
| 403 | } |
|---|
| 404 | if(timer==1) { |
|---|
| 405 | int ready; |
|---|
| 406 | static int n=0; |
|---|
| 407 | if (!mrec) ready=1; |
|---|
| 408 | else get_property_case(PROPCASE_SHOOTING, &ready, 4); |
|---|
| 409 | n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. |
|---|
| 410 | if(!ready) return 0; |
|---|
| 411 | } |
|---|
| 412 | ++timer; |
|---|
| 413 | // Try to get the best viewport buffer. In playmode its the _d one, in |
|---|
| 414 | // record mode we try to get the fast live one first |
|---|
| 415 | if (!mrec) { |
|---|
| 416 | img_buf = vid_get_viewport_fb_d(); |
|---|
| 417 | } |
|---|
| 418 | else { |
|---|
| 419 | img_buf = vid_get_viewport_live_fb(); |
|---|
| 420 | if( !img_buf ) { |
|---|
| 421 | img_buf = vid_get_viewport_fb(); |
|---|
| 422 | } |
|---|
| 423 | } |
|---|
| 424 | viewport_height = vid_get_viewport_height(); |
|---|
| 425 | viewport_width = vid_get_viewport_width(); |
|---|
| 426 | switch (conf.zebra_mode) { |
|---|
| 427 | case ZEBRA_MODE_ZEBRA_1: |
|---|
| 428 | f = 4; |
|---|
| 429 | break; |
|---|
| 430 | case ZEBRA_MODE_ZEBRA_2: |
|---|
| 431 | f = 8; |
|---|
| 432 | break; |
|---|
| 433 | case ZEBRA_MODE_SOLID: |
|---|
| 434 | f = 1; |
|---|
| 435 | break; |
|---|
| 436 | case ZEBRA_MODE_BLINKED_1: |
|---|
| 437 | f = timer&1; |
|---|
| 438 | break; |
|---|
| 439 | case ZEBRA_MODE_BLINKED_3: |
|---|
| 440 | f = timer&4; |
|---|
| 441 | break; |
|---|
| 442 | case ZEBRA_MODE_BLINKED_2: |
|---|
| 443 | default: |
|---|
| 444 | f = timer&2; |
|---|
| 445 | break; |
|---|
| 446 | } |
|---|
| 447 | // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] |
|---|
| 448 | if (f) { |
|---|
| 449 | int step_x, step_v, sy, sx; |
|---|
| 450 | over = 255-conf.zebra_over; |
|---|
| 451 | if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} |
|---|
| 452 | for (y=0, v=0; y<viewport_height; ++y) { |
|---|
| 453 | sy=y*screen_buffer_width; |
|---|
| 454 | sx=0; |
|---|
| 455 | for (x=0; x<viewport_width; x+=step_x, sx+=step_x, v+=step_v) { |
|---|
| 456 | register int yy, uu, vv; |
|---|
| 457 | int sel; |
|---|
| 458 | yy = img_buf[v+1]; |
|---|
| 459 | s=sy+sx*2; |
|---|
| 460 | if (conf.zebra_multichannel) { |
|---|
| 461 | uu = (signed char)img_buf[v]; |
|---|
| 462 | vv = (signed char)img_buf[v+2]; |
|---|
| 463 | sel=0; |
|---|
| 464 | if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { |
|---|
| 465 | if (clip8(((yy<<12) + vv*5743 + 2048)>>12)>over) sel = 4; // R |
|---|
| 466 | if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G |
|---|
| 467 | if (clip8(((yy<<12) + uu*7258 + 2048)>>12)>over) sel |= 1; // B |
|---|
| 468 | } |
|---|
| 469 | buf[s]=buf[s+1]=cls[sel]; |
|---|
| 470 | buf[s+2]=buf[s+3]=cls[sel]; |
|---|
| 471 | } |
|---|
| 472 | else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=buf[s+1]=COLOR_TRANSPARENT; |
|---|
| 473 | else buf[s]=buf[s+1]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; |
|---|
| 474 | if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; |
|---|
| 475 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 476 | if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s); |
|---|
| 477 | if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1); |
|---|
| 478 | #else |
|---|
| 479 | if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; |
|---|
| 480 | if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; |
|---|
| 481 | #endif |
|---|
| 482 | |
|---|
| 483 | if (mrec) { |
|---|
| 484 | } |
|---|
| 485 | } |
|---|
| 486 | } |
|---|
| 487 | if (!zebra_drawn) f=0; |
|---|
| 488 | } |
|---|
| 489 | // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on |
|---|
| 490 | if (!f) { |
|---|
| 491 | // if zebra was drawn during previous call of this function |
|---|
| 492 | if (need_restore) { |
|---|
| 493 | if (conf.zebra_restore_screen || conf.zebra_restore_osd) { |
|---|
| 494 | draw_restore(); |
|---|
| 495 | } else { // clear buf[] of zebra, only leave Canon OSD |
|---|
| 496 | if (mrec) { // REC mode |
|---|
| 497 | //~ #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 498 | //~ // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: |
|---|
| 499 | //~ memcpy(buf, cur_buf_top, screen_buffer_width * ZFIX_TOP); |
|---|
| 500 | //~ memcpy(buf + screen_buffer_size - screen_buffer_width * ZFIX_BOTTOM, cur_buf_bot, screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 501 | //~ for (s = screen_buffer_width*ZFIX_TOP; s < screen_buffer_size-screen_buffer_width*ZFIX_BOTTOM; s++) { |
|---|
| 502 | //~ buf[s]=COLOR_TRANSPARENT; |
|---|
| 503 | //~ } |
|---|
| 504 | //~ #else |
|---|
| 505 | //~ // copy from a complete Canon OSD rescue screen dump |
|---|
| 506 | //~ memcpy(buf, cur_buf, screen_buffer_size); |
|---|
| 507 | //~ #endif |
|---|
| 508 | } else { // Not REC mode |
|---|
| 509 | // No Canon OSD restore, fill buf[] with transparent color: |
|---|
| 510 | memset(buf, COLOR_TRANSPARENT, buffer_size); |
|---|
| 511 | } |
|---|
| 512 | // draw CHDK osd and histogram to buf[] (if enabled in config) |
|---|
| 513 | gui_osd_draw_zebra_osd(); |
|---|
| 514 | // copy buf[] to both display buffers |
|---|
| 515 | |
|---|
| 516 | if (buf!=scr_buf) |
|---|
| 517 | memcpy(scr_buf, buf, buffer_size); |
|---|
| 518 | memcpy(scr_buf+screen_buffer_size, buf, buffer_size); |
|---|
| 519 | } |
|---|
| 520 | need_restore=0; |
|---|
| 521 | } |
|---|
| 522 | return !(conf.zebra_restore_screen && conf.zebra_restore_osd); |
|---|
| 523 | // if zebra was drawn |
|---|
| 524 | } else { |
|---|
| 525 | // draw CHDK osd and histogram to buf[] over zebra (if enabled in config) |
|---|
| 526 | gui_osd_draw_zebra_osd(); |
|---|
| 527 | // copy buf[] to both display buffers |
|---|
| 528 | if (buf!=scr_buf) |
|---|
| 529 | memcpy(scr_buf, buf, buffer_size); |
|---|
| 530 | memcpy(scr_buf+screen_buffer_size, buf, buffer_size); |
|---|
| 531 | |
|---|
| 532 | need_restore=1; |
|---|
| 533 | return 1; |
|---|
| 534 | } |
|---|
| 535 | return 0; |
|---|
| 536 | } |
|---|
| 537 | #else |
|---|
| 538 | //------------------------------------------------------------------- |
|---|
| 539 | int gui_osd_draw_zebra(int show) { |
|---|
| 540 | unsigned int v, s, x, y, f, over; |
|---|
| 541 | color cl_under=conf.zebra_color>>8, cl_over=conf.zebra_color&0xFF; |
|---|
| 542 | static int need_restore=0; |
|---|
| 543 | int viewport_height; |
|---|
| 544 | int mrec = ((mode_get()&MODE_MASK) == MODE_REC); |
|---|
| 545 | int zebra_drawn=0; |
|---|
| 546 | color cls[] = { |
|---|
| 547 | COLOR_TRANSPARENT, |
|---|
| 548 | (mrec)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, |
|---|
| 549 | (mrec)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, |
|---|
| 550 | (mrec)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, |
|---|
| 551 | (mrec)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, |
|---|
| 552 | (mrec)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, |
|---|
| 553 | (mrec)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, |
|---|
| 554 | COLOR_BLACK |
|---|
| 555 | }; |
|---|
| 556 | |
|---|
| 557 | unsigned bWide = 1; // if wide (16:9) or standard (4:3) aspect ratio (but 1 in cameras that only have 4:3) |
|---|
| 558 | unsigned aspOffset = 0; // offset to add to x-coord (or buffer address) when drawing zebra |
|---|
| 559 | |
|---|
| 560 | #if CAM_HAS_VARIABLE_ASPECT |
|---|
| 561 | if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 0) // standard requires x-shift to overlay drawing |
|---|
| 562 | { |
|---|
| 563 | bWide = 0; |
|---|
| 564 | //aspOffset = (screen_width - (screen_width * 12 / 16)) / 2; // = actual calculation, simplified below |
|---|
| 565 | aspOffset = screen_width / 8; // half of the difference in width between equal height 16:9 and 4:3 screens, = black bar width |
|---|
| 566 | } |
|---|
| 567 | #endif |
|---|
| 568 | |
|---|
| 569 | if (!gui_osd_zebra_init(show)) |
|---|
| 570 | return 0; |
|---|
| 571 | |
|---|
| 572 | if(timer==0) { |
|---|
| 573 | draw_guard_pixel(); |
|---|
| 574 | timer=1; |
|---|
| 575 | return 0; |
|---|
| 576 | } |
|---|
| 577 | if(timer==1) { |
|---|
| 578 | int ready; |
|---|
| 579 | static int n=0; |
|---|
| 580 | if (!mrec) ready=1; |
|---|
| 581 | else get_property_case(PROPCASE_SHOOTING, &ready, 4); |
|---|
| 582 | n=draw_guard_pixel(); // will be 0 in PLAY mode, should be 1 or 2 in REC mode. |
|---|
| 583 | if(!ready) return 0; |
|---|
| 584 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 585 | // rescue Canon OSD from scr_buf to cur_buf_top and _bot: |
|---|
| 586 | if (n==1) { |
|---|
| 587 | memcpy(cur_buf_top, scr_buf, screen_buffer_width*ZFIX_TOP); |
|---|
| 588 | memcpy(cur_buf_bot, scr_buf + screen_buffer_size - screen_buffer_width*ZFIX_BOTTOM, screen_buffer_width*ZFIX_BOTTOM); |
|---|
| 589 | } |
|---|
| 590 | else { |
|---|
| 591 | memcpy(cur_buf_top, scr_buf + screen_buffer_size, screen_buffer_width*ZFIX_TOP); |
|---|
| 592 | memcpy(cur_buf_bot, scr_buf + 2*screen_buffer_size - screen_buffer_width*ZFIX_BOTTOM, screen_buffer_width*ZFIX_BOTTOM); |
|---|
| 593 | } |
|---|
| 594 | #else |
|---|
| 595 | // rescue Canon OSD from cur_buf |
|---|
| 596 | if(n==1) memcpy(cur_buf, scr_buf, screen_buffer_size); |
|---|
| 597 | else memcpy(cur_buf, scr_buf+screen_buffer_size, screen_buffer_size); |
|---|
| 598 | #endif |
|---|
| 599 | } |
|---|
| 600 | ++timer; |
|---|
| 601 | // Try to get the best viewport buffer. In playmode its the _d one, in |
|---|
| 602 | // record mode we try to get the fast live one first |
|---|
| 603 | if (!mrec) { |
|---|
| 604 | img_buf = vid_get_viewport_fb_d(); |
|---|
| 605 | } |
|---|
| 606 | else { |
|---|
| 607 | img_buf = vid_get_viewport_live_fb(); |
|---|
| 608 | if( !img_buf ) { |
|---|
| 609 | img_buf = vid_get_viewport_fb(); |
|---|
| 610 | } |
|---|
| 611 | } |
|---|
| 612 | viewport_height = vid_get_viewport_height(); |
|---|
| 613 | switch (conf.zebra_mode) { |
|---|
| 614 | case ZEBRA_MODE_ZEBRA_1: |
|---|
| 615 | f = 4; |
|---|
| 616 | break; |
|---|
| 617 | case ZEBRA_MODE_ZEBRA_2: |
|---|
| 618 | f = 8; |
|---|
| 619 | break; |
|---|
| 620 | case ZEBRA_MODE_SOLID: |
|---|
| 621 | f = 1; |
|---|
| 622 | break; |
|---|
| 623 | case ZEBRA_MODE_BLINKED_1: |
|---|
| 624 | f = timer&1; |
|---|
| 625 | break; |
|---|
| 626 | case ZEBRA_MODE_BLINKED_3: |
|---|
| 627 | f = timer&4; |
|---|
| 628 | break; |
|---|
| 629 | case ZEBRA_MODE_BLINKED_2: |
|---|
| 630 | default: |
|---|
| 631 | f = timer&2; |
|---|
| 632 | break; |
|---|
| 633 | } |
|---|
| 634 | // if not in no-zebra phase of blink mode zebra, draw zebra to buf[] |
|---|
| 635 | if (f) { |
|---|
| 636 | int step_x, step_v; |
|---|
| 637 | over = 255-conf.zebra_over; |
|---|
| 638 | if (conf.zebra_multichannel) {step_x=2; step_v=6;} else {step_x=1; step_v=3;} |
|---|
| 639 | s = aspOffset; |
|---|
| 640 | for (y=1, v=0; y<=viewport_height; ++y) { |
|---|
| 641 | for (x=0; x<screen_width; x+=step_x, s+=step_x, v+=step_v) { |
|---|
| 642 | register int yy, uu, vv; |
|---|
| 643 | int sel; |
|---|
| 644 | |
|---|
| 645 | if (!bWide && (x + aspOffset >= screen_width - aspOffset)) continue; // do not draw "outside screen" |
|---|
| 646 | |
|---|
| 647 | yy = img_buf[v+1]; |
|---|
| 648 | if (conf.zebra_multichannel) { |
|---|
| 649 | uu = (signed char)img_buf[v]; |
|---|
| 650 | vv = (signed char)img_buf[v+2]; |
|---|
| 651 | sel=0; |
|---|
| 652 | if (!((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) { |
|---|
| 653 | if (clip8(((yy<<12) + vv*5743 + 2048)>>12)>over) sel = 4; // R |
|---|
| 654 | if (clip8(((yy<<12) - uu*1411 - vv*2925 + 2048)>>12)>over) sel |= 2; // G |
|---|
| 655 | if (clip8(((yy<<12) + uu*7258 + 2048)>>12)>over) sel |= 1; // B |
|---|
| 656 | } |
|---|
| 657 | buf[s]=buf[s+1]=cls[sel]; |
|---|
| 658 | } |
|---|
| 659 | else if (((conf.zebra_mode == ZEBRA_MODE_ZEBRA_1 || conf.zebra_mode == ZEBRA_MODE_ZEBRA_2) && (y-x-timer)&f)) buf[s]=COLOR_TRANSPARENT; |
|---|
| 660 | else buf[s]=(yy>over)?cl_over:(yy<conf.zebra_under)?cl_under:COLOR_TRANSPARENT; |
|---|
| 661 | if (buf[s] != COLOR_TRANSPARENT && !zebra_drawn) zebra_drawn = 1; |
|---|
| 662 | if (mrec) { |
|---|
| 663 | // draw Canon OSD to buf[] if in REC mode |
|---|
| 664 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 665 | if(get_cur_buf(s)!=COLOR_TRANSPARENT) buf[s]=get_cur_buf(s); |
|---|
| 666 | if(conf.zebra_multichannel && get_cur_buf(s+1)!=COLOR_TRANSPARENT) buf[s+1]=get_cur_buf(s+1); |
|---|
| 667 | #else |
|---|
| 668 | if(cur_buf[s]!=COLOR_TRANSPARENT) buf[s]=cur_buf[s]; |
|---|
| 669 | if(conf.zebra_multichannel && cur_buf[s+1]!=COLOR_TRANSPARENT) buf[s+1]=cur_buf[s+1]; |
|---|
| 670 | #endif |
|---|
| 671 | } |
|---|
| 672 | } |
|---|
| 673 | s+=screen_buffer_width-screen_width; |
|---|
| 674 | if (y*screen_height/viewport_height == (s+screen_buffer_width)/screen_buffer_width) { |
|---|
| 675 | memcpy(buf+s, buf+s-screen_buffer_width, screen_buffer_width); |
|---|
| 676 | s+=screen_buffer_width; |
|---|
| 677 | } |
|---|
| 678 | } |
|---|
| 679 | if (!zebra_drawn) f=0; |
|---|
| 680 | } |
|---|
| 681 | // if blink mode is in no-zebra phase OR if there was no over/underexposed pixels to draw zebra on |
|---|
| 682 | if (!f) { |
|---|
| 683 | // if zebra was drawn during previous call of this function |
|---|
| 684 | if (need_restore) { |
|---|
| 685 | if (conf.zebra_restore_screen || conf.zebra_restore_osd) { |
|---|
| 686 | draw_restore(); |
|---|
| 687 | } else { // clear buf[] of zebra, only leave Canon OSD |
|---|
| 688 | if (mrec) { // REC mode |
|---|
| 689 | #if ZEBRA_CANONOSD_BORDER_RESTORE |
|---|
| 690 | // copy rescued Canon OSD to buf[] top/bottom parts and fill center with transparent color: |
|---|
| 691 | memcpy(buf, cur_buf_top, screen_buffer_width * ZFIX_TOP); |
|---|
| 692 | memcpy(buf + screen_buffer_size - screen_buffer_width * ZFIX_BOTTOM, cur_buf_bot, screen_buffer_width * ZFIX_BOTTOM); |
|---|
| 693 | for (s = screen_buffer_width*ZFIX_TOP; s < screen_buffer_size-screen_buffer_width*ZFIX_BOTTOM; s++) { |
|---|
| 694 | buf[s]=COLOR_TRANSPARENT; |
|---|
| 695 | } |
|---|
| 696 | #else |
|---|
| 697 | // copy from a complete Canon OSD rescue screen dump |
|---|
| 698 | memcpy(buf, cur_buf, screen_buffer_size); |
|---|
| 699 | #endif |
|---|
| 700 | } else { // Not REC mode |
|---|
| 701 | // No Canon OSD restore, fill buf[] with transparent color: |
|---|
| 702 | memset(buf, COLOR_TRANSPARENT, screen_buffer_size); |
|---|
| 703 | } |
|---|
| 704 | // draw CHDK osd and histogram to buf[] (if enabled in config) |
|---|
| 705 | gui_osd_draw_zebra_osd(); |
|---|
| 706 | // copy buf[] to both display buffers |
|---|
| 707 | memcpy(scr_buf, buf, screen_buffer_size); |
|---|
| 708 | memcpy(scr_buf+screen_buffer_size, buf, screen_buffer_size); |
|---|
| 709 | } |
|---|
| 710 | need_restore=0; |
|---|
| 711 | } |
|---|
| 712 | return !(conf.zebra_restore_screen && conf.zebra_restore_osd); |
|---|
| 713 | // if zebra was drawn |
|---|
| 714 | } else { |
|---|
| 715 | // draw CHDK osd and histogram to buf[] over zebra (if enabled in config) |
|---|
| 716 | gui_osd_draw_zebra_osd(); |
|---|
| 717 | // copy buf[] to both display buffers |
|---|
| 718 | memcpy(scr_buf, buf, screen_buffer_size); |
|---|
| 719 | memcpy(scr_buf+screen_buffer_size, buf, screen_buffer_size); |
|---|
| 720 | |
|---|
| 721 | need_restore=1; |
|---|
| 722 | return 1; |
|---|
| 723 | } |
|---|
| 724 | return 0; |
|---|
| 725 | } |
|---|
| 726 | #endif |
|---|
| 727 | //------------------------------------------------------------------- |
|---|
| 728 | static void gui_osd_draw_blended_histo(coord x, coord y) { |
|---|
| 729 | register unsigned int i, v, red, grn, blu, sel; |
|---|
| 730 | int m = ((mode_get()&MODE_MASK) == MODE_REC); |
|---|
| 731 | color cls[] = { |
|---|
| 732 | conf.histo_color>>8, |
|---|
| 733 | (m)?COLOR_HISTO_B:COLOR_HISTO_B_PLAY, |
|---|
| 734 | (m)?COLOR_HISTO_G:COLOR_HISTO_G_PLAY, |
|---|
| 735 | (m)?COLOR_HISTO_BG:COLOR_HISTO_BG_PLAY, |
|---|
| 736 | (m)?COLOR_HISTO_R:COLOR_HISTO_R_PLAY, |
|---|
| 737 | (m)?COLOR_HISTO_RB:COLOR_HISTO_RB_PLAY, |
|---|
| 738 | (m)?COLOR_HISTO_RG:COLOR_HISTO_RG_PLAY, |
|---|
| 739 | COLOR_WHITE |
|---|
| 740 | }; |
|---|
| 741 | |
|---|
| 742 | for (i=0; i<HISTO_WIDTH; ++i) { |
|---|
| 743 | red = histogram[HISTO_R][i]; |
|---|
| 744 | grn = histogram[HISTO_G][i]; |
|---|
| 745 | blu = histogram[HISTO_B][i]; |
|---|
| 746 | |
|---|
| 747 | for (v=1; v<HISTO_HEIGHT; ++v) { |
|---|
| 748 | sel = 0; |
|---|
| 749 | |
|---|
| 750 | if (v < red) sel = 4; |
|---|
| 751 | if (v < grn) sel |= 2; |
|---|
| 752 | if (v < blu) sel |= 1; |
|---|
| 753 | |
|---|
| 754 | draw_pixel(x+1+i, y+HISTO_HEIGHT-v, cls[sel]); |
|---|
| 755 | } |
|---|
| 756 | } |
|---|
| 757 | |
|---|
| 758 | draw_rect(x, y, x+1+HISTO_WIDTH, y+HISTO_HEIGHT, conf.histo_color2&0xFF); |
|---|
| 759 | //Vertical lines |
|---|
| 760 | if (conf.histo_show_ev_grid) for (i=1;i<=4;i++) draw_line(x+(1+HISTO_WIDTH)*i/5, y, x+(1+HISTO_WIDTH)*i/5, y+HISTO_HEIGHT, conf.histo_color2&0xFF); |
|---|
| 761 | |
|---|
| 762 | } |
|---|
| 763 | |
|---|
| 764 | //------------------------------------------------------------------- |
|---|
| 765 | void gui_osd_draw_histo() { |
|---|
| 766 | switch (conf.histo_layout) { |
|---|
| 767 | case OSD_HISTO_LAYOUT_Y: |
|---|
| 768 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 769 | break; |
|---|
| 770 | case OSD_HISTO_LAYOUT_A_Y: |
|---|
| 771 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 772 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 773 | break; |
|---|
| 774 | case OSD_HISTO_LAYOUT_R_G_B: |
|---|
| 775 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 776 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 777 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT*2, 0); |
|---|
| 778 | break; |
|---|
| 779 | case OSD_HISTO_LAYOUT_A_yrgb: |
|---|
| 780 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 781 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 782 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 783 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 784 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 785 | break; |
|---|
| 786 | case OSD_HISTO_LAYOUT_Y_argb: |
|---|
| 787 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 788 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 789 | gui_osd_draw_single_histo(HISTO_R, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT, 1); |
|---|
| 790 | gui_osd_draw_single_histo(HISTO_G, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 791 | gui_osd_draw_single_histo(HISTO_B, conf.histo_pos.x+HISTO_WIDTH/2+1, conf.histo_pos.y+HISTO_HEIGHT+HISTO_HEIGHT/2, 1); |
|---|
| 792 | break; |
|---|
| 793 | case OSD_HISTO_LAYOUT_BLEND: |
|---|
| 794 | gui_osd_draw_blended_histo(conf.histo_pos.x, conf.histo_pos.y); |
|---|
| 795 | break; |
|---|
| 796 | case OSD_HISTO_LAYOUT_BLEND_Y: |
|---|
| 797 | gui_osd_draw_blended_histo(conf.histo_pos.x, conf.histo_pos.y); |
|---|
| 798 | gui_osd_draw_single_histo(HISTO_Y, conf.histo_pos.x, conf.histo_pos.y+HISTO_HEIGHT, 0); |
|---|
| 799 | break; |
|---|
| 800 | case OSD_HISTO_LAYOUT_A: |
|---|
| 801 | default: |
|---|
| 802 | gui_osd_draw_single_histo(HISTO_RGB, conf.histo_pos.x, conf.histo_pos.y, 0); |
|---|
| 803 | break; |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | if (conf.histo_layout != OSD_HISTO_LAYOUT_R_G_B) { |
|---|
| 807 | if (under_exposed && conf.show_overexp) { |
|---|
| 808 | draw_filled_ellipse(conf.histo_pos.x+5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); |
|---|
| 809 | } |
|---|
| 810 | |
|---|
| 811 | if (over_exposed && conf.show_overexp) { |
|---|
| 812 | draw_filled_ellipse(conf.histo_pos.x+HISTO_WIDTH-5, conf.histo_pos.y+5, 3, 3, MAKE_COLOR(conf.histo_color2>>8, conf.histo_color2>>8)); |
|---|
| 813 | } |
|---|
| 814 | } |
|---|
| 815 | if ((conf.show_overexp ) && kbd_is_key_pressed(KEY_SHOOT_HALF) && (under_exposed || over_exposed)) |
|---|
| 816 | draw_string(conf.histo_pos.x+HISTO_WIDTH-FONT_WIDTH*3, conf.histo_pos.y-FONT_HEIGHT, "EXP", conf.histo_color); |
|---|
| 817 | if (conf.histo_auto_ajust){ |
|---|
| 818 | if (histo_magnification) { |
|---|
| 819 | sprintf(osd_buf, " %d.%02dx ", histo_magnification/1000, histo_magnification/10%100); |
|---|
| 820 | draw_string(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, osd_buf, conf.histo_color); |
|---|
| 821 | } else if (gui_get_mode()==GUI_MODE_OSD){ |
|---|
| 822 | draw_string(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, " 9.99x ", conf.histo_color); |
|---|
| 823 | } else { |
|---|
| 824 | draw_filled_rect(conf.histo_pos.x, conf.histo_pos.y-FONT_HEIGHT, conf.histo_pos.x+8*FONT_WIDTH, conf.histo_pos.y-1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 825 | } |
|---|
| 826 | } |
|---|
| 827 | } |
|---|
| 828 | |
|---|
| 829 | //------------------------------------------------------------------- |
|---|
| 830 | static void sprintf_dist(char *buf, float dist) { |
|---|
| 831 | // length of printed string is always 4 |
|---|
| 832 | if (dist<=0 || dist>=MAX_DIST) { |
|---|
| 833 | sprintf(buf, " inf"); |
|---|
| 834 | } else if (dist<1000) { |
|---|
| 835 | sprintf(buf, ".%03d", (int)dist); |
|---|
| 836 | } else if (dist<10000) { |
|---|
| 837 | sprintf(buf, "%d.%02d", (int)(dist/1000), (int)(dist/10)%100); |
|---|
| 838 | } else if (dist<100000) { |
|---|
| 839 | sprintf(buf, "%02d.%d", (int)(dist/1000), (int)(dist/100)%10); |
|---|
| 840 | } else { |
|---|
| 841 | sprintf(buf, "%4d", (int)(dist/1000)); |
|---|
| 842 | } |
|---|
| 843 | } |
|---|
| 844 | |
|---|
| 845 | static void sprintf_canon_values(char *buf, short dist) |
|---|
| 846 | { |
|---|
| 847 | short v=((dist<0)?-dist:dist); |
|---|
| 848 | sprintf(buf, "%s%d.%02d", ((dist<0)?"-":""), v/96, v%96); |
|---|
| 849 | } |
|---|
| 850 | |
|---|
| 851 | |
|---|
| 852 | //------------------------------------------------------------------- |
|---|
| 853 | |
|---|
| 854 | void gui_osd_calc_dof() { |
|---|
| 855 | |
|---|
| 856 | int av, av_min, c_of_c, fl, v, v1, m; |
|---|
| 857 | //long lfpfl=lens_get_focus_pos_fl(); |
|---|
| 858 | |
|---|
| 859 | #if CAM_HAS_IRIS_DIAPHRAGM |
|---|
| 860 | av=shooting_get_real_aperture(); |
|---|
| 861 | #else |
|---|
| 862 | av=shooting_get_min_real_aperture(); |
|---|
| 863 | #endif |
|---|
| 864 | fl=get_focal_length(lens_get_zoom_point()); |
|---|
| 865 | dof.far_limit=-1.0; |
|---|
| 866 | dof.near_limit=-1.0; |
|---|
| 867 | dof.depth_of_field=-1.0; |
|---|
| 868 | dof.hyperfocal_distance=-1.0; |
|---|
| 869 | dof.subject_distance=-1.0; |
|---|
| 870 | |
|---|
| 871 | if ((av!=0) && (fl!=0)) { |
|---|
| 872 | if (conf.dof_subj_dist_as_near_limit) { |
|---|
| 873 | v1=(fl*fl); |
|---|
| 874 | dof.near_limit=shooting_get_canon_subject_distance(); |
|---|
| 875 | av_min=shooting_get_min_real_aperture(); |
|---|
| 876 | c_of_c=circle_of_confusion*10; |
|---|
| 877 | if ((av_min!=0) && (c_of_c!=0)) dof.hyperfocal_distance=v1/(c_of_c*av_min); |
|---|
| 878 | if ((dof.near_limit>0) && (dof.near_limit<MAX_DIST)) { |
|---|
| 879 | v=(dof.hyperfocal_distance-dof.near_limit); |
|---|
| 880 | m=dof.hyperfocal_distance*dof.near_limit; |
|---|
| 881 | if ((v>0) && (m>0)) dof.subject_distance=m/v; |
|---|
| 882 | } |
|---|
| 883 | dof.hyperfocal_distance=v1/(c_of_c*av); |
|---|
| 884 | if ((dof.subject_distance>0) && (dof.subject_distance<MAX_DIST)) { |
|---|
| 885 | v = (dof.hyperfocal_distance-dof.subject_distance); |
|---|
| 886 | m=dof.hyperfocal_distance*dof.subject_distance; |
|---|
| 887 | if ((v>0) && (m>0)) dof.far_limit=m/v; |
|---|
| 888 | dof.depth_of_field=dof.far_limit-dof.near_limit; |
|---|
| 889 | } |
|---|
| 890 | } |
|---|
| 891 | else { |
|---|
| 892 | dof.subject_distance=shooting_get_canon_subject_distance(); |
|---|
| 893 | dof.hyperfocal_distance=(fl*fl)/(10*circle_of_confusion*av); |
|---|
| 894 | if (dof.subject_distance>0 && dof.subject_distance<MAX_DIST) { |
|---|
| 895 | m = dof.hyperfocal_distance*dof.subject_distance; |
|---|
| 896 | v = (dof.hyperfocal_distance+dof.subject_distance); |
|---|
| 897 | if ((v>0) && (m>0)) dof.near_limit=m/v; |
|---|
| 898 | v = (dof.hyperfocal_distance-dof.subject_distance); |
|---|
| 899 | if ((v>0) && (m>0)) dof.far_limit=m/v; |
|---|
| 900 | dof.depth_of_field=dof.far_limit-dof.near_limit; |
|---|
| 901 | } |
|---|
| 902 | } |
|---|
| 903 | } |
|---|
| 904 | if (conf.dof_dist_from_lens) { |
|---|
| 905 | int h=shooting_get_lens_to_focal_plane_width(); |
|---|
| 906 | if (dof.subject_distance>0) dof.subject_distance-=h; |
|---|
| 907 | if (dof.far_limit>0) dof.far_limit-=h; |
|---|
| 908 | if (dof.near_limit>0) dof.near_limit-=h; |
|---|
| 909 | if (dof.hyperfocal_distance>0) dof.hyperfocal_distance-=h; |
|---|
| 910 | } |
|---|
| 911 | } |
|---|
| 912 | |
|---|
| 913 | void gui_osd_calc_expo_param() { |
|---|
| 914 | |
|---|
| 915 | expo.av96=shooting_get_av96(); |
|---|
| 916 | expo.tv96=shooting_get_tv96(); |
|---|
| 917 | expo.sv96=shooting_get_sv96(); |
|---|
| 918 | expo.iso=shooting_get_iso_real(); |
|---|
| 919 | expo.sv96_market=shooting_get_svm96(); |
|---|
| 920 | expo.iso_market=shooting_get_iso_market(); |
|---|
| 921 | expo.bv96_measured=shooting_get_bv96(); |
|---|
| 922 | expo.ev96_seted=expo.tv96+expo.av96; //Tv96+Av96 |
|---|
| 923 | expo.ev96_measured=expo.bv96_measured+expo.sv96;//Bv96+Sv96 |
|---|
| 924 | expo.dev96=expo.ev96_measured-expo.ev96_seted;// Ev96_external-Ev96_internal |
|---|
| 925 | expo.bv96_seted=expo.ev96_seted-expo.sv96; |
|---|
| 926 | expo.dev96_canon=shooting_get_canon_overexposure_value(); |
|---|
| 927 | expo.b=shooting_get_luminance(); |
|---|
| 928 | } |
|---|
| 929 | |
|---|
| 930 | void gui_osd_draw_dof() { |
|---|
| 931 | |
|---|
| 932 | //gui_osd_calc_dof(); |
|---|
| 933 | //strcpy(osd_buf, ""); |
|---|
| 934 | draw_string(conf.dof_pos.x, conf.dof_pos.y, "S/R1/R2:", conf.osd_color); |
|---|
| 935 | sprintf_dist(osd_buf, dof.subject_distance); |
|---|
| 936 | int i=strlen(osd_buf); |
|---|
| 937 | osd_buf[i]='/'; |
|---|
| 938 | sprintf_dist(osd_buf+i+1, dof.near_limit); |
|---|
| 939 | i=strlen(osd_buf); |
|---|
| 940 | osd_buf[i]='/'; |
|---|
| 941 | sprintf_dist(osd_buf+i+1, dof.far_limit); |
|---|
| 942 | draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y, osd_buf, conf.osd_color); |
|---|
| 943 | |
|---|
| 944 | draw_string(conf.dof_pos.x, conf.dof_pos.y+FONT_HEIGHT, "DOF/HYP:", conf.osd_color); |
|---|
| 945 | sprintf_dist(osd_buf, dof.depth_of_field); |
|---|
| 946 | int j=strlen(osd_buf); |
|---|
| 947 | osd_buf[j]='/'; |
|---|
| 948 | sprintf_dist(osd_buf+j+1, dof.hyperfocal_distance); |
|---|
| 949 | draw_string(conf.dof_pos.x+8*FONT_WIDTH, conf.dof_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 950 | |
|---|
| 951 | } |
|---|
| 952 | |
|---|
| 953 | static short n, m; //string number |
|---|
| 954 | |
|---|
| 955 | void gui_print_osd_state_string_int(const char * title, int value) { |
|---|
| 956 | strcpy(osd_buf, title); |
|---|
| 957 | sprintf(osd_buf+strlen(osd_buf), "%d", value); |
|---|
| 958 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 959 | osd_buf[12]=0; |
|---|
| 960 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 961 | n+=FONT_HEIGHT; |
|---|
| 962 | } |
|---|
| 963 | |
|---|
| 964 | void gui_print_osd_state_string_chr(const char *title, const char *value) { |
|---|
| 965 | strcpy(osd_buf, title); |
|---|
| 966 | sprintf(osd_buf+strlen(osd_buf), "%s", value); |
|---|
| 967 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 968 | osd_buf[12]=0; |
|---|
| 969 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 970 | n+=FONT_HEIGHT; |
|---|
| 971 | } |
|---|
| 972 | |
|---|
| 973 | void gui_print_osd_state_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 974 | strcpy(osd_buf, title); |
|---|
| 975 | sprintf(osd_buf+strlen(osd_buf), fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 976 | sprintf(osd_buf+strlen(osd_buf), "%12s", ""); |
|---|
| 977 | osd_buf[12]=0; |
|---|
| 978 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, osd_buf, conf.osd_color_override); |
|---|
| 979 | n+=FONT_HEIGHT; |
|---|
| 980 | } |
|---|
| 981 | |
|---|
| 982 | void gui_print_osd_misc_string_int(const char * title, int value) { |
|---|
| 983 | strcpy(osd_buf, title); |
|---|
| 984 | sprintf(osd_buf+strlen(osd_buf), "%d", value); |
|---|
| 985 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 986 | osd_buf[9]=0; |
|---|
| 987 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 988 | m+=FONT_HEIGHT; |
|---|
| 989 | } |
|---|
| 990 | |
|---|
| 991 | /* |
|---|
| 992 | void gui_print_osd_misc_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 993 | char s[16]; |
|---|
| 994 | strcpy(osd_buf, title); |
|---|
| 995 | sprintf(s, fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 996 | sprintf(osd_buf+strlen(osd_buf), "%6s", s); |
|---|
| 997 | //osd_buf[8]=0; |
|---|
| 998 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 999 | m+=FONT_HEIGHT; |
|---|
| 1000 | } |
|---|
| 1001 | */ |
|---|
| 1002 | |
|---|
| 1003 | void gui_print_osd_misc_string_float(const char * title, const char * fmt, int divisor, int value) { |
|---|
| 1004 | strcpy(osd_buf, title); |
|---|
| 1005 | sprintf(osd_buf+strlen(osd_buf), fmt, (int)(value/divisor), (int)(value%divisor)); |
|---|
| 1006 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 1007 | osd_buf[9]=0; |
|---|
| 1008 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 1009 | m+=FONT_HEIGHT; |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | |
|---|
| 1013 | void gui_print_osd_misc_string_dist(const char * title, int value) { |
|---|
| 1014 | strcpy(osd_buf, title); |
|---|
| 1015 | sprintf_dist(osd_buf+strlen(osd_buf), (float)value); |
|---|
| 1016 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 1017 | osd_buf[9]=0; |
|---|
| 1018 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 1019 | m+=FONT_HEIGHT; |
|---|
| 1020 | } |
|---|
| 1021 | |
|---|
| 1022 | void gui_print_osd_misc_string_canon_values(const char * title, short value) { |
|---|
| 1023 | strcpy(osd_buf, title); |
|---|
| 1024 | sprintf_canon_values(osd_buf+strlen(osd_buf), value); |
|---|
| 1025 | sprintf(osd_buf+strlen(osd_buf), "%9s", ""); |
|---|
| 1026 | osd_buf[9]=0; |
|---|
| 1027 | draw_string(conf.values_pos.x, conf.values_pos.y+m, osd_buf, conf.osd_color); |
|---|
| 1028 | m+=FONT_HEIGHT; |
|---|
| 1029 | } |
|---|
| 1030 | |
|---|
| 1031 | //------------------------------------------------------------------- |
|---|
| 1032 | void gui_osd_draw_raw_info() |
|---|
| 1033 | { |
|---|
| 1034 | int x, m=(mode_get()&MODE_SHOOTING_MASK); |
|---|
| 1035 | static int b; |
|---|
| 1036 | if ((!((movie_status > 1) && conf.save_raw_in_video )) && (!(shooting_get_prop(PROPCASE_RESOLUTION)==5)) && (!((m==MODE_SPORTS) && conf.save_raw_in_sports)) && (!((m==MODE_AUTO) && conf.save_raw_in_auto)) && (!(conf.edge_overlay_enable && conf.save_raw_in_edgeoverlay)) && (!((shooting_get_drive_mode()==1) && conf.save_raw_in_burst && !(m==MODE_SPORTS))) && (!((shooting_get_drive_mode()>=2) && conf.save_raw_in_timer)) && (!((shooting_get_prop(PROPCASE_BRACKET_MODE)==1) && conf.save_raw_in_ev_bracketing)) ) |
|---|
| 1037 | { |
|---|
| 1038 | if (conf.show_remaining_raw) |
|---|
| 1039 | { |
|---|
| 1040 | int raw_count=GetRawCount(); |
|---|
| 1041 | if (raw_count>conf.remaining_raw_treshold) |
|---|
| 1042 | { |
|---|
| 1043 | if (conf.dng_raw) sprintf(osd_buf, "DNG:%3d", raw_count); else sprintf(osd_buf, "RAW:%3d", raw_count); |
|---|
| 1044 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color); |
|---|
| 1045 | } |
|---|
| 1046 | else |
|---|
| 1047 | { |
|---|
| 1048 | |
|---|
| 1049 | if (conf.dng_raw) sprintf(osd_buf, "DNG:%3d", raw_count); else sprintf(osd_buf, "RAW:%3d", raw_count); |
|---|
| 1050 | |
|---|
| 1051 | if (b > 6) |
|---|
| 1052 | { |
|---|
| 1053 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color_warn); |
|---|
| 1054 | b = (b>12) ? 0 : b+1; |
|---|
| 1055 | } |
|---|
| 1056 | else |
|---|
| 1057 | { |
|---|
| 1058 | draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, osd_buf, conf.osd_color); |
|---|
| 1059 | b = b+1; |
|---|
| 1060 | } |
|---|
| 1061 | } |
|---|
| 1062 | } |
|---|
| 1063 | else if (conf.dng_raw) draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "DNG", conf.osd_color); else draw_string(conf.mode_raw_pos.x, conf.mode_raw_pos.y, "RAW", conf.osd_color); |
|---|
| 1064 | } |
|---|
| 1065 | else if (conf.raw_exceptions_warn) |
|---|
| 1066 | { |
|---|
| 1067 | if (conf.dng_raw) gui_print_osd_state_string_chr("DNG Disabled",""); else gui_print_osd_state_string_chr("RAW Disabled",""); |
|---|
| 1068 | } |
|---|
| 1069 | |
|---|
| 1070 | |
|---|
| 1071 | } |
|---|
| 1072 | //------------------------------------------------------------------- |
|---|
| 1073 | void gui_osd_draw_state() { |
|---|
| 1074 | int a, gui_mode=gui_get_mode(), m=(mode_get()&MODE_SHOOTING_MASK); |
|---|
| 1075 | long t; |
|---|
| 1076 | |
|---|
| 1077 | n=0; |
|---|
| 1078 | /////////////////////////// |
|---|
| 1079 | //sprintf(osd_buf,"%s",get_debug()); |
|---|
| 1080 | //draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+6*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1081 | //////////////////////////// |
|---|
| 1082 | |
|---|
| 1083 | |
|---|
| 1084 | if ((((conf.tv_enum_type) || (conf.tv_override_value)) && (conf.tv_override_koef) && !(conf.override_disable==1)) || gui_mode==GUI_MODE_OSD){ |
|---|
| 1085 | if(kbd_is_key_pressed(KEY_SHOOT_HALF)) |
|---|
| 1086 | { |
|---|
| 1087 | t=(int)(shooting_get_shutter_speed_from_tv96(shooting_get_tv96())*100000); |
|---|
| 1088 | gui_print_osd_state_string_float("TV:", "%d.%05d ", 100000, t); |
|---|
| 1089 | } |
|---|
| 1090 | else |
|---|
| 1091 | { |
|---|
| 1092 | if (conf.tv_enum_type) |
|---|
| 1093 | gui_print_osd_state_string_chr("TV:",shooting_get_tv_override_value()); |
|---|
| 1094 | else |
|---|
| 1095 | { |
|---|
| 1096 | t=(int)(shooting_get_shutter_speed_override_value()*100000); |
|---|
| 1097 | gui_print_osd_state_string_float("TV:", "%d.%05d ", 100000, t); |
|---|
| 1098 | } |
|---|
| 1099 | } |
|---|
| 1100 | } |
|---|
| 1101 | if ((conf.av_override_value && !(conf.override_disable==1))|| gui_mode==GUI_MODE_OSD) |
|---|
| 1102 | gui_print_osd_state_string_float("AV:", "%d.%02d ", 100, shooting_get_aperture_from_av96(shooting_get_av96_override_value())); |
|---|
| 1103 | #if CAM_HAS_ND_FILTER |
|---|
| 1104 | if ((conf.nd_filter_state && !(conf.override_disable==1))|| gui_mode==GUI_MODE_OSD) |
|---|
| 1105 | gui_print_osd_state_string_chr("NDFILTER:", ((conf.nd_filter_state==1)?"IN":"OUT")); |
|---|
| 1106 | #endif |
|---|
| 1107 | if ((conf.autoiso_enable && shooting_get_iso_mode()<=0 && !(m==MODE_M || m==MODE_TV) && shooting_get_flash_mode() && (!(conf.override_disable==1 && conf.override_disable_all))) || gui_mode==GUI_MODE_OSD) |
|---|
| 1108 | gui_print_osd_state_string_chr("AUTOISO:", ((conf.autoiso_enable==1)?"ON":"OFF")); |
|---|
| 1109 | if ((conf.subj_dist_override_value && conf.subj_dist_override_koef && shooting_can_focus() && !(conf.override_disable==1)) || ((gui_mode==GUI_MODE_ALT) && shooting_get_common_focus_mode()) || gui_mode==GUI_MODE_OSD) { |
|---|
| 1110 | gui_print_osd_state_string_int("SD:",shooting_get_subject_distance_override_value()); |
|---|
| 1111 | if (gui_mode==GUI_MODE_ALT) |
|---|
| 1112 | gui_print_osd_state_string_int("FACTOR:",shooting_get_subject_distance_override_koef()); |
|---|
| 1113 | } |
|---|
| 1114 | if ((conf.iso_override_value && conf.iso_override_koef && !(conf.override_disable==1)) || gui_mode==GUI_MODE_OSD) |
|---|
| 1115 | gui_print_osd_state_string_int("ISO:", shooting_get_iso_override_value()); |
|---|
| 1116 | if ((gui_mode==GUI_MODE_OSD) || (shooting_get_drive_mode())) { |
|---|
| 1117 | if ((conf.tv_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) || (conf.av_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) || (conf.iso_bracket_value && conf.iso_bracket_koef && !(conf.override_disable==1 && conf.override_disable_all)) || ((conf.subj_dist_bracket_value) && (conf.subj_dist_bracket_koef) && (shooting_can_focus() && !(conf.override_disable==1 && conf.override_disable_all)))) |
|---|
| 1118 | gui_print_osd_state_string_chr("BRACKET:", shooting_get_bracket_type()); |
|---|
| 1119 | if (conf.tv_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 1120 | gui_print_osd_state_string_chr("TV:", shooting_get_tv_bracket_value()); |
|---|
| 1121 | else if (conf.av_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 1122 | gui_print_osd_state_string_chr("AV:", shooting_get_av_bracket_value()); |
|---|
| 1123 | else if (conf.iso_bracket_value && conf.iso_bracket_koef && !(conf.override_disable==1 && conf.override_disable_all)) |
|---|
| 1124 | gui_print_osd_state_string_int("ISO:", shooting_get_iso_bracket_value()); |
|---|
| 1125 | else if ((conf.subj_dist_bracket_value && !(conf.override_disable==1 && conf.override_disable_all)) && (conf.subj_dist_bracket_koef) && (shooting_can_focus())) |
|---|
| 1126 | gui_print_osd_state_string_int("SD:",shooting_get_subject_distance_bracket_value()); |
|---|
| 1127 | } |
|---|
| 1128 | #ifdef OPT_CURVES |
|---|
| 1129 | if (conf.curve_enable || gui_mode==GUI_MODE_OSD) { |
|---|
| 1130 | if (conf.curve_enable==1) gui_print_osd_state_string_chr("CURVES:", "CSTM"); |
|---|
| 1131 | else if (conf.curve_enable==4) gui_print_osd_state_string_chr("CURVES:", "AUTO"); |
|---|
| 1132 | else if (conf.curve_enable==3) gui_print_osd_state_string_chr("CURVES:", "+2EV"); |
|---|
| 1133 | else if (conf.curve_enable==2) gui_print_osd_state_string_chr("CURVES:", "+1EV"); |
|---|
| 1134 | } |
|---|
| 1135 | #endif |
|---|
| 1136 | if (conf.override_disable == 1) gui_print_osd_state_string_chr("NO ", "OVERRIDES"); |
|---|
| 1137 | if (conf.flash_manual_override) gui_print_osd_state_string_chr("Flash:", "Manual Override"); |
|---|
| 1138 | /* |
|---|
| 1139 | draw_string(conf.mode_state_pos.x, conf.mode_state_pos.y+n, get_debug(), conf.osd_color); |
|---|
| 1140 | n+=FONT_HEIGHT;*/ |
|---|
| 1141 | } |
|---|
| 1142 | |
|---|
| 1143 | //------------------------------------------------------------------- |
|---|
| 1144 | void gui_osd_draw_values(int showtype) { |
|---|
| 1145 | int iso_mode=shooting_get_iso_mode(); |
|---|
| 1146 | float s=-1.0f; |
|---|
| 1147 | |
|---|
| 1148 | m=0; |
|---|
| 1149 | |
|---|
| 1150 | //gui_osd_calc_expo_param(); |
|---|
| 1151 | |
|---|
| 1152 | if (conf.values_show_zoom) { |
|---|
| 1153 | int fl, zp=lens_get_zoom_point(), fl1=get_focal_length(zp); |
|---|
| 1154 | switch (conf.zoom_value) { |
|---|
| 1155 | case ZOOM_SHOW_FL: |
|---|
| 1156 | sprintf(osd_buf, "Z:%d.%dmm%8s", fl1/1000, fl1%1000/100, ""); |
|---|
| 1157 | break; |
|---|
| 1158 | case ZOOM_SHOW_EFL: |
|---|
| 1159 | fl=get_effective_focal_length(zp); |
|---|
| 1160 | // scale by users adapter lens eg. Canon Wide .42 or Canon Tele 1.75 |
|---|
| 1161 | fl = fl * conf.zoom_scale / 100; |
|---|
| 1162 | sprintf(osd_buf, "Z:%3dmm%8s", fl/1000, ""); |
|---|
| 1163 | break; |
|---|
| 1164 | case ZOOM_SHOW_X: |
|---|
| 1165 | default: |
|---|
| 1166 | fl=get_zoom_x(zp); |
|---|
| 1167 | sprintf(osd_buf, "Z:%ld/%d.%dx%8s", zp, fl/10, fl%10, ""); |
|---|
| 1168 | break; |
|---|
| 1169 | } |
|---|
| 1170 | osd_buf[9]=0; |
|---|
| 1171 | draw_string(conf.values_pos.x, conf.values_pos.y, osd_buf, conf.osd_color); |
|---|
| 1172 | m+=FONT_HEIGHT; |
|---|
| 1173 | } |
|---|
| 1174 | |
|---|
| 1175 | |
|---|
| 1176 | if ((conf.values_show_real_aperture) && (showtype==1)) |
|---|
| 1177 | gui_print_osd_misc_string_float("Av :", "%d.%02d ", 100, shooting_get_real_aperture()); |
|---|
| 1178 | if ((conf.show_dof==DOF_SHOW_IN_MISC) && (showtype)) { |
|---|
| 1179 | //if (kbd_is_key_pressed(KEY_SHOOT_HALF) && (mode_photo || (m&MODE_SHOOTING_MASK)==MODE_STITCH)) |
|---|
| 1180 | //gui_osd_calc_dof(); |
|---|
| 1181 | if (conf.dof_subj_dist_in_misc) gui_print_osd_misc_string_dist("SD :", dof.subject_distance); |
|---|
| 1182 | if (conf.dof_near_limit_in_misc) gui_print_osd_misc_string_dist("NL :", dof.near_limit); |
|---|
| 1183 | if (conf.dof_far_limit_in_misc) gui_print_osd_misc_string_dist("FL :", dof.far_limit); |
|---|
| 1184 | if (conf.dof_depth_in_misc) gui_print_osd_misc_string_dist("DOF:", dof.depth_of_field); |
|---|
| 1185 | if (conf.dof_hyperfocal_in_misc) gui_print_osd_misc_string_dist("HYP:", dof.hyperfocal_distance); |
|---|
| 1186 | } |
|---|
| 1187 | if (showtype==1) { |
|---|
| 1188 | if ((iso_mode <= 0) || !(conf.values_show_iso_only_in_autoiso_mode)) { |
|---|
| 1189 | if (conf.values_show_real_iso) gui_print_osd_misc_string_int("I-R:", expo.iso); |
|---|
| 1190 | if (conf.values_show_market_iso) gui_print_osd_misc_string_int("I-M:", expo.iso_market); |
|---|
| 1191 | } |
|---|
| 1192 | if (conf.values_show_bv_measured) gui_print_osd_misc_string_canon_values("Bvm:", expo.bv96_measured ); |
|---|
| 1193 | if (conf.values_show_bv_seted) gui_print_osd_misc_string_canon_values("Bvs:", expo.bv96_seted ); |
|---|
| 1194 | if (conf.values_show_ev_measured) gui_print_osd_misc_string_canon_values("Evm:", expo.ev96_measured); |
|---|
| 1195 | if (conf.values_show_ev_seted ) gui_print_osd_misc_string_canon_values("Evs:", expo.ev96_seted ); |
|---|
| 1196 | if (conf.values_show_overexposure) gui_print_osd_misc_string_canon_values("dE :", expo.dev96); |
|---|
| 1197 | if (conf.values_show_canon_overexposure ) gui_print_osd_misc_string_canon_values("dEc:", expo.dev96_canon); |
|---|
| 1198 | if (conf.values_show_luminance) gui_print_osd_misc_string_float("B :", "%d.%02d ", 100, expo.b); |
|---|
| 1199 | |
|---|
| 1200 | } |
|---|
| 1201 | |
|---|
| 1202 | } |
|---|
| 1203 | |
|---|
| 1204 | #define CLOCK_FORMAT_24 0 |
|---|
| 1205 | #define CLOCK_FORMAT_12 1 |
|---|
| 1206 | #define CLOCK_WITHOUT_SEC 1 |
|---|
| 1207 | #define CLOCK_WITH_SEC 2 |
|---|
| 1208 | |
|---|
| 1209 | //------------------------------------------------------------------- |
|---|
| 1210 | void gui_osd_draw_clock(int x, int y, color cl) { |
|---|
| 1211 | unsigned long t; |
|---|
| 1212 | static struct tm *ttm; |
|---|
| 1213 | int w = 0; |
|---|
| 1214 | int z; |
|---|
| 1215 | static char am[4]; |
|---|
| 1216 | static char pm[4]; |
|---|
| 1217 | static char curr[4]; |
|---|
| 1218 | t = time(NULL); |
|---|
| 1219 | ttm = localtime(&t); |
|---|
| 1220 | unsigned int hour=(ttm->tm_hour); |
|---|
| 1221 | if (conf.clock_format == CLOCK_FORMAT_12) { |
|---|
| 1222 | switch(conf.clock_indicator) |
|---|
| 1223 | { |
|---|
| 1224 | case 1: |
|---|
| 1225 | sprintf(pm, "P"); |
|---|
| 1226 | sprintf(am, "A"); |
|---|
| 1227 | w = 1; |
|---|
| 1228 | break; |
|---|
| 1229 | case 2: |
|---|
| 1230 | sprintf(pm, "."); |
|---|
| 1231 | sprintf(am, " "); |
|---|
| 1232 | w = 1; |
|---|
| 1233 | break; |
|---|
| 1234 | default: |
|---|
| 1235 | sprintf(pm, " PM"); |
|---|
| 1236 | sprintf(am, " AM"); |
|---|
| 1237 | w = 3; |
|---|
| 1238 | break; |
|---|
| 1239 | } |
|---|
| 1240 | sprintf(curr,((hour>=12)?pm:am)); |
|---|
| 1241 | if ((ttm->tm_hour)==00) hour=12; |
|---|
| 1242 | else if ((ttm->tm_hour)>12) hour=hour-12; |
|---|
| 1243 | } |
|---|
| 1244 | switch(conf.show_clock) |
|---|
| 1245 | { |
|---|
| 1246 | case CLOCK_WITHOUT_SEC: |
|---|
| 1247 | if (conf.clock_format == CLOCK_FORMAT_24) |
|---|
| 1248 | sprintf(osd_buf, "%2u:%02u", hour, ttm->tm_min); |
|---|
| 1249 | else |
|---|
| 1250 | sprintf(osd_buf, "%2u:%02u%s", hour, ttm->tm_min,curr); |
|---|
| 1251 | z=0; |
|---|
| 1252 | break; |
|---|
| 1253 | case CLOCK_WITH_SEC: |
|---|
| 1254 | default: |
|---|
| 1255 | if (conf.clock_format == CLOCK_FORMAT_24) |
|---|
| 1256 | sprintf(osd_buf, "%2u:%02u:%02u", hour, ttm->tm_min,ttm->tm_sec); |
|---|
| 1257 | else |
|---|
| 1258 | sprintf(osd_buf, "%2u:%02u:%02u%s", hour, ttm->tm_min,ttm->tm_sec,curr); |
|---|
| 1259 | z=3; |
|---|
| 1260 | break; |
|---|
| 1261 | } |
|---|
| 1262 | if ((conf.show_clock==CLOCK_WITH_SEC || (conf.clock_format==CLOCK_FORMAT_12)) && (conf.clock_pos.x>=(z+w)*FONT_WIDTH) ) |
|---|
| 1263 | draw_string((x)?x-(z+w)*FONT_WIDTH:conf.clock_pos.x-(z+w)*FONT_WIDTH, (y)?y:conf.clock_pos.y, osd_buf, (cl)?cl:conf.osd_color); |
|---|
| 1264 | else |
|---|
| 1265 | draw_string((x)?x:conf.clock_pos.x, (y)?y:conf.clock_pos.y, osd_buf, (cl)?cl:conf.osd_color); |
|---|
| 1266 | } |
|---|
| 1267 | |
|---|
| 1268 | |
|---|
| 1269 | void gui_osd_draw_seconds() { |
|---|
| 1270 | unsigned long t; |
|---|
| 1271 | static struct tm *ttm; |
|---|
| 1272 | |
|---|
| 1273 | t = time(NULL); |
|---|
| 1274 | ttm = localtime(&t); |
|---|
| 1275 | sprintf(osd_buf, "%02u", ttm->tm_sec); |
|---|
| 1276 | if (conf.clock_pos.x<4*FONT_WIDTH){ |
|---|
| 1277 | draw_string(conf.clock_pos.x, conf.clock_pos.y, osd_buf, conf.osd_color); |
|---|
| 1278 | } |
|---|
| 1279 | else |
|---|
| 1280 | { |
|---|
| 1281 | draw_string(conf.clock_pos.x+(3*FONT_WIDTH), conf.clock_pos.y, osd_buf, conf.osd_color); |
|---|
| 1282 | } |
|---|
| 1283 | |
|---|
| 1284 | |
|---|
| 1285 | } |
|---|
| 1286 | |
|---|
| 1287 | void gui_osd_draw_movie_time_left() { |
|---|
| 1288 | |
|---|
| 1289 | static int card_used, init_space, elapsed, avg_use, time_left; |
|---|
| 1290 | static long init_time; |
|---|
| 1291 | static int record_running = 0; |
|---|
| 1292 | static int init = 0; |
|---|
| 1293 | static unsigned int skipcalls = 1; |
|---|
| 1294 | unsigned int hour=0, min=0, sec=0; |
|---|
| 1295 | int mode_video = MODE_IS_VIDEO(m); |
|---|
| 1296 | |
|---|
| 1297 | |
|---|
| 1298 | #if CAM_CHDK_HAS_EXT_VIDEO_MENU |
|---|
| 1299 | if (mode_video || movie_status > 1) { |
|---|
| 1300 | // if manual adjust, show the field item to be adjusted |
|---|
| 1301 | // if any value overriden, show the override value |
|---|
| 1302 | #if !CAM_VIDEO_QUALITY_ONLY |
|---|
| 1303 | if ((conf.video_mode == 0 && conf.fast_movie_quality_control==1) || conf.video_bitrate != VIDEO_DEFAULT_BITRATE) { |
|---|
| 1304 | // gui_print_osd_state_string_chr("Bitrate: ",video_bitrate_strings[conf.video_bitrate]); |
|---|
| 1305 | sprintf(osd_buf3, "Bit:%5s",video_bitrate_strings[conf.video_bitrate]); |
|---|
| 1306 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+2*FONT_HEIGHT, osd_buf3, conf.osd_color); |
|---|
| 1307 | } |
|---|
| 1308 | #endif |
|---|
| 1309 | if ((conf.video_mode == 1 && conf.fast_movie_quality_control==1) || conf.video_quality != VIDEO_DEFAULT_QUALITY) { |
|---|
| 1310 | // gui_print_osd_state_string_int("Quality: ",conf.video_quality); |
|---|
| 1311 | sprintf(osd_buf4, "Qual:%2i",conf.video_quality); |
|---|
| 1312 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+3*FONT_HEIGHT, osd_buf4, conf.osd_color); |
|---|
| 1313 | } |
|---|
| 1314 | // everything else is for stills |
|---|
| 1315 | if(mode_video) |
|---|
| 1316 | return; |
|---|
| 1317 | } |
|---|
| 1318 | #endif |
|---|
| 1319 | |
|---|
| 1320 | if (movie_reset == 1) |
|---|
| 1321 | { |
|---|
| 1322 | init = 0; |
|---|
| 1323 | movie_reset = 0; |
|---|
| 1324 | } |
|---|
| 1325 | if (movie_status > 1) record_running = 1; |
|---|
| 1326 | else |
|---|
| 1327 | {record_running = 0; |
|---|
| 1328 | init = 0; |
|---|
| 1329 | } |
|---|
| 1330 | |
|---|
| 1331 | if (record_running == 1 && init == 0) |
|---|
| 1332 | { |
|---|
| 1333 | init = 1; |
|---|
| 1334 | init_space = GetFreeCardSpaceKb(); |
|---|
| 1335 | init_time = get_tick_count(); |
|---|
| 1336 | } |
|---|
| 1337 | if (init == 1) |
|---|
| 1338 | { |
|---|
| 1339 | |
|---|
| 1340 | card_used = init_space - GetFreeCardSpaceKb(); |
|---|
| 1341 | elapsed = (int) ( get_tick_count() - init_time ) / 1000; |
|---|
| 1342 | avg_use = card_used / elapsed; // running average Kb/sec |
|---|
| 1343 | time_left = (GetFreeCardSpaceKb() / avg_use); |
|---|
| 1344 | hour = time_left / 3600; |
|---|
| 1345 | min = (time_left % 3600) / 60; |
|---|
| 1346 | sec = (time_left % 3600) % 60; |
|---|
| 1347 | |
|---|
| 1348 | if (elapsed<1) |
|---|
| 1349 | { |
|---|
| 1350 | sprintf(osd_buf, "Calc..."); |
|---|
| 1351 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1352 | } |
|---|
| 1353 | |
|---|
| 1354 | if (--skipcalls ==0) { |
|---|
| 1355 | if (elapsed>1) |
|---|
| 1356 | { |
|---|
| 1357 | if (conf.show_movie_time == 3){ |
|---|
| 1358 | sprintf(osd_buf, "%04d KB/s", avg_use); |
|---|
| 1359 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1360 | sprintf(osd_buf2, "-%02d:%02d:%02d", hour, min, sec); |
|---|
| 1361 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y+FONT_HEIGHT, osd_buf2, conf.osd_color); |
|---|
| 1362 | } |
|---|
| 1363 | if (conf.show_movie_time == 2) |
|---|
| 1364 | {sprintf(osd_buf, "%04d KB/s", avg_use); |
|---|
| 1365 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1366 | } |
|---|
| 1367 | if (conf.show_movie_time == 1) |
|---|
| 1368 | { |
|---|
| 1369 | sprintf(osd_buf, "-%02d:%02d:%02d", hour, min, sec); |
|---|
| 1370 | draw_string( conf.mode_video_pos.x, conf.mode_video_pos.y, osd_buf, conf.osd_color); |
|---|
| 1371 | } |
|---|
| 1372 | } |
|---|
| 1373 | |
|---|
| 1374 | skipcalls = conf.show_movie_refresh*5; |
|---|
| 1375 | } |
|---|
| 1376 | } |
|---|
| 1377 | } |
|---|
| 1378 | |
|---|
| 1379 | void gui_osd_draw_ev() { |
|---|
| 1380 | static char *s[6]={" ", "1/6", "1/3", "1/2", "2/3", "5/6"}; |
|---|
| 1381 | short ev=shooting_get_prop(PROPCASE_EV_CORRECTION_1); |
|---|
| 1382 | if (ev/96 || (ev==0)) sprintf(osd_buf, "EV: %d %s", abs(ev/96), s[abs(ev/16%6)]); |
|---|
| 1383 | else sprintf(osd_buf, "EV: %s ", s[abs(ev/16%6)]); |
|---|
| 1384 | if (ev>0) osd_buf[4]='+'; else if (ev<0) osd_buf[4]='-'; |
|---|
| 1385 | draw_string(conf.mode_ev_pos.x, conf.mode_ev_pos.y, osd_buf, conf.osd_color); |
|---|
| 1386 | |
|---|
| 1387 | } |
|---|
| 1388 | |
|---|
| 1389 | |
|---|
| 1390 | void gui_osd_draw_temp() { |
|---|
| 1391 | if (conf.show_temp == 1) |
|---|
| 1392 | { |
|---|
| 1393 | if (conf.temperature_unit == 0) |
|---|
| 1394 | { |
|---|
| 1395 | sprintf(osd_buf," opt: %i°",get_optical_temp()); |
|---|
| 1396 | } |
|---|
| 1397 | else |
|---|
| 1398 | { |
|---|
| 1399 | sprintf(osd_buf,"opt: %i°",(get_optical_temp()*18+320)/10); |
|---|
| 1400 | } |
|---|
| 1401 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1402 | } |
|---|
| 1403 | if (conf.show_temp==2) |
|---|
| 1404 | { |
|---|
| 1405 | if (conf.temperature_unit == 0) |
|---|
| 1406 | { |
|---|
| 1407 | sprintf(osd_buf," ccd: %i°",get_ccd_temp()); |
|---|
| 1408 | } |
|---|
| 1409 | else |
|---|
| 1410 | { |
|---|
| 1411 | sprintf(osd_buf,"ccd: %i°",(get_ccd_temp()*18+320)/10); |
|---|
| 1412 | } |
|---|
| 1413 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1414 | } |
|---|
| 1415 | if (conf.show_temp==3) |
|---|
| 1416 | { |
|---|
| 1417 | if (conf.temperature_unit == 0) |
|---|
| 1418 | { |
|---|
| 1419 | sprintf(osd_buf," batt:%i°",get_battery_temp()); |
|---|
| 1420 | } |
|---|
| 1421 | else |
|---|
| 1422 | { |
|---|
| 1423 | sprintf(osd_buf,"batt:%i°",(get_battery_temp()*18+320)/10); |
|---|
| 1424 | } |
|---|
| 1425 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1426 | } |
|---|
| 1427 | if (conf.show_temp==4) |
|---|
| 1428 | { |
|---|
| 1429 | if (conf.temperature_unit == 0) |
|---|
| 1430 | { |
|---|
| 1431 | sprintf(osd_buf," opt: %i°",get_optical_temp()); |
|---|
| 1432 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1433 | sprintf(osd_buf," ccd: %i°",get_ccd_temp()); |
|---|
| 1434 | draw_string(conf.temp_pos.x, conf.temp_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1435 | sprintf(osd_buf," batt:%i°",get_battery_temp()); |
|---|
| 1436 | draw_string(conf.temp_pos.x, conf.temp_pos.y+2*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1437 | } |
|---|
| 1438 | else |
|---|
| 1439 | { |
|---|
| 1440 | sprintf(osd_buf,"opt: %i°",(get_optical_temp()*18+320)/10); |
|---|
| 1441 | draw_string(conf.temp_pos.x, conf.temp_pos.y, osd_buf, conf.osd_color); |
|---|
| 1442 | sprintf(osd_buf,"ccd: %i°",(get_ccd_temp()*18+320)/10); |
|---|
| 1443 | draw_string(conf.temp_pos.x, conf.temp_pos.y+FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1444 | sprintf(osd_buf,"batt:%i°",(get_battery_temp()*18+320)/10); |
|---|
| 1445 | draw_string(conf.temp_pos.x, conf.temp_pos.y+2*FONT_HEIGHT, osd_buf, conf.osd_color); |
|---|
| 1446 | } |
|---|
| 1447 | } |
|---|
| 1448 | } |
|---|
| 1449 | |
|---|
| 1450 | |
|---|
| 1451 | |
|---|
| 1452 | //------------------------------------------------------------------- |
|---|
| 1453 | #if CAM_EV_IN_VIDEO |
|---|
| 1454 | void gui_osd_draw_ev_video(int visible){ |
|---|
| 1455 | int x0=conf.ev_video_pos.x, y0=conf.ev_video_pos.y; |
|---|
| 1456 | int i, deltax; |
|---|
| 1457 | |
|---|
| 1458 | draw_filled_rect(x0,y0,x0+70,y0+24, visible? ((conf.osd_color&0xFF00))|(conf.osd_color>>8): COLOR_TRANSPARENT); |
|---|
| 1459 | |
|---|
| 1460 | if (!visible) { return; } |
|---|
| 1461 | |
|---|
| 1462 | for (i=0;i<9;i++) draw_line(x0+2+i*8, y0+12, x0+2+i*8, y0+12-(i&1 ? 5 : 10), conf.osd_color); |
|---|
| 1463 | for (i=0;i<9;i++) draw_line(x0+2+i*8+1, y0+12, x0+2+i*8+1, y0+12-(i&1 ? 5 : 10), conf.osd_color); |
|---|
| 1464 | |
|---|
| 1465 | deltax=8*get_ev_video(); |
|---|
| 1466 | |
|---|
| 1467 | x0+=deltax; |
|---|
| 1468 | |
|---|
| 1469 | draw_line(x0+34,y0+16,x0+34,y0+22,conf.osd_color); |
|---|
| 1470 | draw_line(x0+35,y0+16,x0+35,y0+22,conf.osd_color); |
|---|
| 1471 | |
|---|
| 1472 | draw_line(x0+32,y0+19,x0+32,y0+22,conf.osd_color); |
|---|
| 1473 | draw_line(x0+33,y0+18,x0+33,y0+22,conf.osd_color); |
|---|
| 1474 | draw_line(x0+36,y0+18,x0+36,y0+22,conf.osd_color); |
|---|
| 1475 | draw_line(x0+37,y0+19,x0+37,y0+22,conf.osd_color); |
|---|
| 1476 | |
|---|
| 1477 | } |
|---|
| 1478 | #endif |
|---|