[772] | 1 | /* ----------------- */ |
---|
| 2 | /* --- nrwrap2.c --- */ |
---|
| 3 | /* ----------------- */ |
---|
| 4 | |
---|
| 5 | /* |
---|
| 6 | * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved |
---|
| 7 | * Univ Paris Sud XI, CNRS |
---|
| 8 | * |
---|
| 9 | * Distributed under the Boost Software License, Version 1.0 |
---|
| 10 | * see accompanying file LICENSE.txt or copy it at |
---|
| 11 | * http://www.boost.org/LICENSE_1_0.txt |
---|
| 12 | */ |
---|
| 13 | |
---|
| 14 | /* |
---|
| 15 | * 2002/06/11 ajout des fonctions endline |
---|
| 16 | */ |
---|
| 17 | #include <stdio.h> |
---|
| 18 | #include <stddef.h> |
---|
| 19 | #include <stdlib.h> |
---|
| 20 | #include <malloc.h> |
---|
| 21 | #include <math.h> // fabs |
---|
| 22 | |
---|
[821] | 23 | #include "nrc_os_config.h" |
---|
[772] | 24 | #include "mypredef.h" |
---|
| 25 | #include "nrtype.h" |
---|
| 26 | #include "nrdef.h" |
---|
| 27 | #include "nrmacro.h" |
---|
| 28 | #include "nrkernel.h" |
---|
| 29 | |
---|
| 30 | #include "nralloc1.h" |
---|
| 31 | #include "nralloc2.h" |
---|
| 32 | #include "nrwrap2.h" |
---|
| 33 | |
---|
| 34 | /* --------------------------------------------------------------------- */ |
---|
| 35 | IMAGE_EXPORT(sint8**) si8matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 36 | /* --------------------------------------------------------------------- */ |
---|
| 37 | { |
---|
| 38 | long nrow=nrh-nrl+1; |
---|
| 39 | sint8 **m; |
---|
| 40 | |
---|
| 41 | // allocate pointers to rows |
---|
| 42 | m=(sint8 **) malloc((size_t)(nrow*sizeof(sint8*))); |
---|
| 43 | if (!m) nrerror("allocation failure 1 in si8matrix_map()"); |
---|
| 44 | m -= nrl; |
---|
| 45 | |
---|
| 46 | // return pointer to array of pointers to rows |
---|
| 47 | return m; |
---|
| 48 | } |
---|
| 49 | /* --------------------------------------------------------------------- */ |
---|
| 50 | IMAGE_EXPORT(uint8**) ui8matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 51 | /* --------------------------------------------------------------------- */ |
---|
| 52 | { |
---|
| 53 | long nrow=nrh-nrl+1; |
---|
| 54 | uint8 **m; |
---|
| 55 | |
---|
| 56 | // allocate pointers to rows |
---|
| 57 | m=(uint8 **) malloc((size_t)(nrow*sizeof(uint8*))); |
---|
| 58 | if (!m) nrerror("allocation failure 1 in ui8matrix_map()"); |
---|
| 59 | m -= nrl; |
---|
| 60 | |
---|
| 61 | // return pointer to array of pointers to rows |
---|
| 62 | return m; |
---|
| 63 | } |
---|
| 64 | /* ----------------------------------------------------------------------- */ |
---|
| 65 | IMAGE_EXPORT(sint16**) si16matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 66 | /* ----------------------------------------------------------------------- */ |
---|
| 67 | { |
---|
| 68 | long nrow=nrh-nrl+1; |
---|
| 69 | sint16 **m; |
---|
| 70 | |
---|
| 71 | // allocate pointers to rows |
---|
| 72 | m=(sint16 **) malloc((size_t)(nrow*sizeof(sint16*))); |
---|
| 73 | if (!m) nrerror("allocation failure 1 in si16matrix_map()"); |
---|
| 74 | m -= nrl; |
---|
| 75 | |
---|
| 76 | // return pointer to array of pointers to rows |
---|
| 77 | return m; |
---|
| 78 | } |
---|
| 79 | /* ----------------------------------------------------------------------- */ |
---|
| 80 | IMAGE_EXPORT(uint16**) ui16matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 81 | /* ----------------------------------------------------------------------- */ |
---|
| 82 | { |
---|
| 83 | long nrow=nrh-nrl+1; |
---|
| 84 | uint16 **m; |
---|
| 85 | |
---|
| 86 | // allocate pointers to rows |
---|
| 87 | m=(uint16 **) malloc((size_t)(nrow*sizeof(uint16*))); |
---|
| 88 | if (!m) nrerror("allocation failure 1 in ui16matrix_map()"); |
---|
| 89 | m -= nrl; |
---|
| 90 | |
---|
| 91 | // return pointer to array of pointers to rows |
---|
| 92 | return m; |
---|
| 93 | } |
---|
| 94 | /* ----------------------------------------------------------------------- */ |
---|
| 95 | IMAGE_EXPORT(sint32**) si32matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 96 | /* ----------------------------------------------------------------------- */ |
---|
| 97 | { |
---|
| 98 | long nrow=nrh-nrl+1; |
---|
| 99 | sint32 **m; |
---|
| 100 | |
---|
| 101 | // allocate pointers to rows |
---|
| 102 | m=(sint32 **) malloc((size_t)(nrow*sizeof(sint32*))); |
---|
| 103 | if (!m) nrerror("allocation failure 1 in si32matrix_map()"); |
---|
| 104 | m -= nrl; |
---|
| 105 | |
---|
| 106 | // return pointer to array of pointers to rows |
---|
| 107 | return m; |
---|
| 108 | } |
---|
| 109 | /* ----------------------------------------------------------------------- */ |
---|
| 110 | IMAGE_EXPORT(uint32**) ui32matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 111 | /* ----------------------------------------------------------------------- */ |
---|
| 112 | { |
---|
| 113 | long nrow=nrh-nrl+1; |
---|
| 114 | uint32 **m; |
---|
| 115 | |
---|
| 116 | // allocate pointers to rows |
---|
| 117 | m=(uint32 **) malloc((size_t)(nrow*sizeof(uint32*))); |
---|
| 118 | if (!m) nrerror("allocation failure 1 in ui32matrix_map()"); |
---|
| 119 | m -= nrl; |
---|
| 120 | |
---|
| 121 | // return pointer to array of pointers to rows |
---|
| 122 | return m; |
---|
| 123 | } |
---|
| 124 | /* ----------------------------------------------------------------------- */ |
---|
| 125 | IMAGE_EXPORT(sint64**) si64matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 126 | /* ----------------------------------------------------------------------- */ |
---|
| 127 | { |
---|
| 128 | long nrow=nrh-nrl+1; |
---|
| 129 | sint64 **m; |
---|
| 130 | |
---|
| 131 | // allocate pointers to rows |
---|
| 132 | m=(sint64 **) malloc((size_t)(nrow*sizeof(sint64*))); |
---|
| 133 | if (!m) nrerror("allocation failure 1 in si32matrix_map()"); |
---|
| 134 | m -= nrl; |
---|
| 135 | |
---|
| 136 | // return pointer to array of pointers to rows |
---|
| 137 | return m; |
---|
| 138 | } |
---|
| 139 | /* ----------------------------------------------------------------------- */ |
---|
| 140 | IMAGE_EXPORT(uint64**) ui64matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 141 | /* ----------------------------------------------------------------------- */ |
---|
| 142 | { |
---|
| 143 | long nrow=nrh-nrl+1; |
---|
| 144 | uint64 **m; |
---|
| 145 | |
---|
| 146 | // allocate pointers to rows |
---|
| 147 | m=(uint64 **) malloc((size_t)(nrow*sizeof(uint64*))); |
---|
| 148 | if (!m) nrerror("allocation failure 1 in ui32matrix_map()"); |
---|
| 149 | m -= nrl; |
---|
| 150 | |
---|
| 151 | // return pointer to array of pointers to rows |
---|
| 152 | return m; |
---|
| 153 | } |
---|
| 154 | /* ----------------------------------------------------------------------- */ |
---|
| 155 | IMAGE_EXPORT(float32**) f32matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 156 | /* ----------------------------------------------------------------------- */ |
---|
| 157 | { |
---|
| 158 | long nrow=nrh-nrl+1; |
---|
| 159 | float32 **m; |
---|
| 160 | |
---|
| 161 | // allocate pointers to rows |
---|
| 162 | m=(float32 **) malloc((size_t)(nrow*sizeof(float32*))); |
---|
| 163 | if (!m) nrerror("allocation failure 1 in f32matrix_map()"); |
---|
| 164 | m -= nrl; |
---|
| 165 | |
---|
| 166 | // return pointer to array of pointers to rows |
---|
| 167 | return m; |
---|
| 168 | } |
---|
| 169 | /* ----------------------------------------------------------------------- */ |
---|
| 170 | IMAGE_EXPORT(float64**) matrix_f64map(long nrl, long nrh, long ncl, long nch) |
---|
| 171 | /* ----------------------------------------------------------------------- */ |
---|
| 172 | { |
---|
| 173 | long nrow=nrh-nrl+1; |
---|
| 174 | float64 **m; |
---|
| 175 | |
---|
| 176 | // allocate pointers to rows |
---|
| 177 | m=(float64 **) malloc((size_t)(nrow*sizeof(float64*))); |
---|
| 178 | if (!m) nrerror("allocation failure 1 in matrix_f64map()"); |
---|
| 179 | m -= nrl; |
---|
| 180 | |
---|
| 181 | // return pointer to array of pointers to rows |
---|
| 182 | return m; |
---|
| 183 | } |
---|
| 184 | /* --------------------------------------------------------------------- */ |
---|
| 185 | IMAGE_EXPORT(rgb8**) rgb8matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 186 | /* --------------------------------------------------------------------- */ |
---|
| 187 | { |
---|
| 188 | long nrow=nrh-nrl+1; |
---|
| 189 | rgb8 **m; |
---|
| 190 | |
---|
| 191 | // allocate pointers to rows |
---|
| 192 | m=(rgb8**) malloc((size_t)(nrow*sizeof(rgb8*))); |
---|
| 193 | if (!m) nrerror("allocation failure 1 in rgb8matrix_map()"); |
---|
| 194 | m -= nrl; |
---|
| 195 | |
---|
| 196 | // return pointer to array of pointers to rows |
---|
| 197 | return m; |
---|
| 198 | } |
---|
| 199 | /* ----------------------------------------------------------------------- */ |
---|
| 200 | IMAGE_EXPORT(rgbx8**) rgbx8matrix_map(long nrl, long nrh, long ncl, long nch) |
---|
| 201 | /* ----------------------------------------------------------------------- */ |
---|
| 202 | { |
---|
| 203 | long nrow=nrh-nrl+1; |
---|
| 204 | rgbx8 **m; |
---|
| 205 | |
---|
| 206 | // allocate pointers to rows |
---|
| 207 | m=(rgbx8**) malloc((size_t)(nrow*sizeof(rgbx8*))); |
---|
| 208 | if (!m) nrerror("allocation failure 1 in rgbx8matrix_map()"); |
---|
| 209 | m -= nrl; |
---|
| 210 | |
---|
| 211 | // return pointer to array of pointers to rows |
---|
| 212 | return m; |
---|
| 213 | } |
---|
| 214 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 215 | IMAGE_EXPORT(sint8 **) si8matrix_map_1D_pitch(sint8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 216 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 217 | { |
---|
| 218 | long i; |
---|
| 219 | |
---|
| 220 | // map rows and set pointers to them |
---|
| 221 | m[nrl]= (sint8*) data_1D; |
---|
| 222 | m[nrl] -= ncl; |
---|
| 223 | |
---|
| 224 | for(i=nrl+1;i<=nrh;i++) m[i] = m[i-1] + pitch; |
---|
| 225 | |
---|
| 226 | // return pointer to array of pointers to rows |
---|
| 227 | return m; |
---|
| 228 | } |
---|
| 229 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 230 | IMAGE_EXPORT(uint8 **) ui8matrix_map_1D_pitch(uint8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 231 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 232 | { |
---|
| 233 | long i; |
---|
| 234 | |
---|
| 235 | // map rows and set pointers to them |
---|
| 236 | m[nrl]= (uint8*) data_1D; |
---|
| 237 | m[nrl] -= ncl; |
---|
| 238 | |
---|
| 239 | for(i=nrl+1;i<=nrh;i++) m[i] = m[i-1] + pitch; |
---|
| 240 | |
---|
| 241 | // return pointer to array of pointers to rows |
---|
| 242 | return m; |
---|
| 243 | } |
---|
| 244 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 245 | IMAGE_EXPORT(sint16**) si16matrix_map_1D_pitch(sint16 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 246 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 247 | { |
---|
| 248 | long i; |
---|
| 249 | uint8 *p; // must be 8-bit pointer |
---|
| 250 | |
---|
| 251 | // map rows and set pointers to them |
---|
| 252 | m[nrl]= (sint16*) data_1D; |
---|
| 253 | m[nrl] -= ncl; |
---|
| 254 | |
---|
| 255 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 256 | p = (uint8*) m[nrl]; |
---|
| 257 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 258 | p += pitch; |
---|
| 259 | m[i] = (sint16*) p; |
---|
| 260 | } |
---|
| 261 | |
---|
| 262 | // return pointer to array of pointers to rows |
---|
| 263 | return m; |
---|
| 264 | } |
---|
| 265 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 266 | IMAGE_EXPORT(uint16**) ui16matrix_map_1D_pitch(uint16 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 267 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 268 | { |
---|
| 269 | long i; |
---|
| 270 | uint8 *p; // must be 8-bit pointer |
---|
| 271 | |
---|
| 272 | // map rows and set pointers to them |
---|
| 273 | m[nrl]= (uint16*) data_1D; |
---|
| 274 | m[nrl] -= ncl; |
---|
| 275 | |
---|
| 276 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 277 | p = (uint8*) m[nrl]; |
---|
| 278 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 279 | p += pitch; |
---|
| 280 | m[i] = (uint16*) p; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | // return pointer to array of pointers to rows |
---|
| 284 | return m; |
---|
| 285 | } |
---|
| 286 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 287 | IMAGE_EXPORT(sint32**) si32matrix_map_1D_pitch(sint32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 288 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 289 | { |
---|
| 290 | long i; |
---|
| 291 | uint8 *p; // must be 8-bit pointer |
---|
| 292 | |
---|
| 293 | // map rows and set pointers to them |
---|
| 294 | m[nrl]= (sint32*) data_1D; |
---|
| 295 | m[nrl] -= ncl; |
---|
| 296 | |
---|
| 297 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 298 | p = (uint8*) m[nrl]; |
---|
| 299 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 300 | p += pitch; |
---|
| 301 | m[i] = (sint32*) p; |
---|
| 302 | } |
---|
| 303 | |
---|
| 304 | // return pointer to array of pointers to rows |
---|
| 305 | return m; |
---|
| 306 | } |
---|
| 307 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 308 | IMAGE_EXPORT(uint32**) ui32matrix_map_1D_pitch(uint32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 309 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 310 | { |
---|
| 311 | long i; |
---|
| 312 | uint8 *p; // must be 8-bit pointer |
---|
| 313 | |
---|
| 314 | // map rows and set pointers to them |
---|
| 315 | m[nrl]= (uint32*) data_1D; |
---|
| 316 | m[nrl] -= ncl; |
---|
| 317 | |
---|
| 318 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 319 | p = (uint8*) m[nrl]; |
---|
| 320 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 321 | p += pitch; |
---|
| 322 | m[i] = (uint32*) p; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | // return pointer to array of pointers to rows |
---|
| 326 | return m; |
---|
| 327 | } |
---|
| 328 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 329 | IMAGE_EXPORT(sint64**) si64matrix_map_1D_pitch(sint64 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 330 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 331 | { |
---|
| 332 | long i; |
---|
| 333 | uint8 *p; // must be 8-bit pointer |
---|
| 334 | |
---|
| 335 | // map rows and set pointers to them |
---|
| 336 | m[nrl]= (sint64*) data_1D; |
---|
| 337 | m[nrl] -= ncl; |
---|
| 338 | |
---|
| 339 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 340 | p = (uint8*) m[nrl]; |
---|
| 341 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 342 | p += pitch; |
---|
| 343 | m[i] = (sint64*) p; |
---|
| 344 | } |
---|
| 345 | |
---|
| 346 | // return pointer to array of pointers to rows |
---|
| 347 | return m; |
---|
| 348 | } |
---|
| 349 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 350 | IMAGE_EXPORT(uint64**) ui64matrix_map_1D_pitch(uint64 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 351 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 352 | { |
---|
| 353 | long i; |
---|
| 354 | uint8 *p; // must be 8-bit pointer |
---|
| 355 | |
---|
| 356 | // map rows and set pointers to them |
---|
| 357 | m[nrl]= (uint64*) data_1D; |
---|
| 358 | m[nrl] -= ncl; |
---|
| 359 | |
---|
| 360 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 361 | p = (uint8*) m[nrl]; |
---|
| 362 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 363 | p += pitch; |
---|
| 364 | m[i] = (uint64*) p; |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | // return pointer to array of pointers to rows |
---|
| 368 | return m; |
---|
| 369 | } |
---|
| 370 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 371 | IMAGE_EXPORT(float32**) f32matrix_map_1D_pitch(float32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 372 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 373 | { |
---|
| 374 | long i; |
---|
| 375 | uint8 *p; // must be 8-bit pointer |
---|
| 376 | |
---|
| 377 | // map rows and set pointers to them |
---|
| 378 | m[nrl]= (float32*) data_1D; |
---|
| 379 | m[nrl] -= ncl; |
---|
| 380 | |
---|
| 381 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 382 | p = (uint8*) m[nrl]; |
---|
| 383 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 384 | p += pitch; |
---|
| 385 | m[i] = (float32*) p; |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | // return pointer to array of pointers to rows |
---|
| 389 | return m; |
---|
| 390 | } |
---|
| 391 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 392 | IMAGE_EXPORT(float64**) f64matrix_map_1D_pitch(float64 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 393 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 394 | { |
---|
| 395 | long i; |
---|
| 396 | uint8 *p; // must be 8-bit pointer |
---|
| 397 | |
---|
| 398 | // map rows and set pointers to them |
---|
| 399 | m[nrl]= (float64*) data_1D; |
---|
| 400 | m[nrl] -= ncl; |
---|
| 401 | |
---|
| 402 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 403 | p = (uint8*) m[nrl]; |
---|
| 404 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 405 | p += pitch; |
---|
| 406 | m[i] = (float64*) p; |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | // return pointer to array of pointers to rows |
---|
| 410 | return m; |
---|
| 411 | } |
---|
| 412 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
| 413 | IMAGE_EXPORT(rgb8**) rgb8matrix_map_1D_pitch(rgb8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 414 | /* -------------------------------------------------------------------------------------------------------------------- */ |
---|
| 415 | { |
---|
| 416 | long i; |
---|
| 417 | uint8 *p; // must be 8-bit pointer |
---|
| 418 | |
---|
| 419 | // map rows and set pointers to them |
---|
| 420 | m[nrl]= (rgb8*) data_1D; |
---|
| 421 | m[nrl] -= ncl; |
---|
| 422 | |
---|
| 423 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 424 | p = (uint8*) m[nrl]; |
---|
| 425 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 426 | p += pitch; |
---|
| 427 | m[i] = (rgb8*) p; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | // return pointer to array of pointers to rows |
---|
| 431 | return m; |
---|
| 432 | } |
---|
| 433 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 434 | IMAGE_EXPORT(rgbx8**) rgbx8matrix_map_1D_pitch(rgbx8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 435 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 436 | { |
---|
| 437 | long i; |
---|
| 438 | uint8 *p; // must be 8-bit pointer |
---|
| 439 | |
---|
| 440 | // map rows and set pointers to them |
---|
| 441 | m[nrl]= (rgbx8*) data_1D; |
---|
| 442 | m[nrl] -= ncl; |
---|
| 443 | |
---|
| 444 | //for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1] + pitch; |
---|
| 445 | p = (uint8*) m[nrl]; |
---|
| 446 | for(i=nrl+1;i<=nrh;i++) { |
---|
| 447 | p += pitch; |
---|
| 448 | m[i] = (rgbx8*) p; |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | // return pointer to array of pointers to rows |
---|
| 452 | return m; |
---|
| 453 | } |
---|
| 454 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 455 | IMAGE_EXPORT(sint8**) si8matrix_remap_1D_pitch(sint8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 456 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 457 | { |
---|
| 458 | m[nrl] += ncl; |
---|
| 459 | return si8matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 460 | } |
---|
| 461 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 462 | IMAGE_EXPORT(uint8**) ui8matrix_remap_1D_pitch(uint8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 463 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 464 | { |
---|
| 465 | m[nrl] += ncl; |
---|
| 466 | return ui8matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 467 | } |
---|
| 468 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 469 | IMAGE_EXPORT(sint16**) si16matrix_remap_1D_pitch(sint16 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 470 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 471 | { |
---|
| 472 | m[nrl] += ncl; |
---|
| 473 | return si16matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 474 | } |
---|
| 475 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 476 | IMAGE_EXPORT(uint16**) ui16matrix_remap_1D_pitch(uint16 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 477 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 478 | { |
---|
| 479 | m[nrl] += ncl; |
---|
| 480 | return ui16matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 481 | } |
---|
| 482 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 483 | IMAGE_EXPORT(sint32**) si32matrix_remap_1D_pitch(sint32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 484 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 485 | { |
---|
| 486 | m[nrl] += ncl; |
---|
| 487 | return si32matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 488 | } |
---|
| 489 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 490 | IMAGE_EXPORT(uint32**) ui32matrix_remap_1D_pitch(uint32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 491 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
---|
| 492 | { |
---|
| 493 | m[nrl] += ncl; |
---|
| 494 | return ui32matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 495 | } |
---|
| 496 | /* --------------------------------------------------------------------------------------------------------------------------- */ |
---|
| 497 | IMAGE_EXPORT(float32**) f32matrix_remap_1D_pitch(float32 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 498 | /* --------------------------------------------------------------------------------------------------------------------------- */ |
---|
| 499 | { |
---|
| 500 | m[nrl] += ncl; |
---|
| 501 | return f32matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 502 | } |
---|
| 503 | /* --------------------------------------------------------------------------------------------------------------------------- */ |
---|
| 504 | IMAGE_EXPORT(float64**) f64matrix_remap_1D_pitch(float64 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 505 | /* --------------------------------------------------------------------------------------------------------------------------- */ |
---|
| 506 | { |
---|
| 507 | m[nrl] += ncl; |
---|
| 508 | return f64matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 509 | } |
---|
| 510 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 511 | IMAGE_EXPORT(rgb8**) rgb8matrix_remap_1D_pitch(rgb8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 512 | /* --------------------------------------------------------------------------------------------------------------------- */ |
---|
| 513 | { |
---|
| 514 | m[nrl] += ncl; |
---|
| 515 | return rgb8matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 516 | } |
---|
| 517 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 518 | IMAGE_EXPORT(rgbx8**) rgbx8matrix_remap_1D_pitch(rgbx8 **m, long nrl, long nrh, long ncl, long nch, void *data_1D, long pitch) |
---|
| 519 | /* ----------------------------------------------------------------------------------------------------------------------- */ |
---|
| 520 | { |
---|
| 521 | m[nrl] += ncl; |
---|
| 522 | return rgbx8matrix_map_1D_pitch(m, nrl, nrh, ncl, nch, data_1D, pitch); |
---|
| 523 | } |
---|
| 524 | /* |
---|
| 525 | * --------------- |
---|
| 526 | * free_matrix_map |
---|
| 527 | * --------------- |
---|
| 528 | */ |
---|
| 529 | /* ---------------------------------------------------------------------------------- */ |
---|
| 530 | IMAGE_EXPORT(void) free_si8matrix_map(sint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 531 | /* ---------------------------------------------------------------------------------- */ |
---|
| 532 | { |
---|
| 533 | free((FREE_ARG)(m+nrl)); |
---|
| 534 | } |
---|
| 535 | /* ---------------------------------------------------------------------------------- */ |
---|
| 536 | IMAGE_EXPORT(void) free_ui8matrix_map(uint8 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 537 | /* ---------------------------------------------------------------------------------- */ |
---|
| 538 | { |
---|
| 539 | free((FREE_ARG)(m+nrl)); |
---|
| 540 | } |
---|
| 541 | /* ------------------------------------------------------------------------------------ */ |
---|
| 542 | IMAGE_EXPORT(void) free_si16matrix_map(sint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 543 | /* ------------------------------------------------------------------------------------ */ |
---|
| 544 | { |
---|
| 545 | free((FREE_ARG)(m+nrl)); |
---|
| 546 | } |
---|
| 547 | /* ------------------------------------------------------------------------------------ */ |
---|
| 548 | IMAGE_EXPORT(void) free_ui16matrix_map(uint16 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 549 | /* ------------------------------------------------------------------------------------ */ |
---|
| 550 | { |
---|
| 551 | free((FREE_ARG)(m+nrl)); |
---|
| 552 | } |
---|
| 553 | /* ------------------------------------------------------------------------------------ */ |
---|
| 554 | IMAGE_EXPORT(void) free_si32matrix_map(sint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 555 | /* ------------------------------------------------------------------------------------ */ |
---|
| 556 | { |
---|
| 557 | free((FREE_ARG)(m+nrl)); |
---|
| 558 | } |
---|
| 559 | /* ------------------------------------------------------------------------------------ */ |
---|
| 560 | IMAGE_EXPORT(void) free_ui32matrix_map(uint32 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 561 | /* ------------------------------------------------------------------------------------ */ |
---|
| 562 | { |
---|
| 563 | free((FREE_ARG)(m+nrl)); |
---|
| 564 | } |
---|
| 565 | /* ------------------------------------------------------------------------------------ */ |
---|
| 566 | IMAGE_EXPORT(void) free_si64matrix_map(sint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 567 | /* ------------------------------------------------------------------------------------ */ |
---|
| 568 | { |
---|
| 569 | free((FREE_ARG)(m+nrl)); |
---|
| 570 | } |
---|
| 571 | /* ------------------------------------------------------------------------------------ */ |
---|
| 572 | IMAGE_EXPORT(void) free_ui64matrix_map(uint64 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 573 | /* ------------------------------------------------------------------------------------ */ |
---|
| 574 | { |
---|
| 575 | free((FREE_ARG)(m+nrl)); |
---|
| 576 | } |
---|
| 577 | /* ---------------------------------------------------------------------------------- */ |
---|
| 578 | IMAGE_EXPORT(void) free_rgb8matrix_map(rgb8 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 579 | /* ---------------------------------------------------------------------------------- */ |
---|
| 580 | { |
---|
| 581 | free((FREE_ARG)(m+nrl)); |
---|
| 582 | } |
---|
| 583 | /* ------------------------------------------------------------------------------------ */ |
---|
| 584 | IMAGE_EXPORT(void) free_rgbx8matrix_map(rgbx8 **m, long nrl, long nrh, long ncl, long nch) |
---|
| 585 | /* ------------------------------------------------------------------------------------ */ |
---|
| 586 | { |
---|
| 587 | free((FREE_ARG)(m+nrl)); |
---|
| 588 | } |
---|
| 589 | |
---|