亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? rpng-win.c

?? 教你如何簡單顯示一章TIFF位圖,分析的很透徹,很適合出學(xué)者.希望能給你帶來幫助!
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*---------------------------------------------------------------------------

   rpng - simple PNG display program                             rpng-win.c

   This program decodes and displays PNG images, with gamma correction and
   optionally with a user-specified background color (in case the image has
   transparency).  It is very nearly the most basic PNG viewer possible.
   This version is for 32-bit Windows; it may compile under 16-bit Windows
   with a little tweaking (or maybe not).

   to do:
    - stdout/stderr don't work!  need message window (maybe scrollable?)
    - handle quoted command-line args (especially filenames with spaces)
    - have minimum window width:  oh well
    - use %.1023s to simplify truncation of title-bar string?

  ---------------------------------------------------------------------------

      Copyright (c) 1998-1999 Greg Roelofs.  All rights reserved.

      This software is provided "as is," without warranty of any kind,
      express or implied.  In no event shall the author or contributors
      be held liable for any damages arising in any way from the use of
      this software.

      Permission is granted to anyone to use this software for any purpose,
      including commercial applications, and to alter it and redistribute
      it freely, subject to the following restrictions:

      1. Redistributions of source code must retain the above copyright
         notice, disclaimer, and this list of conditions.
      2. Redistributions in binary form must reproduce the above copyright
         notice, disclaimer, and this list of conditions in the documenta-
         tion and/or other materials provided with the distribution.
      3. All advertising materials mentioning features or use of this
         software must display the following acknowledgment:

            This product includes software developed by Greg Roelofs
            and contributors for the book, "PNG: The Definitive Guide,"
            published by O'Reilly and Associates.

  ---------------------------------------------------------------------------*/

#define PROGNAME  "rpng-win"
#define LONGNAME  "Simple PNG Viewer for Windows"
#define VERSION   "1.0 of 20 February 1999"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <windows.h>

/* #define DEBUG  :  this enables the Trace() macros */

#include "readpng.h"	/* typedefs, common macros, readpng prototypes */


/* could just include png.h, but this macro is the only thing we need
 * (name and typedefs changed to local versions); note that side effects
 * only happen with alpha (which could easily be avoided with
 * "ush acopy = (alpha);") */

#define alpha_composite(composite, fg, alpha, bg) {			\
    ush temp = ((ush)(fg)*(ush)(alpha) +				\
                (ush)(bg)*(ush)(255 - (ush)(alpha)) + (ush)128);	\
    (composite) = (uch)((temp + (temp >> 8)) >> 8);			\
}


/* local prototypes */
static int        rpng_win_create_window(HINSTANCE hInst, int showmode);
static int        rpng_win_display_image(void);
static void       rpng_win_cleanup(void);
LRESULT CALLBACK  rpng_win_wndproc(HWND, UINT, WPARAM, LPARAM);


static char titlebar[1024], *window_name = titlebar;
static char *progname = PROGNAME;
static char *appname = LONGNAME;
static char *icon_name = PROGNAME;	/* GRR:  not (yet) used */
static char *filename;
static FILE *infile;

static char *bgstr;
static uch bg_red=0, bg_green=0, bg_blue=0;

static double display_exponent;

static ulg image_width, image_height, image_rowbytes;
static int image_channels;
static uch *image_data;

/* Windows-specific variables */
static ulg wimage_rowbytes;
static uch *dib;
static uch *wimage_data;
static BITMAPINFOHEADER *bmih;

static HWND global_hwnd;




int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
{
    char *args[1024];		/* arbitrary limit, but should suffice */
    char *p, *q, **argv = args;
    int argc = 0;
    int rc, alen, flen;
    int error = 0;
    int have_bg = FALSE;
    double LUT_exponent;		/* just the lookup table */
    double CRT_exponent = 2.2;		/* just the monitor */
    double default_display_exponent;	/* whole display system */
    MSG msg;


    filename = (char *)NULL;


    /* First set the default value for our display-system exponent, i.e.,
     * the product of the CRT exponent and the exponent corresponding to
     * the frame-buffer's lookup table (LUT), if any.  This is not an
     * exhaustive list of LUT values (e.g., OpenStep has a lot of weird
     * ones), but it should cover 99% of the current possibilities.  And
     * yes, these ifdefs are completely wasted in a Windows program... */

#if defined(NeXT)
    LUT_exponent = 1.0 / 2.2;
    /*
    if (some_next_function_that_returns_gamma(&next_gamma))
        LUT_exponent = 1.0 / next_gamma;
     */
#elif defined(sgi)
    LUT_exponent = 1.0 / 1.7;
    /* there doesn't seem to be any documented function to get the
     * "gamma" value, so we do it the hard way */
    infile = fopen("/etc/config/system.glGammaVal", "r");
    if (infile) {
        double sgi_gamma;

        fgets(tmpline, 80, infile);
        fclose(infile);
        sgi_gamma = atof(tmpline);
        if (sgi_gamma > 0.0)
            LUT_exponent = 1.0 / sgi_gamma;
    }
#elif defined(Macintosh)
    LUT_exponent = 1.8 / 2.61;
    /*
    if (some_mac_function_that_returns_gamma(&mac_gamma))
        LUT_exponent = mac_gamma / 2.61;                 
     */
#else
    LUT_exponent = 1.0;   /* assume no LUT:  most PCs */
#endif

    /* the defaults above give 1.0, 1.3, 1.5 and 2.2, respectively: */
    default_display_exponent = LUT_exponent * CRT_exponent;


    /* If the user has set the SCREEN_GAMMA environment variable as suggested
     * (somewhat imprecisely) in the libpng documentation, use that; otherwise
     * use the default value we just calculated.  Either way, the user may
     * override this via a command-line option. */

    if ((p = getenv("SCREEN_GAMMA")) != NULL)
        display_exponent = atof(p);
    else
        display_exponent = default_display_exponent;


    /* Windows really hates command lines, so we have to set up our own argv.
     * Note that we do NOT bother with quoted arguments here, so don't use
     * filenames with spaces in 'em! */

    argv[argc++] = PROGNAME;
    p = cmd;
    for (;;) {
        if (*p == ' ')
            while (*++p == ' ')
                ;
        /* now p points at the first non-space after some spaces */
        if (*p == '\0')
            break;    /* nothing after the spaces:  done */
        argv[argc++] = q = p;
        while (*q && *q != ' ')
            ++q;
        /* now q points at a space or the end of the string */
        if (*q == '\0')
            break;    /* last argv already terminated; quit */
        *q = '\0';    /* change space to terminator */
        p = q + 1;
    }
    argv[argc] = NULL;   /* terminate the argv array itself */


    /* Now parse the command line for options and the PNG filename. */

    while (*++argv && !error) {
        if (!strcmp(*argv, "-gamma")) {
            if (!*++argv)
                ++error;
            display_exponent = atof(*argv);
            if (display_exponent <= 0.0)
                ++error;
        } else if (!strcmp(*argv, "-bgcolor")) {
            if (!*++argv)
                ++error;
            bgstr = *argv;
            if (strlen(bgstr) != 7 || bgstr[0] != '#')
                ++error;
            else
                have_bg = TRUE;
        } else {
            if (**argv != '-') {
                filename = *argv;
                if (argv[1])   /* shouldn't be any more args after filename */
                    ++error;
            } else
                ++error;   /* not expecting any other options */
        }
    }

    if (!filename) {
        ++error;
    } else if (!(infile = fopen(filename, "rb"))) {
        fprintf(stderr, PROGNAME ":  can't open PNG file [%s]\n", filename);
        ++error;
    } else {
        if ((rc = readpng_init(infile, &image_width, &image_height)) != 0) {
            switch (rc) {
                case 1:
                    fprintf(stderr, PROGNAME
                      ":  [%s] is not a PNG file: incorrect signature\n",
                      filename);
                    break;
                case 2:
                    fprintf(stderr, PROGNAME
                      ":  [%s] has bad IHDR (libpng longjmp)\n",
                      filename);
                    break;
                case 4:
                    fprintf(stderr, PROGNAME ":  insufficient memory\n");
                    break;
                default:
                    fprintf(stderr, PROGNAME
                      ":  unknown readpng_init() error\n");
                    break;
            }
            ++error;
        }
        if (error)
            fclose(infile);
    }

    if (error) {
        fprintf(stderr, "\n%s %s:  %s\n", PROGNAME, VERSION, appname);
        readpng_version_info();
        fprintf(stderr, "\n"
         "Usage:  %s [-gamma exp] [-bgcolor bg] file.png\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  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., ``#ff7f00'' for orange:  same as HTML colors);\n"
         "\t\t  used with transparent images\n"
         "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
         "\n", PROGNAME, default_display_exponent);
        exit(1);
    }


    /* set the title-bar string, but make sure buffer doesn't overflow */

    alen = strlen(appname);
    flen = strlen(filename);
    if (alen + flen + 3 > 1023)
        sprintf(titlebar, "%s:  ...%s", appname, filename+(alen+flen+6-1023));
    else
        sprintf(titlebar, "%s:  %s", appname, filename);


    /* if the user didn't specify a background color on the command line,
     * check for one in the PNG file--if not, the initialized values of 0
     * (black) will be used */

    if (have_bg)
        sscanf(bgstr+1, "%2x%2x%2x", &bg_red, &bg_green, &bg_blue);
    else if (readpng_get_bgcolor(&bg_red, &bg_green, &bg_blue) > 1) {
        readpng_cleanup(TRUE);
        fprintf(stderr, PROGNAME
          ":  libpng error while checking for background color\n");
        exit(2);
    }


    /* do the basic Windows initialization stuff, make the window and fill it
     * with the background color */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美色爱综合网| 日韩一区欧美小说| 色婷婷av一区二区三区大白胸| 国v精品久久久网| 久久久久久99久久久精品网站| 精品一区二区三区免费毛片爱| 亚洲国产精品t66y| 欧美视频精品在线| 黄色日韩网站视频| 亚洲精品欧美专区| 精品福利视频一区二区三区| 91网站最新地址| 国产精品美女视频| 制服丝袜中文字幕一区| caoporm超碰国产精品| 免费在线看成人av| 一区二区三区在线视频免费观看| 欧美zozo另类异族| 欧美三级蜜桃2在线观看| 国产精品一区久久久久| 亚洲在线成人精品| 欧美精品vⅰdeose4hd| 亚洲激情自拍视频| 欧美日韩电影一区| 亚洲成人av一区| 欧美在线色视频| 亚洲人妖av一区二区| 丰满少妇久久久久久久| 国产精品热久久久久夜色精品三区 | 香蕉久久夜色精品国产使用方法 | 久久婷婷国产综合国色天香| 日韩三级电影网址| 久久品道一品道久久精品| 中文字幕在线观看不卡| 欧美成人在线直播| 欧美丝袜丝交足nylons图片| 国产成人8x视频一区二区| 亚洲午夜电影在线| 国产精品久久久久影院色老大| 精品免费视频.| 成人在线综合网站| 蜜桃一区二区三区四区| 亚洲永久精品大片| 一区二区三区美女视频| |精品福利一区二区三区| 日韩视频国产视频| 7777精品伊人久久久大香线蕉超级流畅| 91黄色免费网站| 国产精品系列在线播放| 国产乱码一区二区三区| 成人国产视频在线观看| www.日韩精品| 在线看一区二区| 欧美日韩国产综合视频在线观看 | 91在线观看视频| 日本高清视频一区二区| 欧美午夜电影在线播放| 欧美亚日韩国产aⅴ精品中极品| 欧美日韩视频专区在线播放| 五月天国产精品| 亚洲精品高清在线| 免费不卡在线观看| 丝袜诱惑制服诱惑色一区在线观看 | 在线观看一区二区精品视频| 国产成人鲁色资源国产91色综| 美女脱光内衣内裤视频久久影院| 国产综合久久久久影院| 婷婷国产在线综合| 亚洲狠狠爱一区二区三区| 爽好多水快深点欧美视频| 精品亚洲porn| 99综合电影在线视频| 欧美亚洲禁片免费| 精品区一区二区| 国产精品乱码久久久久久| 亚洲欧美日韩国产中文在线| 丝袜诱惑亚洲看片| 国产盗摄女厕一区二区三区| 94-欧美-setu| 日韩一区二区电影| 国产精品久久久久久妇女6080| 亚洲午夜久久久| 美美哒免费高清在线观看视频一区二区| 国产乱人伦偷精品视频不卡 | 亚洲欧美另类小说| 奇米精品一区二区三区四区| youjizz久久| 欧美一级久久久| 中文字幕一区二区三区乱码在线| 午夜电影网亚洲视频| 国内精品免费**视频| 欧美亚洲综合网| 久久麻豆一区二区| 亚洲aⅴ怡春院| 成人av免费观看| 精品捆绑美女sm三区| 亚洲男人的天堂在线观看| 久热成人在线视频| 在线视频欧美精品| 亚洲自拍偷拍九九九| 激情成人综合网| 欧美日韩免费在线视频| 国产精品午夜免费| 久久99国产精品免费| 欧美伊人久久久久久久久影院| 久久九九国产精品| 日韩精品视频网| 日本高清不卡一区| 欧美一区二区精品久久911| 国产精品美女一区二区三区| 欧美午夜寂寞影院| 亚洲电影在线免费观看| 日本高清成人免费播放| 一区二区在线观看视频| 99久久综合99久久综合网站| 国产婷婷色一区二区三区四区| 五月综合激情婷婷六月色窝| 色妞www精品视频| 久久综合丝袜日本网| 在线亚洲高清视频| 欧美一区二区久久| 亚洲午夜久久久久久久久久久 | 国产在线视视频有精品| 在线精品亚洲一区二区不卡| 国产精品久久久久一区二区三区共| 久久精工是国产品牌吗| 日韩欧美国产小视频| 石原莉奈在线亚洲二区| 欧美在线免费视屏| 一二三区精品福利视频| 91色视频在线| 亚洲精选免费视频| 色av一区二区| 一区二区三区日韩| 色94色欧美sute亚洲线路一久| 亚洲人成在线观看一区二区| 99国产精品视频免费观看| 亚洲一区二区三区免费视频| 99精品久久99久久久久| 国产精品美女久久久久久久久久久 | 亚洲视频一区在线观看| 日韩av中文在线观看| 4438x亚洲最大成人网| 亚洲综合精品久久| 91福利在线免费观看| 亚洲女同女同女同女同女同69| 日本精品一区二区三区高清| 亚洲三级电影网站| 成人免费视频app| 久久亚洲一区二区三区四区| 日韩电影免费一区| 欧美精品一区二区不卡| 精品一区二区三区在线观看 | 久久99久久久欧美国产| 欧美精品色一区二区三区| 亚洲午夜精品网| 国产91对白在线观看九色| 欧美一区二区三区影视| 日韩一区二区高清| 欧美日韩亚洲不卡| 国产成人在线免费观看| 亚洲精选一二三| 久久蜜桃av一区精品变态类天堂 | 五月天网站亚洲| 加勒比av一区二区| 日韩欧美在线网站| 久久精品国产精品亚洲精品| 日韩午夜在线观看| 久久超级碰视频| 国产日韩亚洲欧美综合| 91精品国产黑色紧身裤美女| 亚洲高清免费观看高清完整版在线观看| 在线观看视频一区二区欧美日韩| 亚洲日本中文字幕区| 欧美一级一区二区| 国产河南妇女毛片精品久久久 | 国产日韩影视精品| 99天天综合性| 日本欧美加勒比视频| 久久亚洲影视婷婷| 成人18视频日本| 亚洲在线视频免费观看| 日韩女优av电影在线观看| 国产精品一区二区三区99| 综合分类小说区另类春色亚洲小说欧美 | 久久久国产精品午夜一区ai换脸| 91在线国产福利| 亚洲chinese男男1069| 久久综合五月天婷婷伊人| 91麻豆国产在线观看| 午夜久久久影院| 国产日产欧美一区| 成人一区二区三区视频 | 国产午夜亚洲精品午夜鲁丝片| 欧美天堂一区二区三区| 国产一区二区三区不卡在线观看 | 综合精品久久久| 欧美一区二区三区影视| 日韩av电影一区| 亚洲精品中文在线影院|