Changeset 822 for soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
- Timestamp:
- Jun 1, 2016, 10:25:43 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
r821 r822 49 49 */ 50 50 51 52 #undef display_type_matrix 53 #define display_type_matrix(t) \ 54 void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 55 { \ 56 if (name != NULL) { \ 57 printf("%s\n", name); \ 58 } \ 59 \ 60 for (int32_t i = nrl; i <= nrh; i++) { \ 61 for (int32_t j = ncl; j <= nch; j++) { \ 62 printf(format, m[i][j]); \ 63 } \ 64 printf("\n"); \ 65 } \ 66 } 67 68 display_type_matrix(int8_t); 69 display_type_matrix(uint8_t); 70 display_type_matrix(int16_t); 71 display_type_matrix(uint16_t); 72 display_type_matrix(int32_t); 73 display_type_matrix(uint32_t); 74 display_type_matrix(int64_t); 75 display_type_matrix(uint64_t); 76 display_type_matrix(float); 77 display_type_matrix(double); 78 79 51 80 /* -------------------------------------------------------------------------------------------------------- */ 52 IMAGE_EXPORT(void) display_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)81 void display_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 53 82 /* -------------------------------------------------------------------------------------------------------- */ 54 83 { 55 long i,j;56 57 if(name != NULL) printf(name);58 59 for (i=nrl; i<=nrh; i++) {60 for (j=ncl; j<=nch; j++) {61 printf(format, m[i][j] );84 if (name != NULL) { 85 printf(name); 86 } 87 88 for (int32_t i = nrl; i <= nrh; i++) { 89 for (int32_t j = ncl; j <= nch; j++) { 90 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 62 91 } 63 92 printf("\n"); 64 93 } 65 94 } 66 /* -------------------------------------------------------------------------------------------------------- */ 67 IMAGE_EXPORT(void) display_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 68 /* -------------------------------------------------------------------------------------------------------- */ 69 { 70 long i,j; 71 72 if(name != NULL) printf(name); 73 74 for(i=nrl; i<=nrh; i++) { 75 for(j=ncl; j<=nch; j++) { 76 printf(format, m[i][j]); 95 96 /* ---------------------------------------------------------------------------------------------------------- */ 97 void display_rgbx8matrix(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 98 /* ---------------------------------------------------------------------------------------------------------- */ 99 { 100 if (name != NULL) { 101 printf(name); 102 } 103 104 for (int32_t i = nrl; i <= nrh; i++) { 105 for (int32_t j = ncl; j <= nch; j++) { 106 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 77 107 } 78 108 printf("\n"); 79 109 } 80 110 } 81 /* ---------------------------------------------------------------------------------------------------------- */ 82 IMAGE_EXPORT(void) display_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 83 /* ---------------------------------------------------------------------------------------------------------- */ 84 { 85 long i,j; 86 87 if(name != NULL) printf(name); 88 89 for(i=nrl; i<=nrh; i++) { 90 for(j=ncl; j<=nch; j++) { 91 printf(format, m[i][j]); 92 } 93 printf("\n"); 94 } 95 } 96 /* ---------------------------------------------------------------------------------------------------------- */ 97 IMAGE_EXPORT(void) display_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 98 /* ---------------------------------------------------------------------------------------------------------- */ 99 { 100 long i,j; 101 102 if(name != NULL) printf(name); 103 104 for(i=nrl; i<=nrh; i++) { 105 for(j=ncl; j<=nch; j++) { 106 printf(format, m[i][j]); 107 } 108 printf("\n"); 109 } 110 } 111 /* ---------------------------------------------------------------------------------------------------------- */ 112 IMAGE_EXPORT(void) display_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 113 /* ---------------------------------------------------------------------------------------------------------- */ 114 { 115 long i,j; 116 117 if(name != NULL) printf(name); 118 119 for(i=nrl; i<=nrh; i++) { 120 for(j=ncl; j<=nch; j++) { 121 printf(format, m[i][j]); 122 } 123 printf("\n"); 124 } 125 } 126 /* ---------------------------------------------------------------------------------------------------------- */ 127 IMAGE_EXPORT(void) display_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 128 /* ---------------------------------------------------------------------------------------------------------- */ 129 { 130 long i,j; 131 132 if(name != NULL) printf(name); 133 134 for(i=nrl; i<=nrh; i++) { 135 for(j=ncl; j<=nch; j++) { 136 printf(format, m[i][j]); 137 } 138 printf("\n"); 139 } 140 } 141 /* ---------------------------------------------------------------------------------------------------------- */ 142 IMAGE_EXPORT(void) display_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 143 /* ---------------------------------------------------------------------------------------------------------- */ 144 { 145 long i,j; 146 147 if(name != NULL) printf(name); 148 149 for(i=nrl; i<=nrh; i++) { 150 for(j=ncl; j<=nch; j++) { 151 printf(format, m[i][j]); 152 } 153 printf("\n"); 154 } 155 } 156 /* --------------------------------------------------------------------------------------------------------- */ 157 IMAGE_EXPORT(void) display_i64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 158 /* --------------------------------------------------------------------------------------------------------- */ 159 { 160 long i,j; 161 162 if(name != NULL) printf(name); 163 164 for(i=nrl; i<=nrh; i++) { 165 for(j=ncl; j<=nch; j++) { 166 printf(format, m[i][j]); 167 } 168 printf("\n"); 169 } 170 } 171 /* ---------------------------------------------------------------------------------------------------------- */ 172 IMAGE_EXPORT(void) display_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 173 /* ---------------------------------------------------------------------------------------------------------- */ 174 { 175 long i,j; 176 177 if(name != NULL) printf(name); 178 179 for(i=nrl; i<=nrh; i++) { 180 for(j=ncl; j<=nch; j++) { 181 printf(format, m[i][j]); 182 } 183 printf("\n"); 184 } 185 } 186 /* ---------------------------------------------------------------------------------------------------------- */ 187 IMAGE_EXPORT(void) display_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 188 /* ---------------------------------------------------------------------------------------------------------- */ 189 { 190 long i,j; 191 192 if(name != NULL) printf(name); 193 194 for(i=nrl; i<=nrh; i++) { 195 for(j=ncl; j<=nch; j++) { 196 printf(format, m[i][j]); 197 } 198 printf("\n"); 199 } 200 } 201 /* -------------------------------------------------------------------------------------------------------- */ 202 IMAGE_EXPORT(void) display_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 203 /* -------------------------------------------------------------------------------------------------------- */ 204 { 205 long i,j; 206 207 if(name != NULL) printf(name); 208 209 for(i=nrl; i<=nrh; i++) { 210 for(j=ncl; j<=nch; j++) { 211 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 212 } 213 printf("\n"); 214 } 215 } 216 /* ---------------------------------------------------------------------------------------------------------- */ 217 IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 218 /* ---------------------------------------------------------------------------------------------------------- */ 219 { 220 long i,j; 221 222 if(name != NULL) printf(name); 223 224 for(i=nrl; i<=nrh; i++) { 225 for(j=ncl; j<=nch; j++) { 226 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 227 } 228 printf("\n"); 229 } 230 } 231 /* 232 * ---------------------- 233 * --- display_matrix --- 234 * ---------------------- 235 */ 236 237 /* ---------------------------------------------------------------------------------------------------------- */ 238 IMAGE_EXPORT(void) display_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 239 /* ---------------------------------------------------------------------------------------------------------- */ 240 { 241 long i,j; 242 243 if(name != NULL) printf(name); 244 245 for(j=ncl; j<=nch; j++) { 246 for(i=nrl; i<=nrh; i++) { 247 printf(format, m[i][j]); 248 } 249 printf("\n"); 250 } 251 } 252 /* ---------------------------------------------------------------------------------------------------------- */ 253 IMAGE_EXPORT(void) display_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 254 /* ---------------------------------------------------------------------------------------------------------- */ 255 { 256 long i,j; 257 258 if(name != NULL) printf(name); 259 260 for(j=ncl; j<=nch; j++) { 261 for(i=nrl; i<=nrh; i++) { 262 printf(format, m[i][j]); 263 } 264 printf("\n"); 265 } 266 } 267 /* ------------------------------------------------------------------------------------------------------------ */ 268 IMAGE_EXPORT(void) display_si16matrix_T(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 269 /* ------------------------------------------------------------------------------------------------------------ */ 270 { 271 long i,j; 272 273 if(name != NULL) printf(name); 274 275 for(j=ncl; j<=nch; j++) { 276 for(i=nrl; i<=nrh; i++) { 277 printf(format, m[i][j]); 278 } 279 printf("\n"); 280 } 281 } 282 /* ------------------------------------------------------------------------------------------------------------ */ 283 IMAGE_EXPORT(void) display_ui16matrix_T(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 284 /* ------------------------------------------------------------------------------------------------------------ */ 285 { 286 long i,j; 287 288 if(name != NULL) printf(name); 289 290 for(j=ncl; j<=nch; j++) { 291 for(i=nrl; i<=nrh; i++) { 292 printf(format, m[i][j]); 293 } 294 printf("\n"); 295 } 296 } 297 /* ------------------------------------------------------------------------------------------------------------ */ 298 IMAGE_EXPORT(void) display_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 299 /* ------------------------------------------------------------------------------------------------------------ */ 300 { 301 long i,j; 302 303 if(name != NULL) printf(name); 304 305 for(j=ncl; j<=nch; j++) { 306 for(i=nrl; i<=nrh; i++) { 307 printf(format, m[i][j]); 308 } 309 printf("\n"); 310 } 311 } 312 /* ---------------------------------------------------------------------------------------------------------- */ 313 IMAGE_EXPORT(void) display_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 314 /* ---------------------------------------------------------------------------------------------------------- */ 315 { 316 long i,j; 317 318 if(name != NULL) printf(name); 319 320 for(j=ncl; j<=nch; j++) { 321 for(i=nrl; i<=nrh; i++) { 322 printf(format, m[i][j]); 323 } 324 printf("\n"); 325 } 326 } 327 /* ------------------------------------------------------------------------------------------------------------ */ 328 IMAGE_EXPORT(void) display_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 329 /* ------------------------------------------------------------------------------------------------------------ */ 330 { 331 long i,j; 332 333 if(name != NULL) printf(name); 334 335 for(j=ncl; j<=nch; j++) { 336 for(i=nrl; i<=nrh; i++) { 337 printf(format, m[i][j]); 338 } 339 printf("\n"); 340 } 341 } 342 /* ------------------------------------------------------------------------------------------------------------ */ 343 IMAGE_EXPORT(void) display_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 344 /* ------------------------------------------------------------------------------------------------------------ */ 345 { 346 long i,j; 347 348 if(name != NULL) printf(name); 349 350 for(j=ncl; j<=nch; j++) { 351 for(i=nrl; i<=nrh; i++) { 352 printf(format, m[i][j]); 353 } 354 printf("\n"); 355 } 356 } 357 /* ------------------------------------------------------------------------------------------------------------ */ 358 IMAGE_EXPORT(void) display_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 359 /* ------------------------------------------------------------------------------------------------------------ */ 360 { 361 long i,j; 362 363 if(name != NULL) printf(name); 364 365 for(j=ncl; j<=nch; j++) { 366 for(i=nrl; i<=nrh; i++) { 367 printf(format, m[i][j]); 368 } 369 printf("\n"); 370 } 371 } 372 /* ------------------------------------------------------------------------------------------------------------ */ 373 IMAGE_EXPORT(void) display_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 374 /* ------------------------------------------------------------------------------------------------------------ */ 375 { 376 long i,j; 377 378 if(name != NULL) printf(name); 379 380 for(j=ncl; j<=nch; j++) { 381 for(i=nrl; i<=nrh; i++) { 382 printf(format, m[i][j]); 383 } 384 printf("\n"); 385 } 386 } 387 /* ---------------------------------------------------------------------------------------------------------- */ 388 IMAGE_EXPORT(void) display_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 389 /* ---------------------------------------------------------------------------------------------------------- */ 390 { 391 long i,j; 392 393 if(name != NULL) printf(name); 394 395 for(j=ncl; j<=nch; j++) { 396 for(i=nrl; i<=nrh; i++) { 397 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 398 } 399 printf("\n"); 400 } 401 } 402 /* ------------------------------------------------------------------------------------------------------------ */ 403 IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 404 /* ------------------------------------------------------------------------------------------------------------ */ 405 { 406 long i,j; 407 408 if(name != NULL) printf(name); 409 410 for(j=ncl; j<=nch; j++) { 411 for(i=nrl; i<=nrh; i++) { 412 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 413 } 414 printf("\n"); 415 } 416 } 111 417 112 418 113 /* … … 422 117 */ 423 118 119 #undef display_type_matrix_T 120 #define display_type_matrix_T(t) \ 121 void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 122 { \ 123 if (name != NULL) { \ 124 printf("%s\n", name); \ 125 } \ 126 \ 127 for (int32_t j = ncl; j <= nch; j++) { \ 128 for (int32_t i = nrl; i <= nrh; i++) { \ 129 printf(format, m[i][j]); \ 130 } \ 131 printf("\n"); \ 132 } \ 133 } 134 135 display_type_matrix_T(int8_t); 136 display_type_matrix_T(uint8_t); 137 display_type_matrix_T(int16_t); 138 display_type_matrix_T(uint16_t); 139 display_type_matrix_T(int32_t); 140 display_type_matrix_T(uint32_t); 141 display_type_matrix_T(int64_t); 142 display_type_matrix_T(uint64_t); 143 display_type_matrix_T(float); 144 display_type_matrix_T(double); 145 146 147 /* -------------------------------------------------------------------------------------------------------- */ 148 void display_rgb8matrix_T(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 149 /* -------------------------------------------------------------------------------------------------------- */ 150 { 151 if (name != NULL) { 152 printf(name); 153 } 154 155 for (int32_t j = ncl; j <= nch; j++) { 156 for (int32_t i = nrl; i <= nrh; i++) { 157 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 158 } 159 printf("\n"); 160 } 161 } 162 163 /* ---------------------------------------------------------------------------------------------------------- */ 164 void display_rgbx8matrix_T(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 165 /* ---------------------------------------------------------------------------------------------------------- */ 166 { 167 if (name != NULL) { 168 printf(name); 169 } 170 171 for (int32_t j = ncl; j <= nch; j++) { 172 for (int32_t i = nrl; i <= nrh; i++) { 173 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 174 } 175 printf("\n"); 176 } 177 } 178 179 180 181 /* 182 * ----------------------------- 183 * --- display_matrix_number --- 184 * ----------------------------- 185 */ 186 187 #undef display_type_matrix_number 188 #define display_type_matrix_number(t) \ 189 void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \ 190 { \ 191 if (name != NULL) { \ 192 printf("%s\n", name); \ 193 } \ 194 printf("%5c", '#'); \ 195 for (int32_t j = ncl; j <= nch; j++) { \ 196 printf(format, j); \ 197 } \ 198 printf("\n"); \ 199 for (int32_t i = nrl; i <= nrh; i++) { \ 200 printf("[%3d]", i); \ 201 for (int32_t j = ncl; j <= nch; j++) { \ 202 printf(format, m[i][j]); \ 203 } \ 204 printf("\n"); \ 205 } \ 206 printf("\n"); \ 207 } 208 209 display_type_matrix_number(int8_t); 210 display_type_matrix_number(uint8_t); 211 display_type_matrix_number(int16_t); 212 display_type_matrix_number(uint16_t); 213 display_type_matrix_number(int32_t); 214 display_type_matrix_number(uint32_t); 215 display_type_matrix_number(int64_t); 216 display_type_matrix_number(uint64_t); 217 display_type_matrix_number(float); 218 display_type_matrix_number(double); 219 220 424 221 /* --------------------------------------------------------------------------------------------------------------- */ 425 IMAGE_EXPORT(void) display_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)222 void display_rgb8matrix_number(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) 426 223 /* --------------------------------------------------------------------------------------------------------------- */ 427 224 { 428 int i,j; 429 430 if(name != NULL) printf(name); 431 225 if (name != NULL) { 226 printf(name); 227 } 432 228 // 1ere ligne 433 229 printf("%5c", '#'); 434 for (j=ncl; j<=nch; j++) {230 for (int32_t j = ncl; j <= nch; j++) { 435 231 printf(format, j); 436 232 } 437 233 printf("\n"); 438 for (i=nrl; i<=nrh; i++) {234 for (int32_t i = nrl; i <= nrh; i++) { 439 235 printf("[%3d]", i); 440 for (j=ncl; j<=nch; j++) {441 printf(format, m[i][j] );236 for (int32_t j = ncl; j <= nch; j++) { 237 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 442 238 } 443 239 printf("\n"); … … 445 241 printf("\n"); 446 242 } 447 /* --------------------------------------------------------------------------------------------------------------- */ 448 IMAGE_EXPORT(void) display_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 449 /* --------------------------------------------------------------------------------------------------------------- */ 450 { 451 int i,j; 452 453 if(name != NULL)printf(name);454 243 244 /* ----------------------------------------------------------------------------------------------------------------- */ 245 void display_rgbx8matrix_number(rgbx8 **m,int32_t nrl,int32_t nrh,int32_t ncl, int32_t nch, char *format, char *name) 246 /* ----------------------------------------------------------------------------------------------------------------- */ 247 { 248 if (name != NULL) { 249 printf(name); 250 } 455 251 // 1ere ligne 456 252 printf("%5c", '#'); 457 for (j=ncl; j<=nch; j++) {253 for (int32_t j = ncl; j <= nch; j++) { 458 254 printf(format, j); 459 255 } 460 256 printf("\n"); 461 for (i=nrl; i<=nrh; i++) {257 for (int32_t i = nrl; i <= nrh; i++) { 462 258 printf("[%3d]", i); 463 for (j=ncl; j<=nch; j++) {464 printf(format, m[i][j] );259 for (int32_t j = ncl; j <= nch; j++) { 260 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 465 261 } 466 262 printf("\n"); … … 468 264 printf("\n"); 469 265 } 470 /* ----------------------------------------------------------------------------------------------------------------- */ 471 IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 472 /* ----------------------------------------------------------------------------------------------------------------- */ 473 { 474 int i,j; 475 476 if(name != NULL) printf(name); 477 478 // 1ere ligne 479 printf("%5c", '#'); 480 for(j=ncl; j<=nch; j++) { 481 printf(format, j); 482 } 483 printf("\n"); 484 for(i=nrl; i<=nrh; i++) { 485 printf("[%3d]", i); 486 for(j=ncl; j<=nch; j++) { 487 printf(format, m[i][j]); 488 } 489 printf("\n"); 490 } 491 printf("\n"); 492 } 493 /* ----------------------------------------------------------------------------------------------------------------- */ 494 IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 495 /* ----------------------------------------------------------------------------------------------------------------- */ 496 { 497 int i,j; 498 499 if(name != NULL) printf(name); 500 501 // 1ere ligne 502 printf("%5c", '#'); 503 for(j=ncl; j<=nch; j++) { 504 printf(format, j); 505 } 506 printf("\n"); 507 for(i=nrl; i<=nrh; i++) { 508 printf("[%3d]", i); 509 for(j=ncl; j<=nch; j++) { 510 printf(format, m[i][j]); 511 } 512 printf("\n"); 513 } 514 printf("\n"); 515 } 516 /* ----------------------------------------------------------------------------------------------------------------- */ 517 IMAGE_EXPORT(void) display_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 518 /* ----------------------------------------------------------------------------------------------------------------- */ 519 { 520 int i,j; 521 522 if(name != NULL) printf(name); 523 524 // 1ere ligne 525 printf("%5c", '#'); 526 for(j=ncl; j<=nch; j++) { 527 printf(format, j); 528 } 529 printf("\n"); 530 for(i=nrl; i<=nrh; i++) { 531 printf("[%3d]", i); 532 for(j=ncl; j<=nch; j++) { 533 printf(format, m[i][j]); 534 } 535 printf("\n"); 536 } 537 printf("\n"); 538 } 539 /* ----------------------------------------------------------------------------------------------------------------- */ 540 IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 541 /* ----------------------------------------------------------------------------------------------------------------- */ 542 { 543 int i,j; 544 545 if(name != NULL) printf(name); 546 547 // 1ere ligne 548 printf("%5c", '#'); 549 for(j=ncl; j<=nch; j++) { 550 printf(format, j); 551 } 552 printf("\n"); 553 for(i=nrl; i<=nrh; i++) { 554 printf("[%3d]", i); 555 for(j=ncl; j<=nch; j++) { 556 printf(format, m[i][j]); 557 } 558 printf("\n"); 559 } 560 printf("\n"); 561 } 562 /* ----------------------------------------------------------------------------------------------------------------- */ 563 IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 564 /* ----------------------------------------------------------------------------------------------------------------- */ 565 { 566 int i,j; 567 568 if(name != NULL) printf(name); 569 570 // 1ere ligne 571 printf("%5c", '#'); 572 for(j=ncl; j<=nch; j++) { 573 printf(format, j); 574 } 575 printf("\n"); 576 for(i=nrl; i<=nrh; i++) { 577 printf("[%3d]", i); 578 for(j=ncl; j<=nch; j++) { 579 printf(format, m[i][j]); 580 } 581 printf("\n"); 582 } 583 printf("\n"); 584 } 585 /* ----------------------------------------------------------------------------------------------------------------- */ 586 IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 587 /* ----------------------------------------------------------------------------------------------------------------- */ 588 { 589 int i,j; 590 591 if(name != NULL) printf(name); 592 593 // 1ere ligne 594 printf("%5c", '#'); 595 for(j=ncl; j<=nch; j++) { 596 printf(format, j); 597 } 598 printf("\n"); 599 for(i=nrl; i<=nrh; i++) { 600 printf("[%3d]", i); 601 for(j=ncl; j<=nch; j++) { 602 printf(format, m[i][j]); 603 } 604 printf("\n"); 605 } 606 printf("\n"); 607 } 608 /* ----------------------------------------------------------------------------------------------------------------- */ 609 IMAGE_EXPORT(void) display_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 610 /* ----------------------------------------------------------------------------------------------------------------- */ 611 { 612 int i,j; 613 614 if(name != NULL) printf(name); 615 616 // 1ere ligne 617 printf("%5c", '#'); 618 for(j=ncl; j<=nch; j++) { 619 printf(format, j); 620 } 621 printf("\n"); 622 for(i=nrl; i<=nrh; i++) { 623 printf("[%3d]", i); 624 for(j=ncl; j<=nch; j++) { 625 printf(format, m[i][j]); 626 } 627 printf("\n"); 628 } 629 printf("\n"); 630 } 631 /* ----------------------------------------------------------------------------------------------------------------- */ 632 IMAGE_EXPORT(void) display_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 633 /* ----------------------------------------------------------------------------------------------------------------- */ 634 { 635 int i,j; 636 637 if(name != NULL) printf(name); 638 639 // 1ere ligne 640 printf("%5c", '#'); 641 for(j=ncl; j<=nch; j++) { 642 printf(format, j); 643 } 644 printf("\n"); 645 for(i=nrl; i<=nrh; i++) { 646 printf("[%3d]", i); 647 for(j=ncl; j<=nch; j++) { 648 printf(format, m[i][j]); 649 } 650 printf("\n"); 651 } 652 printf("\n"); 653 } 654 /* --------------------------------------------------------------------------------------------------------------- */ 655 IMAGE_EXPORT(void) display_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 656 /* --------------------------------------------------------------------------------------------------------------- */ 657 { 658 int i,j; 659 660 if(name != NULL) printf(name); 661 662 // 1ere ligne 663 printf("%5c", '#'); 664 for(j=ncl; j<=nch; j++) { 665 printf(format, j); 666 } 667 printf("\n"); 668 for(i=nrl; i<=nrh; i++) { 669 printf("[%3d]", i); 670 for(j=ncl; j<=nch; j++) { 671 printf(format, m[i][j].r, m[i][j].g, m[i][j].b); 672 } 673 printf("\n"); 674 } 675 printf("\n"); 676 } 677 /* ----------------------------------------------------------------------------------------------------------------- */ 678 IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name) 679 /* ----------------------------------------------------------------------------------------------------------------- */ 680 { 681 int i,j; 682 683 if(name != NULL) printf(name); 684 685 // 1ere ligne 686 printf("%5c", '#'); 687 for(j=ncl; j<=nch; j++) { 688 printf(format, j); 689 } 690 printf("\n"); 691 for(i=nrl; i<=nrh; i++) { 692 printf("[%3d]", i); 693 for(j=ncl; j<=nch; j++) { 694 printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x); 695 } 696 printf("\n"); 697 } 698 printf("\n"); 699 } 266 267 700 268 701 269 /* … … 705 273 */ 706 274 707 // ------------------------------------------------------------------------------------------------ 708 void display_si8matrix_positive(sint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 709 // ------------------------------------------------------------------------------------------------ 710 { 711 int i, j; 712 713 char *format, *str; 714 715 select_display_positive_parameters(iformat, &format, &str); 716 717 if(name != NULL) printf(name); 718 719 for(i=i0; i<=i1; i++) { 720 for(j=j0; j<=j1; j++) { 721 if(m[i][j]) { 722 printf(format, m[i][j]); 723 } else { 724 printf("%s", str); 725 } 726 } 727 printf("\n"); 728 } 729 } 730 // ------------------------------------------------------------------------------------------------ 731 void display_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 732 // ------------------------------------------------------------------------------------------------ 733 { 734 int i, j; 735 736 char * format; 737 char * str; 738 739 select_display_positive_parameters(iformat, &format, &str); 740 741 if (name != NULL) { 742 printf("%s\n", name); 743 } 744 745 // @QM have to hack this function for the giet 746 for (i = i0; i <= i1; i++) { 747 for (j = j0; j <= j1; j++) { 748 if (m[i][j]) { 749 // For the giet 750 int a = m[i][j]; 751 int len = 0; 752 if (a == 0) { 753 len = 1; 754 } 755 else { 756 while (a != 0) { 757 a = a / 10; 758 len++; 759 } 760 } 761 for (int k = len; k < iformat; k++) { 762 printf(" "); 763 } 764 printf("%d", m[i][j]); 765 } 766 else { 767 printf("%s", str); 768 } 769 } 770 printf("\n"); 771 } 772 } 773 774 775 // -------------------------------------------------------------------------------------------------- 776 void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 777 // -------------------------------------------------------------------------------------------------- 778 { 779 int i, j; 780 781 char *format, *str; 782 783 select_display_positive_parameters(iformat, &format, &str); 784 785 if(name != NULL) printf(name); 786 787 for(i=i0; i<=i1; i++) { 788 for(j=j0; j<=j1; j++) { 789 if(m[i][j]) { 790 printf(format, m[i][j]); 791 } else { 792 printf("%s", str); 793 } 794 } 795 printf("\n"); 796 } 797 } 798 // -------------------------------------------------------------------------------------------------- 799 void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 800 // -------------------------------------------------------------------------------------------------- 801 { 802 int i, j; 803 char *format, *str; 804 805 select_display_positive_parameters(iformat, &format, &str); 806 807 if(name != NULL) printf(name); 808 809 for(i=i0; i<=i1; i++) { 810 for(j=j0; j<=j1; j++) { 811 if(m[i][j]) { 812 printf(format, m[i][j]); 813 } else { 814 printf("%s", str); 815 } 816 } 817 printf("\n"); 818 } 819 } 820 // -------------------------------------------------------------------------------------------------- 821 void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 822 // -------------------------------------------------------------------------------------------------- 823 { 824 int i, j; 825 char *format, *str; 826 827 select_display_positive_parameters(iformat, &format, &str); 828 829 if(name != NULL) printf(name); 830 831 for(i=i0; i<=i1; i++) { 832 for(j=j0; j<=j1; j++) { 833 if(m[i][j]) { 834 printf(format, m[i][j]); 835 } else { 836 printf("%s", str); 837 } 838 } 839 printf("\n"); 840 } 841 } 842 // -------------------------------------------------------------------------------------------------- 843 void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 844 // -------------------------------------------------------------------------------------------------- 845 { 846 int i, j; 847 char * format; 848 char * str; 849 850 select_display_positive_parameters(iformat, &format, &str); 851 852 if (name != NULL) { 853 printf("%s\n", name); 854 } 855 856 // @QM have to hack this function for the giet 857 for (i = i0; i <= i1; i++) { 858 for (j = j0; j <= j1; j++) { 859 if (m[i][j] != 0) { 860 int a = m[i][j]; 861 int len = 0; 862 if (a == 0) { 863 len = 1; 864 } 865 else { 866 while (a != 0) { 867 a = a / 10; 868 len++; 869 } 870 } 871 for (int k = len; k < iformat; k++) { 872 printf(" "); 873 } 874 printf("%d", m[i][j]); 875 } 876 else { 877 printf("%s", str); 878 } 879 } 880 printf("\n"); 881 } 882 883 } 884 // -------------------------------------------------------------------------------------------------- 885 void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 886 // -------------------------------------------------------------------------------------------------- 887 { 888 int i, j; 889 char *format, *str; 890 891 select_display_positive_parameters(iformat, &format, &str); 892 893 if(name != NULL) printf(name); 894 895 for(i=i0; i<=i1; i++) { 896 for(j=j0; j<=j1; j++) { 897 if(m[i][j]) { 898 printf(format, m[i][j]); 899 } else { 900 printf("%s", str); 901 } 902 } 903 printf("\n"); 904 } 905 } 906 // -------------------------------------------------------------------------------------------------- 907 void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name) 908 // -------------------------------------------------------------------------------------------------- 909 { 910 int i, j; 911 char *format, *str; 912 913 select_display_positive_parameters(iformat, &format, &str); 914 915 if(name != NULL) printf(name); 916 917 for(i=i0; i<=i1; i++) { 918 for(j=j0; j<=j1; j++) { 919 if(m[i][j]) { 920 printf(format, m[i][j]); 921 } else { 922 printf("%s", str); 923 } 924 } 925 printf("\n"); 926 } 927 } 928 275 #if TARGET_OS != GIETVM 276 277 #undef display_type_matrix_positive 278 #define display_type_matrix_positive(t) \ 279 void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \ 280 { \ 281 char * format; \ 282 char * str; \ 283 select_display_positive_parameters(iformat, &format, &str); \ 284 if (name != NULL) { \ 285 printf("%s\n", name); \ 286 } \ 287 for (int32_t i = i0; i <= i1; i++) { \ 288 for (int32_t j = j0; j <= j1; j++) { \ 289 if (m[i][j] != 0) { \ 290 printf(format, m[i][j]); \ 291 } \ 292 else { \ 293 printf("%s", str); \ 294 } \ 295 } \ 296 printf("\n"); \ 297 } \ 298 printf("\n"); \ 299 } 300 301 #else 302 303 #undef display_type_matrix_positive 304 #define display_type_matrix_positive(t) \ 305 void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \ 306 { \ 307 char * format; \ 308 char * str; \ 309 select_display_positive_parameters(iformat, &format, &str); \ 310 if (name != NULL) { \ 311 printf("%s\n", name); \ 312 } \ 313 for (int32_t i = i0; i <= i1; i++) { \ 314 for (int32_t j = j0; j <= j1; j++) { \ 315 if (m[i][j] != 0) { \ 316 int32_t a = m[i][j]; \ 317 int32_t len = 0; \ 318 if (a == 0) { \ 319 len = 1; \ 320 } \ 321 else { \ 322 while (a != 0) { \ 323 a = a / 10; \ 324 len++; \ 325 } \ 326 } \ 327 for (int32_t k = len; k < iformat; k++) { \ 328 printf(" "); \ 329 } \ 330 printf(format, m[i][j]); \ 331 } \ 332 else { \ 333 printf("%s", str); \ 334 } \ 335 } \ 336 printf("\n"); \ 337 } \ 338 printf("\n"); \ 339 } 340 341 #endif 342 343 344 display_type_matrix_positive(int8_t); 345 display_type_matrix_positive(uint8_t); 346 display_type_matrix_positive(int16_t); 347 display_type_matrix_positive(uint16_t); 348 display_type_matrix_positive(int32_t); 349 display_type_matrix_positive(uint32_t); 350 display_type_matrix_positive(int64_t); 351 display_type_matrix_positive(uint64_t); 352 display_type_matrix_positive(float); 353 display_type_matrix_positive(double); 929 354 930 355 … … 974 399 975 400 /* ------------------------------------------------- */ 976 static void ReadPGMrow(int fd, int width, uint8 * line)401 static void ReadPGMrow(int32_t fd, int32_t width, uint8 * line) 977 402 /* ------------------------------------------------- */ 978 403 { 979 read(fd, &line[0], sizeof(uint8 ) * width);404 read(fd, &line[0], sizeof(uint8_t) * width); 980 405 } 981 406 982 407 983 408 /* -------------------------------------------------- */ 984 static void WritePGMrow(uint8 * line, int width, int fd)409 static void WritePGMrow(uint8_t * line, int32_t width, int32_t fd) 985 410 /* -------------------------------------------------- */ 986 411 { 987 write(fd, &line[0], sizeof(uint8 ) * width);412 write(fd, &line[0], sizeof(uint8_t) * width); 988 413 } 989 414 990 415 991 416 /* ----------------------------------------------------------------------------------------------- */ 992 IMAGE_EXPORT(uint8 **)LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)417 uint8_t ** LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch) 993 418 /* ----------------------------------------------------------------------------------------------- */ 994 419 { 995 420 // only for P5 binary type, not for text type 996 421 997 int height, width, gris;998 uint8 ** m;999 int fd;422 int32_t height, width, gris; 423 uint8_t ** m; 424 int32_t fd; 1000 425 1001 426 char buffer[80]; 1002 int i;1003 427 (void) gris; 1004 428 … … 1026 450 m = ui8matrix(*nrl, *nrh, *ncl, *nch); 1027 451 1028 for (i = 0; i < height; i++) {452 for (int32_t i = 0; i < height; i++) { 1029 453 ReadPGMrow(fd, width, m[i]); 1030 454 } … … 1037 461 1038 462 /* ----------------------------------------------------------------------------------------------- */ 1039 IMAGE_EXPORT(void)SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)463 void SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename) 1040 464 /* ----------------------------------------------------------------------------------------------- */ 1041 465 { 1042 int nrow = nrh - nrl + 1;1043 int ncol = nch - ncl + 1;466 int32_t nrow = nrh - nrl + 1; 467 int32_t ncol = nch - ncl + 1; 1044 468 1045 469 char buffer[80]; 1046 470 1047 int fd; 1048 int i; 471 int32_t fd; 1049 472 1050 473 //fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT); … … 1058 481 snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow); 1059 482 write(fd, buffer, strlen(buffer)); 1060 for (i = nrl; i <= nrh; i++) {483 for (int32_t i = nrl; i <= nrh; i++) { 1061 484 WritePGMrow(m[i], ncol, fd); 1062 485 } … … 1068 491 1069 492 493 // Local Variables: 494 // tab-width: 4 495 // c-basic-offset: 4 496 // c-file-offsets:((innamespace . 0)(inline-open . 0)) 497 // indent-tabs-mode: nil 498 // End: 499 500 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 501
Note: See TracChangeset
for help on using the changeset viewer.