diff --git a/ChangeLog b/ChangeLog index 7c0a14f49..841c3dec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-09-03 Chris Pinkham + + * camlibs/panasonic/coolshot/README + camlibs/panasonic/coolshot/coolshot.c + camlibs/panasonic/coolshot/library.h + camlibs/panasonic/coolshot/library.c: added thumbnail support. + 2001-09-02 Chris Pinkham * camlibs/panasonic/coolshot/coolshot.c diff --git a/camlibs/panasonic/coolshot/README b/camlibs/panasonic/coolshot/README index a7cc25189..38c022755 100644 --- a/camlibs/panasonic/coolshot/README +++ b/camlibs/panasonic/coolshot/README @@ -14,7 +14,7 @@ For questions/comments, email the library author: TODO List --------- - file upload capability -- figure out thumbnail data format +- fix thumbnail download to use additional data supplied by camera - better error checking ("fixme"s) & recovery - modify coolshot_file_count to return GP_ code and take *count as argument diff --git a/camlibs/panasonic/coolshot/coolshot.c b/camlibs/panasonic/coolshot/coolshot.c index d4b36344d..97b4362e3 100644 --- a/camlibs/panasonic/coolshot/coolshot.c +++ b/camlibs/panasonic/coolshot/coolshot.c @@ -61,6 +61,8 @@ static char *coolshot_cameras[] = { int camera_id (CameraText *id) { + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_id"); + strcpy (id->text, "coolshot"); return (GP_OK); @@ -72,6 +74,8 @@ int camera_abilities (CameraAbilitiesList *list) char *ptr; CameraAbilities *a; + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_abilities"); + ptr = coolshot_cameras[x++]; while (*ptr) { gp_abilities_new( &a ); @@ -86,7 +90,7 @@ int camera_abilities (CameraAbilitiesList *list) /* fixme, need to set these operations lists to correct values */ a->operations = GP_OPERATION_NONE; - a->file_operations = GP_FILE_OPERATION_NONE; + a->file_operations = GP_FILE_OPERATION_PREVIEW; /* fixme, believe supports GP_FOLDER_PUT_FILE */ a->folder_operations = GP_FOLDER_OPERATION_NONE; @@ -101,7 +105,7 @@ int camera_abilities (CameraAbilitiesList *list) static int camera_start (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_start"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_start"); /* coolshot_sb sets to default speed if speed == 0 */ CHECK (coolshot_sb (camera, camera->port_info->speed)); @@ -110,7 +114,7 @@ static int camera_start (Camera *camera) static int camera_stop (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_stop"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_stop"); CHECK (coolshot_sb( camera, DEFAULT_SPEED)); return (GP_OK); @@ -122,7 +126,7 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int count; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** file_list_func"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* file_list_func"); gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder); CHECK (camera_start (camera)); @@ -138,7 +142,7 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int n; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** get_info_func"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* get_info_func"); gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder); gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** filename: %s",filename); @@ -159,7 +163,7 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, static int camera_exit (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_exit"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_exit"); return (GP_OK); } @@ -187,20 +191,19 @@ static int camera_file_get (Camera *camera, const char *folder, switch (type) { case GP_FILE_TYPE_PREVIEW: - /* fixme, need to figure out thumbnail format & munge it into a jpeg CHECK (coolshot_request_thumbnail (camera, data, &size, n)); - */ - CHECK (coolshot_request_image (camera, data, &size, n)); + CHECK (coolshot_build_thumbnail (data, &size)); + CHECK (gp_file_set_mime_type (file, GP_MIME_PPM)); break; case GP_FILE_TYPE_NORMAL: CHECK (coolshot_request_image (camera, data, &size, n)); + CHECK (gp_file_set_mime_type (file, GP_MIME_JPEG)); break; default: return (GP_ERROR_NOT_SUPPORTED); } - CHECK (gp_file_set_mime_type (file, GP_MIME_JPEG)); CHECK (gp_file_set_name (file, filename)); CHECK (gp_file_append (file, data, size)); @@ -212,7 +215,7 @@ static int camera_summary (Camera *camera, CameraText *summary) int count; char tmp[1024]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_summary"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_summary"); CHECK (camera_start (camera)); @@ -227,7 +230,7 @@ static int camera_summary (Camera *camera, CameraText *summary) static int camera_manual (Camera *camera, CameraText *manual) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_manual"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_manual"); strcpy (manual->text, _("Some notes:\n" " No notes here yet.\n")); @@ -236,7 +239,7 @@ static int camera_manual (Camera *camera, CameraText *manual) static int camera_about (Camera *camera, CameraText *about) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_about"); + gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_about"); strcpy (about->text, _("coolshot library v" COOLSHOT_VERSION diff --git a/camlibs/panasonic/coolshot/library.c b/camlibs/panasonic/coolshot/library.c index 23643a3d3..148f65e44 100644 --- a/camlibs/panasonic/coolshot/library.c +++ b/camlibs/panasonic/coolshot/library.c @@ -592,3 +592,75 @@ int coolshot_enq (Camera *camera) return (GP_ERROR_IO_TIMEOUT); } + +int coolshot_build_thumbnail (char *data, int *size) +{ + char thumbnail[32768]; + char prev_line[256]; + char *ptr; + char *pptr; + char *src; + int length; + int x, y, r, g, b; + int ynd; + int loop; + + strcpy( thumbnail, + "P6\n" + "# CREATOR: gphoto2, panasonic coolshot library\n" + "80 60\n" + "255\n" ); + + length = strlen( thumbnail ); + ptr = thumbnail + length; + pptr = prev_line; + + src = data; + x = y = ynd = 1; + r = g = b = 128; + + for( loop = 0; loop < *size; loop++ ) { + if ( y == 81 ) { + x++; + y = 1; + + memcpy( ptr, prev_line, 240 ); + pptr = prev_line; + ptr += 240; + } + + if (( x % 2 ) == 1 ) { + if (( ynd % 2 ) == 1 ) { + r = *src; + } else { + g = *src; + } + } else { + if (( ynd % 2 ) == 1 ) { + g = *src; + } else { + b = *src; + } + } + + *(ptr++) = r; *(ptr++) = g; *(ptr++) = b; + *(pptr++) = r; *(pptr++) = g; *(pptr++) = b; + + *(ptr++) = r; *(ptr++) = g; *(ptr++) = b; + *(pptr++) = r; *(pptr++) = g; *(pptr++) = b; + + y += 2; + ynd++; + + src++; + } + + length += 80 * 60 * 3; + + memcpy( data, thumbnail, length ); + *size = length; + + return( GP_OK ); +} + + diff --git a/camlibs/panasonic/coolshot/library.h b/camlibs/panasonic/coolshot/library.h index 7fa0ff547..59597a24c 100644 --- a/camlibs/panasonic/coolshot/library.h +++ b/camlibs/panasonic/coolshot/library.h @@ -48,4 +48,4 @@ int coolshot_check_checksum( char *packet, int length ); int coolshot_request_image (Camera *camera, char *buf, int *len, int number); int coolshot_request_thumbnail (Camera *camera, char *buf, int *len, int number); int coolshot_download_image (Camera *camera, char *buf, int *len, int thumbnail); - +int coolshot_build_thumbnail (char *data, int *size);