//------------------------------------------------------------------- color draw_get_pixel(coord x, coord y) { #ifndef THUMB_FW if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return 0; if (conf.rotate_osd) { #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY return bitmap_buffer[0][rotate_base - (y * camera_screen.buffer_width + ASPECT_XCORRECTION(x))]; #else return frame_buffer[0][rotate_base - (y * camera_screen.buffer_width + ASPECT_XCORRECTION(x))]; #endif } else { #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY return bitmap_buffer[0][y * camera_screen.buffer_width + ASPECT_XCORRECTION(x)]; #else return frame_buffer[0][y * camera_screen.buffer_width + ASPECT_XCORRECTION(x)]; #endif } #else // DIGIC 6 not supported return 0; #endif }
//------------------------------------------------------------------- void draw_hline(coord x, coord y, int len, color cl) { if ((y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return; if (x < 0) { len += x; x = 0; } if ((x + len) > camera_screen.width) len = camera_screen.width - x; if ((x == 0) && (y == 0)) { x++; len--; } // Skip guard pixel register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x); len = ASPECT_XCORRECTION(len); // Scale the line length if needed for (; len>0; len--, offset++) draw_pixel_proc(offset, cl); }
void draw_set_draw_proc(void (*pixel_proc)(unsigned int offset, color cl)) { draw_pixel_proc_norm = (pixel_proc)?pixel_proc:draw_pixel_std; if (conf.rotate_osd) { rotate_base = (camera_screen.height - 1) * camera_screen.buffer_width + ASPECT_XCORRECTION(camera_screen.width) - 1; draw_pixel_proc = draw_pixel_proc_rotated; } else { draw_pixel_proc = draw_pixel_proc_norm; } }
void draw_pixel_unrotated(coord x, coord y, color cl) { // Make sure pixel is on screen. Skip top left pixel if screen erase detection is on to avoid triggering the detector. if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height) || ((x == 0) && (y == 0))) return; else { register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x); draw_pixel_proc_norm(offset, cl); #if CAM_USES_ASPECT_CORRECTION draw_pixel_proc_norm(offset+1, cl); // Draw second pixel if screen scaling is needed #endif } }
#if defined(CAM_FORWARDMATRIX2) 1, { CAM_FORWARDMATRIX2 }, #else 0, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, #endif DNG_BADPIXEL_VALUE_LIMIT, }; _cam_screen camera_screen = { CAM_SCREEN_VERSION, CAM_SCREEN_WIDTH, CAM_SCREEN_HEIGHT, CAM_SCREEN_WIDTH * CAM_SCREEN_HEIGHT, ASPECT_XCORRECTION(CAM_SCREEN_WIDTH), CAM_BITMAP_WIDTH, CAM_BITMAP_HEIGHT, CAM_BITMAP_WIDTH * CAM_BITMAP_HEIGHT, EDGE_HMARGIN, CAM_TS_BUTTON_BORDER, #if defined(CAM_ZEBRA_NOBUF) 1, #else 0, #endif CAM_USES_ASPECT_CORRECTION, #if defined(CAM_HAS_VARIABLE_ASPECT) 1, #else 0, #endif CAM_MENU_BORDERWIDTH, };
/* send selected data for live view returns 0 on error, total size on success should only be called from ptp handler */ int live_view_get_data(ptp_data *data, int flags) { int vp_size = 0,bm_size = 0,pal_size = 0; lv_data_header *lv; lv_framebuffer_desc *vp; lv_framebuffer_desc *bm; // determine if we will send palette so it can go in one send if ( flags & LV_TFR_PALETTE ) // bitmap palette { // if no palette, will be set to zero pal_size = vid_get_palette_size(); } // one contiguous buffer to allow a single send call int buf_size = sizeof(lv_data_header) + sizeof(lv_framebuffer_desc)*2 + pal_size; void *buf = malloc(buf_size); if(!buf) { return 0; } lv = buf; lv->vp_desc_start = sizeof(lv_data_header); lv->bm_desc_start = lv->vp_desc_start+sizeof(lv_framebuffer_desc); vp = buf + lv->vp_desc_start; bm = buf + lv->bm_desc_start; lv->version_major = LIVE_VIEW_VERSION_MAJOR; lv->version_minor = LIVE_VIEW_VERSION_MINOR; lv->lcd_aspect_ratio = vid_get_aspect_ratio(); lv->palette_type = vid_get_palette_type(); lv->palette_data_start = 0; vp->fb_type = LV_FB_YUV8; vp->buffer_width = vid_get_viewport_buffer_width_proper(); vp->visible_width = vid_get_viewport_width_proper(); vp->visible_height = vid_get_viewport_height_proper(); vp->margin_left = vid_get_viewport_display_xoffset_proper(); vp->margin_top = vid_get_viewport_display_yoffset_proper(); // TODO returning margins from lib.c might be better // can end up with negative if size and offset sources don't update at exactly the same time vp->margin_right = vid_get_viewport_fullscreen_width() - vp->visible_width - vp->margin_left; vp->margin_bot = vid_get_viewport_fullscreen_height() - vp->visible_height - vp->margin_top; bm->fb_type = LV_FB_PAL8; bm->buffer_width = camera_screen.buffer_width; bm->margin_left = 0; bm->margin_top = 0; bm->margin_right = 0; bm->margin_bot = 0; bm->visible_width = ASPECT_XCORRECTION(camera_screen.width); bm->visible_height = camera_screen.height; vp->data_start = 0; bm->data_start = 0; int total_size = buf_size; void *vp_fb = vid_get_viewport_active_buffer(); // Add viewport details if requested, and not null if ( flags & LV_TFR_VIEWPORT && vp_fb) // live buffer { vp->data_start = total_size; vp_size = (vp->buffer_width*vp->visible_height*6)/4; total_size += vp_size; // offset to start of actual data vp_fb += vid_get_viewport_image_offset(); } // Add bitmap details if requested if ( flags & LV_TFR_BITMAP ) // bitmap buffer { bm->data_start = total_size; bm_size = bm->buffer_width*bm->visible_height; total_size += bm_size; } // Add palette detals if requested and available if ( pal_size ) // bitmap palette { lv->palette_data_start = buf_size - pal_size; memcpy(buf + lv->palette_data_start,vid_get_bitmap_active_palette(),pal_size); } // Send header structure (along with total size to be sent) data->send_data(data->handle,(char*)buf,buf_size,total_size,0,0,0); // Send viewport data if requested if ( vp_size ) { data->send_data(data->handle,vp_fb,vp_size,0,0,0,0); } // Send bitmap data if requested if ( bm_size ) { data->send_data(data->handle,vid_get_bitmap_active_buffer(),bm_size,0,0,0,0); } free(buf); return total_size; }