X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=contrib%2Fgregbook%2Frpng2-x.c;h=a146ef4173f017c3722df29882e185cd9bc22655;hb=361fb099aa967c1618d8071268abab395e67e86a;hp=873af2335432694120f4470871efa8d1d597fbe6;hpb=5ab0f6df7ecb95c9b816ece7a88a8df92b0cb2af;p=platform%2Fupstream%2Flibpng.git diff --git a/contrib/gregbook/rpng2-x.c b/contrib/gregbook/rpng2-x.c index 873af23..a146ef4 100644 --- a/contrib/gregbook/rpng2-x.c +++ b/contrib/gregbook/rpng2-x.c @@ -40,7 +40,12 @@ - 2.02: fixed improper display of usage screen on PNG error(s); fixed unexpected-EOF and file-read-error cases; fixed Trace() cut-and- paste bugs + - 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings + about unused variables (GR-P) + TO DO: + use nanosleep() instead of usleep(), which is obsolete/deprecated. --------------------------------------------------------------------------- Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. @@ -94,9 +99,12 @@ #define PROGNAME "rpng2-x" #define LONGNAME "Progressive PNG Viewer for X" -#define VERSION "2.02 of 16 March 2008" -#define RESNAME "rpng2" /* our X resource application name */ -#define RESCLASS "Rpng" /* our X resource class name */ +#define VERSION "2.04 of 15 June 2014" +#define RESNAME "rpng2" /* our X resource application name */ +#define RESCLASS "Rpng" /* our X resource class name */ + +/* This is temporary until the code is rewritten to use nanosleep(). */ +#define usleep(x) sleep(((x)+499999)/1000000) #include #include @@ -131,7 +139,7 @@ (e.type == KeyPress && /* v--- or 1 for shifted keys */ \ ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape))) -#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */ +#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */ #define rgb1_max bg_freq #define rgb1_min bg_gray @@ -301,7 +309,7 @@ int main(int argc, char **argv) int have_bg = FALSE; #ifdef FEATURE_LOOP int loop = FALSE; - long loop_interval = -1; /* seconds (100,000 max) */ + long loop_interval = -1; /* seconds (100,000 max) */ #endif double LUT_exponent; /* just the lookup table */ double CRT_exponent = 2.2; /* just the monitor */ @@ -435,18 +443,6 @@ int main(int argc, char **argv) loop_interval = 100000; } #endif -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif } else { if (**argv != '-') { filename = *argv; @@ -467,50 +463,47 @@ int main(int argc, char **argv) fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng2_version_info(); fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif + "Usage: "); + fprintf(stderr, + "%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" + " %*s [-usleep dur | -timing] [-pause]\n", + PROGNAME, (int)strlen(PROGNAME), " "); + fprintf(stderr, #ifdef FEATURE_LOOP - " %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n" -#else - " %*s [-usleep dur | -timing] [-pause] file.png\n\n" + " [-loop [sec]]" #endif + " file.png\n\n"); + fprintf(stderr, " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" " exp \ttransfer-function exponent (``gamma'') of the display\n" "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t to the product of the lookup-table exponent (varies)\n", + default_display_exponent); + fprintf(stderr, "\t\t and the CRT exponent (usually 2.2); must be positive\n" " bg \tdesired background color in 7-character hex RGB format\n" "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t used with transparent images; overrides -bgpat\n" " pat \tdesired background pattern number (0-%d); used with\n" - "\t\t transparent images; overrides -bgcolor\n" + "\t\t transparent images; overrides -bgcolor\n", + num_bgpat-1); #ifdef FEATURE_LOOP + fprintf(stderr, " -loop\tloops through background images after initial display\n" "\t\t is complete (depends on -bgpat)\n" - " sec \tseconds to display each background image (default = 2)\n" -#endif -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" + " sec \tseconds to display each background image (default = 2)\n"); #endif + fprintf(stderr, " dur \tduration in microseconds to wait after displaying each\n" "\t\t row (for demo purposes)\n" " -timing\tenables delay for every block read, to simulate modem\n" "\t\t download of image (~36 Kbps)\n" " -pause\tpauses after displaying each pass until mouse clicked\n" "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - (int)strlen(PROGNAME), " ", -#endif - (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1); + "is displayed) to quit.\n"); exit(1); } - if (!(infile = fopen(filename, "rb"))) { fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); ++error; @@ -612,7 +605,7 @@ int main(int argc, char **argv) "(unexpectedly) while reading PNG image file\n"); exit(3); } else /* if (error) */ { - // will print error message below + /* will print error message below */ } break; } @@ -756,6 +749,8 @@ int main(int argc, char **argv) Trace((stderr, "about to call rpng2_x_cleanup()\n")) rpng2_x_cleanup(); + (void)argc; /* Unused */ + return 0; } @@ -802,8 +797,9 @@ static void rpng2_x_init(void) if (rpng2_x_create_window()) { /* GRR TEMPORARY HACK: this is fundamentally no different from cases - * above; libpng should longjmp() back to us when png_ptr goes away. - * If we/it segfault instead, seems like a libpng bug... */ + * above; libpng should call our error handler to longjmp() back to us + * when png_ptr goes away. If we/it segfault instead, seems like a + * libpng bug... */ /* we're here via libpng callback, so if window fails, clean and bail */ readpng2_cleanup(&rpng2_info); @@ -1297,7 +1293,7 @@ static int rpng2_x_load_bg_image(void) for (row = 0; row < rpng2_info.height; ++row) { src = bg_data + row*bg_rowbytes; dest = ximage->data + row*ximage_rowbytes; - if (bpp == 32) { /* slightly optimized version */ + if (bpp == 32) { /* slightly optimized version */ for (i = rpng2_info.width; i > 0; --i) { red = *src++; green = *src++; @@ -1846,6 +1842,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow, XFlush(display); } + (void)startcol; + (void)width; + } /* end function rpng2_x_redisplay_image() */