1 /* pisa_sane_scan.h -*- C++ -*- 2 Copyright (C) 2001, 2004, 2008 SEIKO EPSON Corporation 3 4 This file is part of the `iscan' program. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 20 As a special exception, the copyright holders give permission 21 to link the code of this program with the esmod library and 22 distribute linked combinations including the two. You must obey 23 the GNU General Public License in all respects for all of the 24 code used other then esmod. 25 */ 26 27 #ifndef ___PISA_SANE_SCAN_H 28 #define ___PISA_SANE_SCAN_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <sane/sane.h> 35 #include <sane/saneopts.h> 36 37 #undef SANE_NAME_SCAN_X_RESOLUTION 38 #define SANE_NAME_SCAN_X_RESOLUTION "x-resolution" 39 40 #ifdef __cplusplus 41 } 42 #endif 43 44 #include "pisa_enums.h" 45 #include "pisa_structs.h" 46 47 typedef struct 48 { 49 char option; 50 char film; 51 char pixeltype; 52 char bitdepth; 53 char scanspeed; 54 char dropout; 55 char monoopt; 56 char halftone; 57 58 double offset[2]; 59 double area[2]; 60 long resolution[2]; 61 long zoom[2]; 62 63 gamma_struct gamma; 64 double coef[9]; 65 66 long threshold; 67 long speed; 68 long focus; 69 long usm; 70 long de_screening; 71 72 } scan_parameter; 73 74 75 class sane_scan 76 { 77 public: 78 void close_device (void); 79 80 // queries 81 void get_current_max_size (double *width, double *height) const; 82 long get_max_resolution (long cutoff = -1) const; 83 void get_color_profile (double *coef) const; 84 bool area_is_too_large (const scan_parameter& param) const; 85 bool has_adf (void) const; 86 bool has_tpu (void) const; 87 bool has_zoom (void) const; 88 bool has_focus (void) const; 89 bool has_start_button (void) const; 90 bool is_dumb (void) const; 91 bool is_button_pressed (void) const; 92 93 // mutators 94 void set_option (pisa_option_type option); 95 void set_film_type (pisa_film_type film); 96 97 protected: 98 void init (void); 99 void open_device (char *name = 0); 100 101 void set_scan_parameter (const scan_parameter& param); 102 void start_scan (int *width, int *height); 103 void acquire_image (unsigned char *img, int row_bytes, int height, 104 int cancel); 105 void finish_acquire (void); 106 107 int is_activate (const char *option_name) const; 108 long get_resolution (SANE_String_Const direction, int min_res) const; 109 long get_max_resolution (const char *option_name, long cutoff = -1) const; 110 int get_option_id (const char *option_name) const; 111 void get_value (const char *option_name, void *value) const; 112 113 void set_value (const char *option_name, void *value); 114 115 private: 116 void update_settings (const scan_parameter& param); 117 118 void query_device (char *device_name) const; 119 void get_scanner_info (const char *name = 0); 120 121 void set_color_mode (char pixeltype, char bitdepth); 122 void set_color_profile (const double *coef); 123 void set_focus (long position); 124 void set_gamma_table (const unsigned char *gamma_table); 125 void set_scan_area (double offset_x, double offset_y, 126 double width, double height); 127 void set_scan_resolution (int resolution_x, int resolution_y); 128 void set_scan_zoom (int zoom_x, int zoom_y); 129 void set_speed (long speed); 130 void set_threshold (long threshold); 131 132 private: 133 SANE_Handle m_hdevice; 134 SANE_Parameters m_sane_para; 135 long m_rows; 136 137 char * name; 138 pisa_option_type support_option; 139 bool support_zoom; 140 bool support_focus; 141 bool support_start_button; 142 long max_resolution; 143 }; 144 145 146 #endif // ___PISA_SANE_SCAN_H 147