1 /* input.h: interface for input handlers 2 3 Copyright (C) 1999, 2000, 2001 Bernhard Herzog. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public License 7 as published by the Free Software Foundation; either version 2.1 of 8 the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 USA. */ 19 20 #ifndef INPUT_H 21 #define INPUT_H 22 #include "types.h" 23 #include "autotrace.h" 24 #include "exception.h" 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif /* __cplusplus */ 29 30 /* Input handler should be implemented with using 31 following functions and macros. */ 32 33 /* at_input_add_handler 34 Register an input handler to autotrace. */ 35 extern int at_input_add_handler (at_string suffix, 36 at_string description, 37 at_input_read_func func); 38 39 /* at_bitmap_init 40 Return initialized at_bitmap_type value. 41 42 args: 43 AREA is used as a storage of returned value. 44 If AREA is NULL, the storage is newly allocated 45 by at_bitmap_init. In such case the size of storage 46 is automatically calculated by WIDTH, HEIGHT and PLANES. 47 48 PLANES must be 1(gray scale) or 3(RGB color). 49 50 return value: 51 The return value is not newly allocated. 52 Only the storage is allocated if AREA is NULL. 53 On the other hand, at_bitmap_new allocates 54 mem for at_bitmap_type; and returns a pointer 55 for the mem. 56 at_bitmap_new is for autotrace library user. 57 at_bitmap_init is for input-handler developer. 58 Don't use at_bitmap_new in your input-handler. */ 59 extern at_bitmap_type at_bitmap_init(unsigned char * area, 60 unsigned short width, 61 unsigned short height, 62 unsigned int planes); 63 64 /* TODO: free storage */ 65 66 /* The number of color planes of each pixel */ 67 #define AT_BITMAP_PLANES(b) ((b).np) 68 69 /* The pixels, represented as an array of bytes (in contiguous storage). 70 Each pixel is represented by np bytes. */ 71 #define AT_BITMAP_BITS(b) ((b).bitmap) 72 73 /* These are convenient abbreviations for geting inside the members. */ 74 #define AT_BITMAP_WIDTH(b) ((b).width) 75 #define AT_BITMAP_HEIGHT(b) ((b).height) 76 77 /* This is the pixel at [ROW,COL]. */ 78 #define AT_BITMAP_PIXEL(b, row, col) \ 79 ((AT_BITMAP_BITS (b) + (row) * AT_BITMAP_PLANES (b) * AT_BITMAP_WIDTH (b) \ 80 + (col) * AT_BITMAP_PLANES(b))) 81 82 #ifdef __cplusplus 83 } 84 #endif /* __cplusplus */ 85 86 #endif /* Not def: INPUT_H */ 87