| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #ifdef __cplusplus |
| 3 |
|
| extern "C" { |
| 4 |
|
| #endif |
| 5 |
|
| #include "EXTERN.h" |
| 6 |
|
| #include "perl.h" |
| 7 |
|
| #include "XSUB.h" |
| 8 |
|
| #include "imext.h" |
| 9 |
|
| #include "imperl.h" |
| 10 |
|
| #include "imqoi.h" |
| 11 |
|
| |
| 12 |
|
| DEFINE_IMAGER_CALLBACKS; |
| 13 |
|
| |
| 14 |
|
| MODULE = Imager::File::QOI PACKAGE = Imager::File::QOI |
| 15 |
|
| |
| 16 |
|
| Imager::ImgRaw |
| 17 |
|
| i_readqoi(ig, page=0) |
| 18 |
|
| Imager::IO ig |
| 19 |
|
| int page |
| 20 |
|
| |
| 21 |
|
| void |
| 22 |
|
| i_readqoi_multi(ig) |
| 23 |
|
| Imager::IO ig |
| 24 |
|
| PREINIT: |
| 25 |
|
| i_img **imgs; |
| 26 |
|
| int count; |
| 27 |
|
| int i; |
| 28 |
|
| PPCODE: |
| 29 |
0 |
| imgs = i_readqoi_multi(ig, &count); |
| 30 |
0 |
▶ | if (imgs) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (imgs) { |
0 |
0 |
0 |
|
| 31 |
0 |
▶ | EXTEND(SP, count); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, count); |
0 |
0 |
0 |
| EXTEND(SP, count); |
0 |
0 |
0 |
|
| 32 |
0 |
▶ | for (i = 0; i < count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < count; ++i) { |
0 |
0 |
0 |
|
| 33 |
0 |
| SV *sv = sv_newmortal(); |
| 34 |
0 |
| sv_setref_pv(sv, "Imager::ImgRaw", (void *)imgs[i]); |
| 35 |
0 |
| PUSHs(sv); |
| 36 |
|
| } |
| 37 |
0 |
| myfree(imgs); |
| 38 |
|
| } |
| 39 |
|
| |
| 40 |
|
| |
| 41 |
|
| undef_int |
| 42 |
|
| i_writeqoi(im, ig) |
| 43 |
|
| Imager::ImgRaw im |
| 44 |
|
| Imager::IO ig |
| 45 |
|
| |
| 46 |
|
| undef_int |
| 47 |
|
| i_writeqoi_multi(ig, ...) |
| 48 |
|
| Imager::IO ig |
| 49 |
|
| PREINIT: |
| 50 |
|
| int i; |
| 51 |
|
| int img_count; |
| 52 |
|
| i_img **imgs; |
| 53 |
|
| CODE: |
| 54 |
0 |
▶ | if (items < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) |
0 |
0 |
0 |
|
| 55 |
0 |
| croak("Usage: i_writeqoi_multi(ig, images...)"); |
| 56 |
0 |
| img_count = items - 1; |
| 57 |
0 |
| RETVAL = 1; |
| 58 |
0 |
▶ | if (img_count < 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (img_count < 1) { |
0 |
0 |
0 |
|
| 59 |
0 |
| RETVAL = 0; |
| 60 |
0 |
| i_clear_error(); |
| 61 |
0 |
| i_push_error(0, "You need to specify images to save"); |
| 62 |
|
| } |
| 63 |
|
| else { |
| 64 |
0 |
| imgs = mymalloc(sizeof(i_img *) * img_count); |
| 65 |
0 |
▶ | for (i = 0; i < img_count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < img_count; ++i) { |
0 |
0 |
0 |
|
| 66 |
0 |
| SV *sv = ST(1+i); |
| 67 |
0 |
| imgs[i] = NULL; |
| 68 |
0 |
▶ | if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) { |
0 |
0 |
0 |
| if (SvROK(sv) && sv_derived_from(sv, "Imager::ImgRaw")) { |
0 |
0 |
0 |
|
| 69 |
0 |
| imgs[i] = INT2PTR(i_img *, SvIV((SV*)SvRV(sv))); |
| 70 |
|
| } |
| 71 |
|
| else { |
| 72 |
0 |
| i_clear_error(); |
| 73 |
0 |
| i_push_error(0, "Only images can be saved"); |
| 74 |
0 |
| myfree(imgs); |
| 75 |
0 |
| RETVAL = 0; |
| 76 |
0 |
| break; |
| 77 |
|
| } |
| 78 |
|
| } |
| 79 |
0 |
▶ | if (RETVAL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (RETVAL) { |
0 |
0 |
0 |
|
| 80 |
0 |
| RETVAL = i_writeqoi_multi(ig, imgs, img_count); |
| 81 |
|
| } |
| 82 |
0 |
| myfree(imgs); |
| 83 |
|
| } |
| 84 |
|
| OUTPUT: |
| 85 |
|
| RETVAL |
| 86 |
|
| |
| 87 |
|
| BOOT: |
| 88 |
2 |
▶ | PERL_INITIALIZE_IMAGER_CALLBACKS; |
Branch: 3 branches
| Branch | True | False | Total |
| PERL_INITIALIZE_IMAGER_CALLBACKS; |
0 |
2 |
2 |
| PERL_INITIALIZE_IMAGER_CALLBACKS; |
0 |
2 |
2 |
| PERL_INITIALIZE_IMAGER_CALLBACKS; |
0 |
2 |
2 |
|