No Description

001-disable-png.patch 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. --- a/configure.ac
  2. +++ b/configure.ac
  3. @@ -58,9 +58,6 @@ AC_ARG_WITH([tools], [AS_HELP_STRING([--
  4. [build_tools=$withval], [build_tools=yes])
  5. AM_CONDITIONAL(BUILD_TOOLS, [test "x$build_tools" = "xyes" ])
  6. -if test x$build_tools = xyes ; then
  7. - PKG_CHECK_MODULES(png, "libpng")
  8. -fi
  9. dnl --with-tests
  10. AC_ARG_WITH([tests], [AS_HELP_STRING([--with-tests], [build tests [default=no]])],
  11. --- a/qrenc.c
  12. +++ b/qrenc.c
  13. @@ -25,7 +25,6 @@
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. -#include <png.h>
  18. #include <getopt.h>
  19. #include "qrencode.h"
  20. @@ -49,7 +48,6 @@ static unsigned int bg_color[4] = {255,
  21. static int verbose = 0;
  22. enum imageType {
  23. - PNG_TYPE,
  24. EPS_TYPE,
  25. SVG_TYPE,
  26. ANSI_TYPE,
  27. @@ -60,7 +58,7 @@ enum imageType {
  28. ANSIUTF8_TYPE
  29. };
  30. -static enum imageType image_type = PNG_TYPE;
  31. +static enum imageType image_type = SVG_TYPE;
  32. static const struct option options[] = {
  33. {"help" , no_argument , NULL, 'h'},
  34. @@ -96,13 +94,13 @@ static void usage(int help, int longopt)
  35. if(longopt) {
  36. fprintf(stderr,
  37. "Usage: qrencode [OPTION]... [STRING]\n"
  38. -"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
  39. +"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
  40. " -h, --help display the help message. -h displays only the help of short\n"
  41. " options.\n\n"
  42. " -o FILENAME, --output=FILENAME\n"
  43. " write image to FILENAME. If '-' is specified, the result\n"
  44. " will be output to standard output. If -S is given, structured\n"
  45. -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
  46. +" symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
  47. " (suffix is removed from FILENAME, if specified)\n"
  48. " -s NUMBER, --size=NUMBER\n"
  49. " specify module size in dots (pixels). (default=3)\n\n"
  50. @@ -116,9 +114,9 @@ static void usage(int help, int longopt)
  51. " specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
  52. " -d NUMBER, --dpi=NUMBER\n"
  53. " specify the DPI of the generated PNG. (default=72)\n\n"
  54. -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={PNG,EPS,\n"
  55. +" -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={EPS,\n"
  56. " SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
  57. -" specify the type of the generated image. (default=PNG)\n\n"
  58. +" specify the type of the generated image. (default=SVG)\n\n"
  59. " -S, --structured\n"
  60. " make structured symbols. Version must be specified.\n\n"
  61. " -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
  62. @@ -133,7 +131,7 @@ static void usage(int help, int longopt)
  63. " --background=RRGGBB[AA]\n"
  64. " specify foreground/background color in hexadecimal notation.\n"
  65. " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
  66. -" Color output support available only in PNG and SVG.\n"
  67. +" Color output support available only in SVG.\n"
  68. " -V, --version\n"
  69. " display the version number and copyrights of the qrencode.\n\n"
  70. " --verbose\n"
  71. @@ -153,12 +151,12 @@ static void usage(int help, int longopt)
  72. } else {
  73. fprintf(stderr,
  74. "Usage: qrencode [OPTION]... [STRING]\n"
  75. -"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
  76. +"Encode input data in a QR Code and save as a SVG or EPS image.\n\n"
  77. " -h display this message.\n"
  78. " --help display the usage of long options.\n"
  79. " -o FILENAME write image to FILENAME. If '-' is specified, the result\n"
  80. " will be output to standard output. If -S is given, structured\n"
  81. -" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
  82. +" symbols are written to FILENAME-01.svg, FILENAME-02.svg, ...\n"
  83. " (suffix is removed from FILENAME, if specified)\n"
  84. " -s NUMBER specify module size in dots (pixels). (default=3)\n"
  85. " -l {LMQH} specify error correction level from L (lowest) to H (highest).\n"
  86. @@ -166,8 +164,8 @@ static void usage(int help, int longopt)
  87. " -v NUMBER specify the version of the symbol. (default=auto)\n"
  88. " -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n"
  89. " -d NUMBER specify the DPI of the generated PNG. (default=72)\n"
  90. -" -t {PNG,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
  91. -" specify the type of the generated image. (default=PNG)\n"
  92. +" -t {EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\n"
  93. +" specify the type of the generated image. (default=SVG)\n"
  94. " -S make structured symbols. Version must be specified.\n"
  95. " -k assume that the input text contains kanji (shift-jis).\n"
  96. " -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
  97. @@ -178,7 +176,7 @@ static void usage(int help, int longopt)
  98. " --background=RRGGBB[AA]\n"
  99. " specify foreground/background color in hexadecimal notation.\n"
  100. " 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
  101. -" Color output support available only in PNG and SVG.\n"
  102. +" Color output support available only in SVG.\n"
  103. " -V display the version number and copyrights of the qrencode.\n"
  104. " [STRING] input data. If it is not specified, data will be taken from\n"
  105. " standard input.\n"
  106. @@ -253,128 +251,6 @@ static FILE *openFile(const char *outfil
  107. return fp;
  108. }
  109. -static int writePNG(QRcode *qrcode, const char *outfile)
  110. -{
  111. - static FILE *fp; // avoid clobbering by setjmp.
  112. - png_structp png_ptr;
  113. - png_infop info_ptr;
  114. - png_colorp palette;
  115. - png_byte alpha_values[2];
  116. - unsigned char *row, *p, *q;
  117. - int x, y, xx, yy, bit;
  118. - int realwidth;
  119. -
  120. - realwidth = (qrcode->width + margin * 2) * size;
  121. - row = (unsigned char *)malloc((realwidth + 7) / 8);
  122. - if(row == NULL) {
  123. - fprintf(stderr, "Failed to allocate memory.\n");
  124. - exit(EXIT_FAILURE);
  125. - }
  126. -
  127. - if(outfile[0] == '-' && outfile[1] == '\0') {
  128. - fp = stdout;
  129. - } else {
  130. - fp = fopen(outfile, "wb");
  131. - if(fp == NULL) {
  132. - fprintf(stderr, "Failed to create file: %s\n", outfile);
  133. - perror(NULL);
  134. - exit(EXIT_FAILURE);
  135. - }
  136. - }
  137. -
  138. - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
  139. - if(png_ptr == NULL) {
  140. - fprintf(stderr, "Failed to initialize PNG writer.\n");
  141. - exit(EXIT_FAILURE);
  142. - }
  143. -
  144. - info_ptr = png_create_info_struct(png_ptr);
  145. - if(info_ptr == NULL) {
  146. - fprintf(stderr, "Failed to initialize PNG write.\n");
  147. - exit(EXIT_FAILURE);
  148. - }
  149. -
  150. - if(setjmp(png_jmpbuf(png_ptr))) {
  151. - png_destroy_write_struct(&png_ptr, &info_ptr);
  152. - fprintf(stderr, "Failed to write PNG image.\n");
  153. - exit(EXIT_FAILURE);
  154. - }
  155. -
  156. - palette = (png_colorp) malloc(sizeof(png_color) * 2);
  157. - if(palette == NULL) {
  158. - fprintf(stderr, "Failed to allocate memory.\n");
  159. - exit(EXIT_FAILURE);
  160. - }
  161. - palette[0].red = fg_color[0];
  162. - palette[0].green = fg_color[1];
  163. - palette[0].blue = fg_color[2];
  164. - palette[1].red = bg_color[0];
  165. - palette[1].green = bg_color[1];
  166. - palette[1].blue = bg_color[2];
  167. - alpha_values[0] = fg_color[3];
  168. - alpha_values[1] = bg_color[3];
  169. - png_set_PLTE(png_ptr, info_ptr, palette, 2);
  170. - png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
  171. -
  172. - png_init_io(png_ptr, fp);
  173. - png_set_IHDR(png_ptr, info_ptr,
  174. - realwidth, realwidth,
  175. - 1,
  176. - PNG_COLOR_TYPE_PALETTE,
  177. - PNG_INTERLACE_NONE,
  178. - PNG_COMPRESSION_TYPE_DEFAULT,
  179. - PNG_FILTER_TYPE_DEFAULT);
  180. - png_set_pHYs(png_ptr, info_ptr,
  181. - dpi * INCHES_PER_METER,
  182. - dpi * INCHES_PER_METER,
  183. - PNG_RESOLUTION_METER);
  184. - png_write_info(png_ptr, info_ptr);
  185. -
  186. - /* top margin */
  187. - memset(row, 0xff, (realwidth + 7) / 8);
  188. - for(y=0; y<margin * size; y++) {
  189. - png_write_row(png_ptr, row);
  190. - }
  191. -
  192. - /* data */
  193. - p = qrcode->data;
  194. - for(y=0; y<qrcode->width; y++) {
  195. - bit = 7;
  196. - memset(row, 0xff, (realwidth + 7) / 8);
  197. - q = row;
  198. - q += margin * size / 8;
  199. - bit = 7 - (margin * size % 8);
  200. - for(x=0; x<qrcode->width; x++) {
  201. - for(xx=0; xx<size; xx++) {
  202. - *q ^= (*p & 1) << bit;
  203. - bit--;
  204. - if(bit < 0) {
  205. - q++;
  206. - bit = 7;
  207. - }
  208. - }
  209. - p++;
  210. - }
  211. - for(yy=0; yy<size; yy++) {
  212. - png_write_row(png_ptr, row);
  213. - }
  214. - }
  215. - /* bottom margin */
  216. - memset(row, 0xff, (realwidth + 7) / 8);
  217. - for(y=0; y<margin * size; y++) {
  218. - png_write_row(png_ptr, row);
  219. - }
  220. -
  221. - png_write_end(png_ptr, info_ptr);
  222. - png_destroy_write_struct(&png_ptr, &info_ptr);
  223. -
  224. - fclose(fp);
  225. - free(row);
  226. - free(palette);
  227. -
  228. - return 0;
  229. -}
  230. -
  231. static int writeEPS(QRcode *qrcode, const char *outfile)
  232. {
  233. FILE *fp;
  234. @@ -831,9 +707,6 @@ static void qrencode(const unsigned char
  235. }
  236. switch(image_type) {
  237. - case PNG_TYPE:
  238. - writePNG(qrcode, outfile);
  239. - break;
  240. case EPS_TYPE:
  241. writeEPS(qrcode, outfile);
  242. break;
  243. @@ -887,9 +760,6 @@ static void qrencodeStructured(const uns
  244. size_t suffix_size;
  245. switch(image_type) {
  246. - case PNG_TYPE:
  247. - type_suffix = ".png";
  248. - break;
  249. case EPS_TYPE:
  250. type_suffix = ".eps";
  251. break;
  252. @@ -948,9 +818,6 @@ static void qrencodeStructured(const uns
  253. }
  254. switch(image_type) {
  255. - case PNG_TYPE:
  256. - writePNG(p->code, filename);
  257. - break;
  258. case EPS_TYPE:
  259. writeEPS(p->code, filename);
  260. break;
  261. @@ -1062,9 +929,7 @@ int main(int argc, char **argv)
  262. }
  263. break;
  264. case 't':
  265. - if(strcasecmp(optarg, "png") == 0) {
  266. - image_type = PNG_TYPE;
  267. - } else if(strcasecmp(optarg, "eps") == 0) {
  268. + if(strcasecmp(optarg, "eps") == 0) {
  269. image_type = EPS_TYPE;
  270. } else if(strcasecmp(optarg, "svg") == 0) {
  271. image_type = SVG_TYPE;
  272. @@ -1133,11 +998,6 @@ int main(int argc, char **argv)
  273. exit(EXIT_SUCCESS);
  274. }
  275. - if(outfile == NULL && image_type == PNG_TYPE) {
  276. - fprintf(stderr, "No output filename is given.\n");
  277. - exit(EXIT_FAILURE);
  278. - }
  279. -
  280. if(optind < argc) {
  281. intext = (unsigned char *)argv[optind];
  282. length = strlen((char *)intext);
  283. --- a/configure
  284. +++ b/configure
  285. @@ -12646,100 +12646,6 @@ else
  286. BUILD_TOOLS_FALSE=
  287. fi
  288. -if test x$build_tools = xyes ; then
  289. -
  290. -pkg_failed=no
  291. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for png" >&5
  292. -$as_echo_n "checking for png... " >&6; }
  293. -
  294. -if test -n "$png_CFLAGS"; then
  295. - pkg_cv_png_CFLAGS="$png_CFLAGS"
  296. - elif test -n "$PKG_CONFIG"; then
  297. - if test -n "$PKG_CONFIG" && \
  298. - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\"libpng\"\""; } >&5
  299. - ($PKG_CONFIG --exists --print-errors ""libpng"") 2>&5
  300. - ac_status=$?
  301. - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  302. - test $ac_status = 0; }; then
  303. - pkg_cv_png_CFLAGS=`$PKG_CONFIG --cflags ""libpng"" 2>/dev/null`
  304. - test "x$?" != "x0" && pkg_failed=yes
  305. -else
  306. - pkg_failed=yes
  307. -fi
  308. - else
  309. - pkg_failed=untried
  310. -fi
  311. -if test -n "$png_LIBS"; then
  312. - pkg_cv_png_LIBS="$png_LIBS"
  313. - elif test -n "$PKG_CONFIG"; then
  314. - if test -n "$PKG_CONFIG" && \
  315. - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\"libpng\"\""; } >&5
  316. - ($PKG_CONFIG --exists --print-errors ""libpng"") 2>&5
  317. - ac_status=$?
  318. - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  319. - test $ac_status = 0; }; then
  320. - pkg_cv_png_LIBS=`$PKG_CONFIG --libs ""libpng"" 2>/dev/null`
  321. - test "x$?" != "x0" && pkg_failed=yes
  322. -else
  323. - pkg_failed=yes
  324. -fi
  325. - else
  326. - pkg_failed=untried
  327. -fi
  328. -
  329. -
  330. -
  331. -if test $pkg_failed = yes; then
  332. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  333. -$as_echo "no" >&6; }
  334. -
  335. -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
  336. - _pkg_short_errors_supported=yes
  337. -else
  338. - _pkg_short_errors_supported=no
  339. -fi
  340. - if test $_pkg_short_errors_supported = yes; then
  341. - png_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs ""libpng"" 2>&1`
  342. - else
  343. - png_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs ""libpng"" 2>&1`
  344. - fi
  345. - # Put the nasty error message in config.log where it belongs
  346. - echo "$png_PKG_ERRORS" >&5
  347. -
  348. - as_fn_error $? "Package requirements (\"libpng\") were not met:
  349. -
  350. -$png_PKG_ERRORS
  351. -
  352. -Consider adjusting the PKG_CONFIG_PATH environment variable if you
  353. -installed software in a non-standard prefix.
  354. -
  355. -Alternatively, you may set the environment variables png_CFLAGS
  356. -and png_LIBS to avoid the need to call pkg-config.
  357. -See the pkg-config man page for more details." "$LINENO" 5
  358. -elif test $pkg_failed = untried; then
  359. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
  360. -$as_echo "no" >&6; }
  361. - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
  362. -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
  363. -as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
  364. -is in your PATH or set the PKG_CONFIG environment variable to the full
  365. -path to pkg-config.
  366. -
  367. -Alternatively, you may set the environment variables png_CFLAGS
  368. -and png_LIBS to avoid the need to call pkg-config.
  369. -See the pkg-config man page for more details.
  370. -
  371. -To get pkg-config, see <http://pkg-config.freedesktop.org/>.
  372. -See \`config.log' for more details" "$LINENO" 5; }
  373. -else
  374. - png_CFLAGS=$pkg_cv_png_CFLAGS
  375. - png_LIBS=$pkg_cv_png_LIBS
  376. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
  377. -$as_echo "yes" >&6; }
  378. -
  379. -fi
  380. -fi
  381. -
  382. # Check whether --with-tests was given.
  383. if test "${with_tests+set}" = set; then :