void load_chdk_palette() { extern int active_palette_buffer; // Only load for the standard record and playback palettes if ((active_palette_buffer == 0) || (active_palette_buffer == 5)) { int *pal = (int*)vid_get_bitmap_active_palette(); if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62) { pal[CHDK_COLOR_BASE+0] = 0x3F3ADF62; // Red pal[CHDK_COLOR_BASE+1] = 0x3F26EA40; // Dark Red pal[CHDK_COLOR_BASE+2] = 0x3F4CD57F; // Light Red pal[CHDK_COLOR_BASE+3] = 0x3F73BFAE; // Green pal[CHDK_COLOR_BASE+4] = 0x3F4BD6CA; // Dark Green pal[CHDK_COLOR_BASE+5] = 0x3F95AB95; // Light Green pal[CHDK_COLOR_BASE+6] = 0x3F4766F0; // Blue pal[CHDK_COLOR_BASE+7] = 0x3F1250F3; // Dark Blue pal[CHDK_COLOR_BASE+8] = 0x3F7F408F; // Cyan pal[CHDK_COLOR_BASE+9] = 0x3F512D5B; // Magenta pal[CHDK_COLOR_BASE+10] = 0x3FA9A917; // Yellow pal[CHDK_COLOR_BASE+11] = 0x3F819137; // Dark Yellow pal[CHDK_COLOR_BASE+12] = 0x3FDED115; // Light Yellow extern char palette_control; palette_control = 1; vid_bitmap_refresh(); } } }
// TODO void load_chdk_palette(), palette_control not found // Function to load CHDK custom colors into active Canon palette void load_chdk_palette() { extern int active_palette_buffer; // Only load for the standard record and playback palettes // 0 = rec, 4 = func menu, 5 = playback, 6 = menu (play or rec), if ((active_palette_buffer == 0) || (active_palette_buffer == 5) || (active_palette_buffer == 4)) { int *pal = (int*)vid_get_bitmap_active_palette(); if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62) { pal[CHDK_COLOR_BASE+0] = 0x33ADF62; // Red pal[CHDK_COLOR_BASE+1] = 0x326EA40; // Dark Red pal[CHDK_COLOR_BASE+2] = 0x34CD57F; // Light Red pal[CHDK_COLOR_BASE+3] = 0x373BFAE; // Green pal[CHDK_COLOR_BASE+4] = 0x34BD6CA; // Dark Green pal[CHDK_COLOR_BASE+5] = 0x395AB95; // Light Green pal[CHDK_COLOR_BASE+6] = 0x34766F0; // Blue pal[CHDK_COLOR_BASE+7] = 0x31250F3; // Dark Blue pal[CHDK_COLOR_BASE+8] = 0x37F408F; // Cyan pal[CHDK_COLOR_BASE+9] = 0x3512D5B; // Magenta pal[CHDK_COLOR_BASE+10] = 0x3A9A917; // Yellow pal[CHDK_COLOR_BASE+11] = 0x3819137; // Dark Yellow pal[CHDK_COLOR_BASE+12] = 0x3DED115; // Light Yellow extern char palette_control; palette_control = 1; // note appears to be a bitmask, bit 2 is also used vid_bitmap_refresh(); } } }
/* 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; }