From 140d5818fd47db5269db459f8c9f7834812760b1 Mon Sep 17 00:00:00 2001 From: danblooomberg Date: Fri, 2 Jun 2023 22:24:02 -0700 Subject: [PATCH] Add read/write alpha tests to prog/misctest1.c --- prog/elephant-cmap-alpha.png | Bin 0 -> 1280 bytes prog/misctest1.c | 28 +++++++++++++++++++++++++++- prog/notes-rgba.png | Bin 0 -> 2008 bytes 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 prog/elephant-cmap-alpha.png create mode 100644 prog/notes-rgba.png diff --git a/prog/elephant-cmap-alpha.png b/prog/elephant-cmap-alpha.png new file mode 100644 index 0000000000000000000000000000000000000000..588896404b03994e09b78a07d65cf115ee264dff GIT binary patch literal 1280 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`ol6-Q7+C{+LR^8|eZ+y?yLWHcuwnc5 z?TZ&Lo;r2voH=urEn5cEI%CF+`Sa(mUAq>@-m+y2kZgy6Y15`noH!B4Te)&&d3m{k zfq{*U&8AJ8X3w6@$jIp7;nCIA)!*OW*Vm__qSD;l{PpSj2iLY# zP-N4ZX*bWW0y4I3+ctOZT%emF%79!T1I`7h+_Y(7VZaYyK!leB`2{l=6g2FgpCF*{ z|NQ&@_5UHj0Z0Y>zn`#v|9hwijDo7@7dQ`60|El)L1h2`|L+Ul?>Cr#zoFrNfkOZO z8q>8549vlvE{-7;jBls6?s{y&<0hK5y6v>VlGEF*&zw2)=U@M(t+#tcH|_N))^k3e zuDPGH?nC*59rN@#tYUx2eyP!U@t<$9u#&RIm$)b1N!!0m+ejR0NpZ0P%WZL@>&KG)2j zJh~Fu!7WXkvkbpVUteOpC6Uw0DexxKS_?+08W)*Gvg*Ez7;hDFnS5#0aFo7u+0p;@ zn1X}iXH5~10Ekb>K$|Bq~_74&8L(bq^9e~?<@Km z)twPiQl(_OOZDBa)P-4synz#Z&Y#-#Mfzax>_aWSJTKpT)Be7N?ZLITT`$f}-K}Bi zy~&e%k>ckqWzv54cGv%86pM+fmOoY7cka?np37IWT1pq3TYTJqUfiLk^z4hpl5;}0 zZB|;8n6`VNP1VN;+vlwUwgQhAN+xaEJo(S6-0R`q=T85g9=~+)<}F_Jr?;(U`t!q- z^V~DeSDe+mgip?PXV`x4*=8QzA04&J|GGSCdLTQi@R?#;qkL%9yJY_?+g^7?t>g#WK>FJ?7XS-qKZvgyGTxfh&Dv!Y~o%Ir5%+g@_zhr_d5 z3Et};vu>1{6fR`1w&;jgi1Lr6*9!f=%{uoWU$`T;fyxD$25d*!=$B z@m1;fDVO^v2V^Qb#!5;=WtWM9wR1{w3TGL_GaYem!;}uVDJ7 zt$nj9n*u{wHg3Bslx{OkD(+^3OXm8SCrnc(34T0fcXEaH#AMw^;m0Lw8T1~NwkNP~ z@4L^W_KT(Iz^`pK>vEgqJwE)9exJawP08+8{`S1PlcWxA+81=YWpkhK?}HLLFWTC+ t9+FD$Y}&xQfA+@bm2>s}Jm7zt-kZ@^U~_%V17Hqj@O1TaS?83{1OS7Wr!D{h literal 0 HcmV?d00001 diff --git a/prog/misctest1.c b/prog/misctest1.c index 59a277779..32dbd6377 100644 --- a/prog/misctest1.c +++ b/prog/misctest1.c @@ -39,6 +39,7 @@ * * Test zlib compression in png * * Show sampled scaling with and without source indexing shift * * Display differences in images with pixDisplayDiff() + * * Demonstrate read of cmap+alpha png, and I/O of rgba pnm, bmp, webp */ #ifdef HAVE_CONFIG_H @@ -54,7 +55,7 @@ static const size_t zlibsize[5] = {1047868, 215039, 195778, 189709, 180987}; int main(int argc, char **argv) { -l_int32 w, h, bx, by, bw, bh, i, j; +l_int32 w, h, bx, by, bw, bh, i, j, same; size_t size; BOX *box1, *box2; BOXA *boxa1, *boxa2, *boxae, *boxao; @@ -386,5 +387,30 @@ PIXCMAP *cmap, *cmapg; pixDestroy(&pix3); pixDestroy(&pix4); + /* Demonstrate read of cmap+alpha png, and I/O of rgba pnm, bmp, webp */ + pix1 = pixRead("elephant-cmap-alpha.png"); /* has colormap */ + pixDisplay(pix1, 1300, 800); + pixWrite("/tmp/lept/misc/e.pnm", pix1, IFF_PNM); + pixWrite("/tmp/lept/misc/e.bmp", pix1, IFF_BMP); + #if HAVE_LIBWEBP + pixWrite("/tmp/lept/misc/e.webp", pix1, IFF_WEBP); + #endif /* HAVE_LIBWEBP */ + pix2 = pixRead("/tmp/lept/misc/e.pnm"); + pixEqual(pix1, pix2, &same); + lept_stderr("png vs pnm same? (yes): %d\n", same); + pixDestroy(&pix2); + pix2 = pixRead("/tmp/lept/misc/e.bmp"); + pixEqual(pix1, pix2, &same); + lept_stderr("png vs bmp same? (yes): %d\n", same); + pixDestroy(&pix2); + #if HAVE_LIBWEBP + pix2 = pixRead("/tmp/lept/misc/e.webp"); + pixDisplay(pix2, 1440, 800); /* interesting change in rgb layer */ + pixEqual(pix1, pix2, &same); + lept_stderr("png vs webp same? (no): %d\n", same); + pixDestroy(&pix2); + #endif /* HAVE_LIBWEBP */ + pixDestroy(&pix1); + return 0; } diff --git a/prog/notes-rgba.png b/prog/notes-rgba.png new file mode 100644 index 0000000000000000000000000000000000000000..c9d9b0705527de10919e4ef8341bbb4d4a57ce80 GIT binary patch literal 2008 zcmV;}2PgQ6P)a|kzNN>RUiG`($x*oa2IY+5f zmcro>8B0uE(RF=xm^i(N5WtK?$XI;tO-0eqJ={MO z2mqLd5t|xYxS?s$W5dSkCMr=xqcKd59{sJNC``N1#@u*v@;U%xxK!Ku zH9wo{MM88WI+}=1-vsc*)|i2IE!(#10Q}a^kR(Ykjp&JFZ2C8WWWGn7bGVLMCm?>y zUr`mrqDj>VCw|!)H_#oiEGw1HZ!9pMeLx6#u=q_Q_H7_E6A%LcfOCOzrIOmpuP*@N z1E2|`X&Oe%@ zJ1+@f82~6H&{dtvRDE$^kUgqwW!8R3X*103r!r*Bwkj5jm0Tfxh7wXHgtQiq4g|1k z6-w!=cBB3Y(41lb++kyOQaXKq&G-Gw&2Iu6ya5CN0zl*n>E9DV;QKy&;FADic2udn z{UJcWxd5fO2?PTI+qM7AIfr96{^`24+d;(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