char *philips_summary () { PhilipsCfgInfo *pcfginfo; int error; char tmp[128]; /* initialize camera and grab configuration information */ if (philips_open_camera() == 0) { error_dialog ( "Could not open camera." ); return ( NULL ); } if ( (pcfginfo = philips_getcfginfo ( &error )) == NULL ) { error_dialog ( "Can't get camera configuration." ); philips_close_camera(); return ( NULL ); } philips_close_camera(); sprintf ( philips_summary_string, "%s\n\n", philips_model(cameraid) ); sprintf ( tmp, "Number of pictures: %ld\n", pcfginfo->picts ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Memory : %d/%d bytes\n", pcfginfo->a_memory, pcfginfo->memory ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Copyright String : %s\n", pcfginfo->copyright ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Resolution : %d\n", pcfginfo->resolution ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Compression: %d\n", pcfginfo->compression ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera White level: %d\n", pcfginfo->white ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Exposure : %d\n", pcfginfo->exposure ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Record Mode: %d\n", pcfginfo->mode ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Flash Mode : %d\n", pcfginfo->flash ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Macro : %d\n", pcfginfo->macro ); strcat ( philips_summary_string, tmp ); sprintf ( tmp, "Camera Zoom Level : %d\n", pcfginfo->zoom ); strcat ( philips_summary_string, tmp ); free ( pcfginfo ); return ( philips_summary_string ); }
int philips_delete_picture (int picNum) { if (philips_open_camera() == 0) { error_dialog("Could not open camera."); return (0); } philips_deletepict(picNum); philips_close_camera(); return (1); }
int philips_number_of_pictures () { long num_pictures_taken = 0; if ( philips_open_camera() == 0 ) { error_dialog("Could not open camera."); return (0); } if ( philips_getnpicts ( &num_pictures_taken ) == -1) num_pictures_taken = 0; philips_close_camera(); return ((int)num_pictures_taken); }
int philips_take_picture () { long picture_number = 0; if ( philips_open_camera() == 0 ) { error_dialog("Could not open camera."); return (0); } if ( philips_takepicture() == 0 ) { philips_getpictnum ( &picture_number ); } philips_close_camera(); return ((int)picture_number); }
struct Image *philips_get_preview () { long picNum = 0; int Size; char tmStamp[25], fileName[20]; struct Image *image; if ( philips_open_camera() == 0 ) { error_dialog("Could not open camera."); return ( NULL ); } if ( (image = (struct Image *)malloc ( sizeof(struct Image) )) == NULL ) { error_dialog("Could not allocate memory for image structure."); return ( NULL ); } if ( philips_takepicture() == 0 ) { philips_set_mode (0); sleep (1); philips_getpictnum ( &picNum ); philips_getpictsize ( picNum, &Size ); philips_getpictdate ( picNum, tmStamp ); image->image = (void *)malloc ( Size ); image->image_size = Size; image->image_info_size = 0; image->image_info = NULL; strcpy ( image->image_type, "jpg" ); philips_getpict ( picNum, (char *)image->image, fileName ); philips_deletepict ( picNum ); printf ( "Captured picture %d, %s, %ld, %s\n", picNum, fileName, Size, tmStamp ); } else { free ( image ) ; image = NULL; } philips_close_camera(); return ( image ); }
struct Image *philips_get_picture (int picNum, int thumbnail) { int Size; char *picData, *thumbData, header[14], fileName[20]; struct Image *image; if ( picNum == 0 ) /* no such picture, abort... */ return ( NULL ); if (philips_open_camera() == 0) { error_dialog("Could not open camera."); return ( NULL ); } if ( (image = (struct Image *)malloc ( sizeof(struct Image) )) == NULL ) { error_dialog("Could not allocate memory for image structure."); return ( NULL ); } if ( thumbnail ) { picData = philips_getthumb ( picNum, &Size ); if ( ! picData ) { error_dialog ( "Could not read thumbnail." ); return ( NULL ); } image->image_size = Size; image->image_info = NULL; image->image_info_size = 0; if ( cameraid != RDC_5000 ) { /* thumbnail format unknown, guess */ thumbData = philips_processThumb ( picData, &Size ); free ( picData ); image->image = thumbData; strcpy ( image->image_type, "pgm" ); } else { /* RDC-5000 uses JPEG thumbnails */ image->image = picData; strcpy ( image->image_type, "jpg" ); } } else { /* Not a thumbnail */ if ( philips_getpictsize ( picNum, &Size ) == 0 ) { image->image = (char *)malloc ( Size ); image->image_size = Size; image->image_info_size = 0; image->image_info = NULL; strcpy ( image->image_type, "jpg" ); philips_getpict ( picNum, (char *)image->image, fileName ); } else { image->image = NULL; image->image_size = 0; image->image_info_size = 0; image->image_info = NULL; } } philips_close_camera(); return ( image ); }
int philips_configure () { struct P_CONFIG_CONTROLS controls; PhilipsCfgInfo *pcfginfo; int error; GtkWidget *dialog; GtkWidget *notebook; GtkWidget *button; char *info, title[128]; /* initialize camera and grab configuration information */ if (philips_open_camera() == 0) { error_dialog ( "Could not open camera." ); return 0; } if ( (pcfginfo = philips_getcfginfo ( &error )) == NULL ) { error_dialog ( "Can't get camera configuration." ); philips_close_camera(); return ( 0 ); } philips_close_camera(); update_progress(12); sprintf ( title, "Configure Camera %s", philips_model(cameraid) ); info = (char *)malloc(2048); /* create a new dialog box */ dialog = gtk_dialog_new(); gtk_window_set_title (GTK_WINDOW(dialog), title); gtk_container_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 10); /* create a new notebook, place the position of the tabs */ notebook = gtk_notebook_new (); gtk_notebook_set_tab_pos ( GTK_NOTEBOOK(notebook), GTK_POS_TOP ); gtk_widget_show ( notebook ); gtk_container_add ( GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), notebook ); /* add a page to the notebook */ philips_cfg_page1 ( notebook, &controls, pcfginfo ); update_progress(25); philips_cfg_page2 ( notebook, &controls, pcfginfo ); update_progress(50); philips_cfg_page3 ( notebook, &controls, pcfginfo ); update_progress(75); philips_cfg_page4 ( notebook, &controls, pcfginfo ); /* create an OK button */ button = gtk_button_new_with_label ( " OK " ); gtk_signal_connect_object ( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(dialog) ); gtk_box_pack_end ( GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, FALSE, 0 ); gtk_widget_show ( button ); /* create a Cancel button */ button = gtk_button_new_with_label ( " Cancel " ); gtk_signal_connect_object ( GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(dialog) ); gtk_box_pack_end ( GTK_BOX(GTK_DIALOG(dialog)->action_area), button, TRUE, FALSE, 0 ); gtk_widget_show ( button ); update_progress(100); gtk_widget_show ( dialog ); update_status ( "Done." ); update_progress ( 0 ); while (GTK_WIDGET_VISIBLE(dialog)) gtk_main_iteration(); /* if (strcmp("Cancel", (char*)gtk_object_get_data(GTK_OBJECT(dialog), "button"))==0) { printf ( "Cancel button pressed, return 1\n" ); return 1; } */ printf ( "Done with config, return 1\n" ); return 1; }