1 /* 2 Copyright (C) 2004-2016 GraphicsMagick Group 3 4 This program is covered by multiple licenses, which are described in 5 Copyright.txt. You should have received a copy of Copyright.txt with this 6 package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. 7 8 Interfaces to support simple iterative pixel read/update access within an 9 image or between two images. These interfaces exist in order to eliminate 10 large amounts of redundant code and to allow changing the underlying 11 implementation without changing the using code. These interfaces 12 intentionally omit any pixel position information in order to not constrain 13 the implementation and to improve performance. 14 15 User-provided callbacks must be thread-safe (preferably re-entrant) since 16 they may be invoked by multiple threads. 17 18 These interfaces have proven to be future safe (since implemented) and may 19 be safely used by other applications/libraries. 20 21 Written by Bob Friesenhahn, March 2004, Updated for regions 2008. 22 23 */ 24 #ifndef _PIXEL_ROW_ITERATOR_H 25 #define _PIXEL_ROW_ITERATOR_H 26 27 #if defined(__cplusplus) || defined(c_plusplus) 28 extern "C" { 29 #endif 30 31 /* 32 Pixel iterator options. 33 */ 34 typedef struct _PixelIteratorOptions 35 { 36 int max_threads; /* Desired number of threads */ 37 unsigned long signature; 38 } PixelIteratorOptions; 39 40 41 /* 42 Initialize pixel iterator options with defaults. 43 */ 44 extern MagickExport void 45 InitializePixelIteratorOptions(PixelIteratorOptions *options, 46 ExceptionInfo *exception); 47 48 /* 49 Read-only access across pixel region. 50 */ 51 52 typedef MagickPassFail (*PixelIteratorMonoReadCallback) 53 ( 54 void *mutable_data, /* User provided mutable data */ 55 const void *immutable_data, /* User provided immutable data */ 56 const Image *const_image, /* Input image */ 57 const PixelPacket *pixels, /* Pixel row */ 58 const IndexPacket *indexes, /* Pixel indexes */ 59 const long npixels, /* Number of pixels in row */ 60 ExceptionInfo *exception /* Exception report */ 61 ); 62 63 extern MagickExport MagickPassFail 64 PixelIterateMonoRead(PixelIteratorMonoReadCallback call_back, 65 const PixelIteratorOptions *options, 66 const char *description, 67 void *mutable_data, 68 const void *immutable_data, 69 const long x, 70 const long y, 71 const unsigned long columns, 72 const unsigned long rows, 73 const Image *image, 74 ExceptionInfo *exception); 75 76 77 typedef MagickPassFail (*PixelIteratorMonoModifyCallback) 78 ( 79 void *mutable_data, /* User provided mutable data */ 80 const void *immutable_data, /* User provided immutable data */ 81 Image *image, /* Modify image */ 82 PixelPacket *pixels, /* Pixel row */ 83 IndexPacket *indexes, /* Pixel row indexes */ 84 const long npixels, /* Number of pixels in row */ 85 ExceptionInfo *exception /* Exception report */ 86 ); 87 88 /* 89 Write access across pixel region. 90 */ 91 extern MagickExport MagickPassFail 92 PixelIterateMonoSet(PixelIteratorMonoModifyCallback call_back, 93 const PixelIteratorOptions *options, 94 const char *description, 95 void *mutable_data, 96 const void *immutable_data, 97 const long x, 98 const long y, 99 const unsigned long columns, 100 const unsigned long rows, 101 Image *image, 102 ExceptionInfo *exception); 103 104 /* 105 Read-write access across pixel region. 106 */ 107 extern MagickExport MagickPassFail 108 PixelIterateMonoModify(PixelIteratorMonoModifyCallback call_back, 109 const PixelIteratorOptions *options, 110 const char *description, 111 void *mutable_data, 112 const void *immutable_data, 113 const long x, 114 const long y, 115 const unsigned long columns, 116 const unsigned long rows, 117 Image *image, 118 ExceptionInfo *exception); 119 120 /* 121 Read-only access across pixel regions of two images. 122 */ 123 124 typedef MagickPassFail (*PixelIteratorDualReadCallback) 125 ( 126 void *mutable_data, /* User provided mutable data */ 127 const void *immutable_data, /* User provided immutable data */ 128 const Image *first_image, /* First Input image */ 129 const PixelPacket *first_pixels, /* Pixel row in first image */ 130 const IndexPacket *first_indexes, /* Pixel row indexes in first image */ 131 const Image *second_image, /* Second Input image */ 132 const PixelPacket *second_pixels, /* Pixel row in second image */ 133 const IndexPacket *second_indexes, /* Pixel row indexes in second image */ 134 const long npixels, /* Number of pixels in row */ 135 ExceptionInfo *exception /* Exception report */ 136 ); 137 138 extern MagickExport MagickPassFail 139 PixelIterateDualRead(PixelIteratorDualReadCallback call_back, 140 const PixelIteratorOptions *options, 141 const char *description, 142 void *mutable_data, 143 const void *immutable_data, 144 const unsigned long columns, 145 const unsigned long rows, 146 const Image *first_image, 147 const long first_x, 148 const long first_y, 149 const Image *second_image, 150 const long second_x, 151 const long second_y, 152 ExceptionInfo *exception); 153 154 /* 155 Read-write access across pixel regions of two images. The first 156 (source) image is accessed read-only while the second (update) 157 image is accessed as read-write. 158 */ 159 160 typedef MagickPassFail (*PixelIteratorDualModifyCallback) 161 ( 162 void *mutable_data, /* User provided mutable data */ 163 const void *immutable_data, /* User provided immutable data */ 164 const Image *source_image, /* Source image */ 165 const PixelPacket *source_pixels, /* Pixel row in source image */ 166 const IndexPacket *source_indexes, /* Pixel row indexes in source image */ 167 Image *update_image, /* Update image */ 168 PixelPacket *update_pixels, /* Pixel row in update image */ 169 IndexPacket *update_indexes, /* Pixel row indexes in update image */ 170 const long npixels, /* Number of pixels in row */ 171 ExceptionInfo *exception /* Exception report */ 172 ); 173 174 extern MagickExport MagickPassFail 175 PixelIterateDualModify(PixelIteratorDualModifyCallback call_back, 176 const PixelIteratorOptions *options, 177 const char *description, 178 void *mutable_data, 179 const void *immutable_data, 180 const unsigned long columns, 181 const unsigned long rows, 182 const Image *source_image, 183 const long source_x, 184 const long source_y, 185 Image *update_image, 186 const long update_x, 187 const long update_y, 188 ExceptionInfo *exception); 189 190 /* 191 Read-write access across pixel regions of two images. The first 192 (source) image is accessed read-only while the second (new) 193 image is accessed for write (uninitialized pixels). 194 */ 195 typedef PixelIteratorDualModifyCallback PixelIteratorDualNewCallback; 196 197 extern MagickExport MagickPassFail 198 PixelIterateDualNew(PixelIteratorDualNewCallback call_back, 199 const PixelIteratorOptions *options, 200 const char *description, 201 void *mutable_data, 202 const void *immutable_data, 203 const unsigned long columns, 204 const unsigned long rows, 205 const Image *source_image, 206 const long source_x, 207 const long source_y, 208 Image *new_image, 209 const long new_x, 210 const long new_y, 211 ExceptionInfo *exception); 212 213 /* 214 Read-read-write access across pixel regions of three images. The 215 first two images are accessed read-only while the third is 216 accessed as read-write. 217 */ 218 219 typedef MagickPassFail (*PixelIteratorTripleModifyCallback) 220 ( 221 void *mutable_data, /* User provided mutable data */ 222 const void *immutable_data, /* User provided immutable data */ 223 const Image *source1_image, /* Source 1 image */ 224 const PixelPacket *source1_pixels, /* Pixel row in source 1 image */ 225 const IndexPacket *source1_indexes, /* Pixel row indexes in source 1 image */ 226 const Image *source2_image, /* Source 2 image */ 227 const PixelPacket *source2_pixels, /* Pixel row in source 2 image */ 228 const IndexPacket *source2_indexes, /* Pixel row indexes in source 2 image */ 229 Image *update_image, /* Update image */ 230 PixelPacket *update_pixels, /* Pixel row in update image */ 231 IndexPacket *update_indexes, /* Pixel row indexes in update image */ 232 const long npixels, /* Number of pixels in row */ 233 ExceptionInfo *exception /* Exception report */ 234 ); 235 236 extern MagickExport MagickPassFail 237 PixelIterateTripleModify(PixelIteratorTripleModifyCallback call_back, 238 const PixelIteratorOptions *options, 239 const char *description, 240 void *mutable_data, 241 const void *immutable_data, 242 const unsigned long columns, 243 const unsigned long rows, 244 const Image *source1_image, 245 const Image *source2_image, 246 const long source_x, 247 const long source_y, 248 Image *update_image, 249 const long update_x, 250 const long update_y, 251 ExceptionInfo *exception); 252 253 /* 254 Read-write access across pixel regions of two images. The first 255 (source) image is accessed read-only while the second (new) 256 image is accessed for write (uninitialized pixels). 257 */ 258 typedef PixelIteratorTripleModifyCallback PixelIteratorTripleNewCallback; 259 260 extern MagickExport MagickPassFail 261 PixelIterateTripleNew(PixelIteratorTripleNewCallback call_back, 262 const PixelIteratorOptions *options, 263 const char *description, 264 void *mutable_data, 265 const void *immutable_data, 266 const unsigned long columns, 267 const unsigned long rows, 268 const Image *source1_image, 269 const Image *source2_image, 270 const long source_x, 271 const long source_y, 272 Image *new_image, 273 const long new_x, 274 const long new_y, 275 ExceptionInfo *exception); 276 277 #if defined(__cplusplus) || defined(c_plusplus) 278 } 279 #endif 280 281 #endif /* _PIXEL_ROW_ITERATOR_H */ 282 283 /* 284 * Local Variables: 285 * mode: c 286 * c-basic-offset: 2 287 * fill-column: 78 288 * End: 289 */ 290