diff options
author | Chris Pinkham <cpinkham@infi.net> | 2001-09-24 01:10:11 +0000 |
---|---|---|
committer | Chris Pinkham <cpinkham@infi.net> | 2001-09-24 01:10:11 +0000 |
commit | 58cd54dfdd7875a14c62834dda45d54121abd999 (patch) | |
tree | 428f5fac96ec2a46c3a670ed7fd594c010fcce6e /camlibs/jamcam/library.c | |
parent | 9bc04e4d3953e69567bf8c121c948d8a9b214b3c (diff) | |
download | libgphoto2-58cd54dfdd7875a14c62834dda45d54121abd999.tar.gz |
* camlibs/jamcam/jamcam.c
camlibs/jamcam/library.h
camlibs/jamcam/library.c: Added support for low-res images.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2314 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/jamcam/library.c')
-rw-r--r-- | camlibs/jamcam/library.c | 110 |
1 files changed, 93 insertions, 17 deletions
diff --git a/camlibs/jamcam/library.c b/camlibs/jamcam/library.c index 61fbecdf8..c609fd42d 100644 --- a/camlibs/jamcam/library.c +++ b/camlibs/jamcam/library.c @@ -32,6 +32,9 @@ #include "library.h" +struct jamcam_file jamcam_files[1024]; +static int jamcam_count = 0; + static int jamcam_set_usb_mem_pointer( Camera *camera, int position ) { char reply[4]; @@ -56,12 +59,16 @@ static int jamcam_set_usb_mem_pointer( Camera *camera, int position ) { int jamcam_file_count (Camera *camera) { char buf[16]; - char reply[16]; + unsigned char reply[16]; int position = 0; - int count = 0; + int data_incr; + int width; + int height; gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_file_count"); + jamcam_count = 0; + memset( buf, 0, sizeof( buf )); switch( camera->port->type ) { @@ -76,10 +83,24 @@ int jamcam_file_count (Camera *camera) { jamcam_read_packet( camera, reply, 16 ); - while((unsigned char)reply[0] != 0xff ) { - count++; + while( reply[0] != 0xff ) { + width = (reply[5] * 256) + reply[4]; + height = (reply[7] * 256) + reply[6]; + + data_incr = 0; + data_incr += reply[8]; + data_incr += reply[9] * 256; + data_incr += reply[10] * 256 * 256; + data_incr += reply[11] * 256 * 256 * 256; - position += DATA_INCR; + jamcam_files[jamcam_count].position = position; + jamcam_files[jamcam_count].width = width; + jamcam_files[jamcam_count].height = height; + jamcam_files[jamcam_count].data_incr = data_incr; + + jamcam_count++; + + position += data_incr; buf[4] = ( position ) & 0xff; buf[5] = ( position >> 8 ) & 0xff; @@ -96,19 +117,35 @@ int jamcam_file_count (Camera *camera) { gp_port_read (camera->port, reply, 0x10 ); + width = (reply[13] * 256) + reply[12]; + height = (reply[15] * 256) + reply[14]; + jamcam_set_usb_mem_pointer( camera, position + 8 ); gp_port_read (camera->port, reply, 0x10 ); while((unsigned char)reply[0] != 0xff ) { - count++; + data_incr = 0; + data_incr += reply[0]; + data_incr += reply[1] * 256; + data_incr += reply[2] * 256 * 256; + data_incr += reply[3] * 256 * 256 * 256; - position += DATA_INCR; + jamcam_files[jamcam_count].position = position; + jamcam_files[jamcam_count].width = width; + jamcam_files[jamcam_count].height = height; + jamcam_files[jamcam_count].data_incr = data_incr; + jamcam_count++; + + position += data_incr; jamcam_set_usb_mem_pointer( camera, position ); gp_port_read (camera->port, reply, 0x10 ); + width = (reply[13] * 256) + reply[12]; + height = (reply[15] * 256) + reply[14]; + jamcam_set_usb_mem_pointer( camera, position + 8 ); gp_port_read (camera->port, reply, 0x10 ); @@ -116,7 +153,9 @@ int jamcam_file_count (Camera *camera) { break; } - return( count ); + gp_debug_printf (GP_DEBUG_LOW, "jamcam", + "*** returning jamcam_count = %d", jamcam_count); + return( jamcam_count ); } int jamcam_fetch_memory( Camera *camera, char *data, int start, int length ) { @@ -188,30 +227,69 @@ int jamcam_request_image( Camera *camera, char *buf, int *len, int number ) { *len = DATA_SIZE; - position = ( DATA_INCR * ( number - 1 )) + 0x10; + position = jamcam_files[number].position + 0x10; + *len = jamcam_files[number].width * jamcam_files[number].height; - jamcam_set_usb_mem_pointer( camera, position ); - gp_port_read (camera->port, buf, 120 ); + if ( camera->port->type == GP_PORT_USB ) { + jamcam_set_usb_mem_pointer( camera, position ); + gp_port_read (camera->port, buf, 120 ); - if ( camera->port->type == GP_PORT_USB ) position += 8; + } return( jamcam_fetch_memory( camera, buf, position, *len )); } +struct jamcam_file *jamcam_file_info(Camera *camera, int number) +{ + return( &jamcam_files[number] ); +} + int jamcam_request_thumbnail( Camera *camera, char *buf, int *len, int number ) { + char line[600]; char packet[16]; int position; + int x, y; + char *ptr; gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_request_thumbnail"); memset( packet, 0, sizeof( packet )); - position = ( DATA_INCR * ( number - 1 )) + 0x10; + position = jamcam_files[number].position + 0x10; + + *len = 4800; - *len = 600; + ptr = buf; - return( jamcam_fetch_memory( camera, buf, position, 600 )); + /* fetch thumbnail lines and build the thumbnail */ + position += 10 * jamcam_files[number].width; + for( y = 0 ; y < 60 ; y++ ) { + jamcam_fetch_memory( camera, line, position, + jamcam_files[number].width ); + + if ( jamcam_files[number].width == 600 ) { + for( x = 22; x < 578 ; x += 7 ) { + *(ptr++) = line[x]; + } + position += 7 * 600; + } else { + for( x = 0; x < 320 ; ) { + *(ptr++) = line[x]; + x += 3; + *(ptr++) = line[x]; + x += 5; + } + + if ( y % 2 ) { + position += 5 * 320; + } else { + position += 3 * 320; + } + } + } + + return( GP_OK ); } int jamcam_write_packet (Camera *camera, char *packet, int length) { @@ -299,8 +377,6 @@ int jamcam_enq (Camera *camera) gp_port_read( camera->port, (char *)buf, 0x0c ); - fprintf( stderr, "buf = %x %x %x %x\n", buf[0], buf[1], buf[2], buf[3] ); - if ( !strncmp( (char *)buf, "KB00", 4 )) { return (GP_OK); } else if (( buf[0] == 0xf0 ) && |