⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tools.c

📁 Coriander is a GUI for controlling a Digital Camera (in the sense of the IIDC specs issued by the 1
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (C) 2000-2004 Damien Douxchamps  <ddouxchamps@users.sf.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#include "coriander.h"  #ifdef HAVE_GDK_PIXBUFstatic char * coriander_icon_xpm[] = {"48 48 97 2","  	c None",". 	c #FF3333","+ 	c #47FF47","@ 	c #FF5151","# 	c #FF0000","$ 	c #FFE974","% 	c #FFE351","& 	c #FFDD26","* 	c #FFE248","= 	c #FFE76B","- 	c #00FF00","; 	c #FF1414","> 	c #FFDE2E",", 	c #FFE662","' 	c #3DFF3D",") 	c #0AFF0A","! 	c #FF0A0A","~ 	c #FF6E2C","{ 	c #ADEB33","] 	c #FF6110","^ 	c #A3E918","/ 	c #7AFF7A","( 	c #FF0801","_ 	c #FFB91F",": 	c #FFDF37","< 	c #FFEA7C","[ 	c #FFE140","} 	c #F4DE24","| 	c #1EFA04","1 	c #FF4F0D","2 	c #FFE55A","3 	c #8EEB15","4 	c #14FF14","5 	c #28FF28","6 	c #FF4747","7 	c #1EFF1E","8 	c #FF3D3D","9 	c #70FF70","0 	c #FF7F2F","a 	c #0AFD01","b 	c #70F010","c 	c #FF2828","d 	c #FFED8E","e 	c #5BFF5B","f 	c #5BF20D","g 	c #D6E21F","h 	c #FFCB22","i 	c #FF7B15","j 	c #FFD424","k 	c #3DF609","l 	c #FF5B5B","m 	c #FF1A04","n 	c #FFA71C","o 	c #E0E121","p 	c #33F807","q 	c #FFEB85","r 	c #EACB22","s 	c #473D0A","t 	c #332C07","u 	c #3D3509","v 	c #7A6A12","w 	c #D6B91F","x 	c #A38D18","y 	c #0A0801","z 	c #000000","A 	c #847213","B 	c #C1E51C","C 	c #AD9619","D 	c #141103","E 	c #C1A71C","F 	c #66580F","G 	c #E0C221","H 	c #51460C","I 	c #F4D424","J 	c #F4DD6B","K 	c #EAD262","L 	c #1E1AE4","M 	c #332CD3","N 	c #2823DC","O 	c #0000FF","P 	c #5151FF","Q 	c #3333FF","R 	c #0A0AFF","S 	c #6666FF","T 	c #AD9B8E","U 	c #7A6EB0","V 	c #6658A8","W 	c #1411ED","X 	c #E0C240","Y 	c #CCB051","Z 	c #99847C","` 	c #7A6A96"," .	c #473DC2","..	c #2826ED","+.	c #5B5BFF","@.	c #4747FF","#.	c #1414FF","                                                                                                ","                                                                                                ","                                                                                                ","                        .                                             +                         ","                    @ # #             $ % & & & & & & * =             - -                       ","                  ; # # # ;     = > & & & & & & & & & & & & & ,     ' - - )                     ","                ! # # # # # ~ & & & & & & & & & & & & & & & & & & { - - - - -                   ","              # # # # # # # # ] & & & & & & & & & & & & & & & & ^ - - - - - - - - /             ","            ! # # # # # # # # ( _ & & : =             < [ & & } | - - - - - - - - -             ","          ; # # # # # # # # # # 1 2                         $ 3 - - - - - - - - - - -           ","        @ # # # # # # # # # # # #                             4 - - - - - - - - - - - 5         ","        # # # # # # # # # # # # # @                         / - - - - - - - - - - - - - /       ","      6 # # # # # # # # # # # # # #                         ) - - - - - - - - - - - - - 7       ","          ; # # # # # # # # # # # # 8                     9 - - - - - - - - - - - - ) /         ","            0 # # # # # # # # # # # #                     ) - - - - - - - - - - a b             ","            & ] ( # # # # # # # # # # c     : & > % d   e - - - - - - - - - - f g &             ","          = & & h 1 # # # # # # # # ( i j & & & & & & & ^ | - - - - - - - k g & & & [           ","          > & & & 2   l # # # # # m n & & & & & & & & & & o p - - - - - ' q & & & & &           ","          & & & &         8 # # ( n & & & r s t u v w & & & o | - - 5       & & & & & d         ","        $ & & & :             c i & & & x y z z z z z A & & & B 4           2 & & & & *         ","        % & & & =               j & & x z z z t y z z z v & & &               & & & : 2         ","        & & & &                 & & r y z y & & & C D z z E & & =                               ","        & & & &               : & & s z z & & & & & & & & & & & &                               ","        & & & &               & & & t z t & & & & & & & & & & & &                               ","        & & & &               > & & u z y & & & & & & & & & & & &                               ","        & & & &               % & & v z z C & & & & & & & & & & &                               ","        & & & &               d & & w z z D & & & w F F F G & & ,                               ","        * & & & <               & & & A z z t F u y z z H & & &               & & : , q         ","        = & & & [               $ & & & v z z z z z z H I & & *             , & & & & [         ","          & & & &                 [ & & & E D z y s C & & & >               > & & & & <         ","          & & & & $                 [ & & & & & & & & & & >                 & & & & &           ","          , & & & &                   2 & & & & & & & & *                 : & & & & :           ","            & & & & ,                     J & & & & K                     & & & & & q           ","            * & & & &                       L M N O P                     % & & & >             ","              & & & & &                   Q O O O O R                       d & & d             ","              & & & & & >                 O O O O O O                           =               ","              [ & & & & & >               O O O O O O S                                         ","                  & & & & & & & > q     R O O O O O O O       : & %                             ","                    & & & & & & & & & T O O O O O O O O U > & & & & d                           ","                      : & & & & & & & V O O O O O O O O M & & & & & &                           ","                        , & & & & & & W O O O O O O O O O X & & & & & ,                         ","                            : & & & Y O O O O O O O O O O Z & & & > d                           ","                                [ & ` O O O O O O O O O O  .& : q                               ","                                    ..O O O O O O O O O O O                                     ","                                    O O O O O O O O O O O O                                     ","                                    O O O O O O O O O O O O +.                                  ","                                  @.O O O O O O O O O O O O #.                                  ","                                      S Q R O O O O O Q +.                                      "};#endifextern char* trigger_mode_list[4];extern char* channel_num_list[16];extern char* phy_speed_list[7];extern char* phy_delay_list[4];extern char* power_class_list[8];extern char* fps_label_list[NUM_FRAMERATES];voidGetFormat7Capabilities(camera_t* cam){  int i, f;  quadlet_t value;    if (dc1394_query_supported_formats(cam->camera_info.handle, cam->camera_info.id, &value)!=DC1394_SUCCESS)    MainError("Could not query supported formats");  else {    if (value & (0x1<<24)) { // is format7 supported?      if (dc1394_query_supported_modes(cam->camera_info.handle, cam->camera_info.id, FORMAT_SCALABLE_IMAGE_SIZE, &value)!=DC1394_SUCCESS) {	MainError("Could not query Format7 supported modes");      }      else {	for (f=MODE_FORMAT7_MIN;f<=MODE_FORMAT7_MAX;f++) {	  cam->format7_info.mode[f-MODE_FORMAT7_MIN].present= (value & (0x1<<(31-(f-MODE_FORMAT7_MIN))) );	  GetFormat7ModeInfo(cam, f);	}      }    }    else { // format7 is not supported!!      for (i=0,f=MODE_FORMAT7_MIN;f<=MODE_FORMAT7_MAX;f++,i++) {	cam->format7_info.mode[i].present=0;      }      cam->format7_info.edit_mode=-1;    }  }  }voidGetFormat7ModeInfo(camera_t* cam, int mode_id) {  Format7ModeInfo_t *mode;  mode=&cam->format7_info.mode[mode_id-MODE_FORMAT7_MIN];  if (mode->present>0) { // check for mode presence before query    if (dc1394_query_format7_max_image_size(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->max_size_x,&mode->max_size_y)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 max image size");    if (dc1394_query_format7_unit_size(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->unit_size_x,&mode->unit_size_y)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 unit size");    // quick hack to keep size/position even. If pos/size is ODD, strange color/distorsions occur on some cams    // (e.g. Basler cams). This will have to really fixed later.    // REM: this is fixed by using the unit_position:    // fprintf(stderr,"Using pos units = %d %d\n",info->mode[i].step_pos_x,info->mode[i].step_pos_y);    if (dc1394_query_format7_unit_position(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->unit_pos_x,&mode->unit_pos_y)!=DC1394_SUCCESS) {      MainError("Got a problem querying format7 unit position");      mode->unit_pos_x=0;      mode->unit_pos_y=0;    }    if (dc1394_query_format7_image_position(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->pos_x,&mode->pos_y)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 image position");    if (dc1394_query_format7_image_size(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->size_x,&mode->size_y)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 image size");    if (dc1394_query_format7_byte_per_packet(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->bpp)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 bytes per packet");    if (mode->bpp==0) {      // sometimes a camera will not set the bpp register until a valid image size has been set after boot. If BPP is zero, we therefor      // try again after setting the image size to the maximum size.      MainError("Camera reported a BPP of ZERO. Trying to set maximum size to correct this.");      if (dc1394_set_format7_image_position(cam->camera_info.handle,cam->camera_info.id,mode_id,0,0)!=DC1394_SUCCESS)	MainError("Got a problem setting format7 image position");      if (dc1394_set_format7_image_size(cam->camera_info.handle,cam->camera_info.id,mode_id,mode->max_size_x,mode->max_size_y)!=DC1394_SUCCESS)	MainError("Got a problem setting format7 image size");      // maybe we should also force a color coding here.      if (dc1394_query_format7_byte_per_packet(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->bpp)!=DC1394_SUCCESS)	MainError("Got a problem querying format7 bytes per packet");      if (mode->bpp==0) {	MainError("    BPP still zero. Giving up.");      }    }    if (dc1394_query_format7_packet_para(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->min_bpp,&mode->max_bpp)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 packet parameters");    if (dc1394_query_format7_pixel_number(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->pixnum)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 pixel number");    if (dc1394_query_format7_total_bytes(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->total_bytes)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 total bytes per frame");    if (dc1394_query_format7_color_coding_id(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->color_coding_id)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 color coding ID");    if (dc1394_query_format7_color_coding(cam->camera_info.handle,cam->camera_info.id,mode_id,&mode->color_coding)!=DC1394_SUCCESS)      MainError("Got a problem querying format7 color coding");    //fprintf(stderr,"%d\n",(int)mode->total_bytes);  }}voidSwitchToNearestFPS(quadlet_t compat, int current) {  int i;  dc1394bool_t cont=DC1394_TRUE;  int new_framerate=-1;  char *temp;  temp=(char*)malloc(STRING_SIZE*sizeof(char));  current=current-FRAMERATE_MIN;  for (i=0;i<=((NUM_FRAMERATES>>1)+1);i++) { // search radius is num_framerates/2 +1 for safe rounding    if ( (compat&(0x1<<(31-(current+i)))) && cont) {      new_framerate=current+i+FRAMERATE_MIN;      cont=DC1394_FALSE;    }    if ( (compat&(0x1<<(31-(current-i)))) && cont) {      new_framerate=current-i+FRAMERATE_MIN;      cont=DC1394_FALSE;    }  }  if (new_framerate!=current) {    sprintf(temp,"Invalid framerate. Updating to nearest: %s",fps_label_list[new_framerate-FRAMERATE_MIN]);    MainStatus(temp);    if (dc1394_set_video_framerate(camera->camera_info.handle,camera->camera_info.id,new_framerate)!=DC1394_SUCCESS) {      MainError("Cannot set video framerate");    }    else {      camera->misc_info.framerate=new_framerate;    }  }  free(temp);}voidChangeModeAndFormat         (GtkMenuItem     *menuitem,			     gpointer         user_data){  int state;  int format;  quadlet_t value;  int mode;    mode=(int)user_data;  if ((mode>=MODE_FORMAT0_MIN)&&(mode<=MODE_FORMAT0_MAX))    format=FORMAT_VGA_NONCOMPRESSED;  else    if ((mode>=MODE_FORMAT1_MIN)&&(mode<=MODE_FORMAT1_MAX))      format=FORMAT_SVGA_NONCOMPRESSED_1;    else      if ((mode>=MODE_FORMAT2_MIN)&&(mode<=MODE_FORMAT2_MAX))	format=FORMAT_SVGA_NONCOMPRESSED_2;      else	if ((mode>=MODE_FORMAT6_MIN)&&(mode<=MODE_FORMAT6_MAX))	  format=FORMAT_STILL_IMAGE;	else	  format=FORMAT_SCALABLE_IMAGE_SIZE;  IsoFlowCheck(&state);    if (dc1394_set_video_format(camera->camera_info.handle,camera->camera_info.id,format)!=DC1394_SUCCESS)    MainError("Could not set video format");  else    camera->misc_info.format=format;  if (dc1394_set_video_mode(camera->camera_info.handle,camera->camera_info.id,mode)!=DC1394_SUCCESS)    MainError("Could not set video mode");  else    camera->misc_info.mode=mode;   // check consistancy of framerate:  if (camera->misc_info.format!=FORMAT_SCALABLE_IMAGE_SIZE) {    if (dc1394_query_supported_framerates(camera->camera_info.handle, camera->camera_info.id, format, mode, &value)!=DC1394_SUCCESS)      MainError("Could not read supported framerates");    else {      if ((value & (0x1<<(31-(camera->misc_info.framerate-FRAMERATE_MIN))))==0) {	// the current framerate is not OK for the new mode/format. Switch to nearest framerate	SwitchToNearestFPS(value,camera->misc_info.framerate);      }    }  }  IsoFlowResume(&state);  // REPROBE EVERYTHING  if (dc1394_get_camera_info(camera->camera_info.handle,camera->camera_info.id, &camera->camera_info)!=DC1394_SUCCESS)    MainError("Could not get camera basic information!");  if (dc1394_get_camera_misc_info(camera->camera_info.handle,camera->camera_info.id, &camera->misc_info)!=DC1394_SUCCESS)    MainError("Could not get camera misc information!");  if (dc1394_get_camera_feature_set(camera->camera_info.handle,camera->camera_info.id, &camera->feature_set)!=DC1394_SUCCESS)    MainError("Could not get camera feature information!");  if (format==FORMAT_SCALABLE_IMAGE_SIZE) {    GetFormat7Capabilities(camera);  }  BuildAllWindows();  UpdateAllWindows();}void IsoFlowCheck(int *state){   if (dc1394_get_iso_status(camera->camera_info.handle, camera->camera_info.id, &camera->misc_info.is_iso_on)!=DC1394_SUCCESS)    MainError("Could not get ISO status");  else {    if (camera->misc_info.is_iso_on>0) {      if (dc1394_stop_iso_transmission(camera->camera_info.handle, camera->camera_info.id)!=DC1394_SUCCESS)	// ... (if not done, restarting is no more possible)	MainError("Could not stop ISO transmission");    }  }  // memorize state:  *state=(GetService(camera, SERVICE_ISO)!=NULL);  if (*state!=0) {    gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(main_window,"service_iso"),FALSE);  }}void IsoFlowResume(int *state){  int was_on;  int timeout;  was_on=camera->misc_info.is_iso_on;  if (was_on>0) { // restart if it was 'on' before the changes    usleep(DELAY); // necessary to avoid desynchronized ISO flow.    if (dc1394_start_iso_transmission(camera->camera_info.handle, camera->camera_info.id)!=DC1394_SUCCESS)      MainError("Could not start ISO transmission");  }  if (*state!=0) {    gtk_toggle_button_set_active((GtkToggleButton*)lookup_widget(main_window,"service_iso"),TRUE);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -