⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libmng_hlapi.c

📁 开源组态软件
💻 C
📖 第 1 页 / 共 5 页
字号:
    {"mng_putchunk_mend",          1, 0, 0},
    {"mng_putchunk_mhdr",          1, 0, 0},
    {"mng_putchunk_move",          1, 0, 0},
#ifndef MNG_SKIPCHUNK_nEED
    {"mng_putchunk_need",          1, 0, 0},
#endif
#ifndef MNG_NO_DELTA_PNG
#ifndef MNG_SKIPCHUNK_ORDR
    {"mng_putchunk_ordr",          1, 0, 0},
    {"mng_putchunk_ordr_entry",    1, 0, 0},
#endif
#endif
#ifndef MNG_SKIPCHUNK_PAST
    {"mng_putchunk_past",          1, 0, 0},
    {"mng_putchunk_past_src",      1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_pHYg
    {"mng_putchunk_phyg",          1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_pHYs
    {"mng_putchunk_phys",          1, 0, 0},
#endif
#ifndef MNG_NO_DELTA_PNG
    {"mng_putchunk_plte",          1, 0, 0},
    {"mng_putchunk_pplt",          1, 0, 0},
    {"mng_putchunk_pplt_entry",    1, 0, 0},
    {"mng_putchunk_prom",          1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_SAVE
    {"mng_putchunk_save",          1, 0, 0},
    {"mng_putchunk_save_entry",    1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_sBIT
    {"mng_putchunk_sbit",          1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_SEEK
    {"mng_putchunk_seek",          1, 0, 0},
#endif
    {"mng_putchunk_show",          1, 0, 0},
#ifndef MNG_SKIPCHUNK_sPLT
    {"mng_putchunk_splt",          1, 0, 0},
#endif
    {"mng_putchunk_srgb",          1, 0, 0},
    {"mng_putchunk_term",          1, 0, 0},
#ifndef MNG_SKIPCHUNK_tEXt
    {"mng_putchunk_text",          1, 0, 0},
#endif
#ifndef MNG_SKIPCHUNK_tIME
    {"mng_putchunk_time",          1, 0, 0},
#endif
    {"mng_putchunk_trns",          1, 0, 0},
    {"mng_putchunk_unkown",        1, 0, 0},
#ifndef MNG_SKIPCHUNK_zTXt
    {"mng_putchunk_ztxt",          1, 0, 0},
#endif
    {"mng_putimgdata_ihdr",        0, 0, 0},
    {"mng_putimgdata_jhdr",        0, 0, 0},
    {"mng_reset",                  1, 0, 0},
    {"mng_read",                   1, 0, 0},
    {"mng_read_pushchunk",         1, 0, 8},
    {"mng_read_pushdata",          1, 0, 8},
    {"mng_read_pushsig",           1, 0, 8},
    {"mng_read_resume",            1, 0, 0},
    {"mng_readdisplay",            1, 0, 0},
    {"mng_set_bgcolor",            1, 0, 0},
    {"mng_set_bkgdstyle",          1, 0, 0},
    {"mng_set_cacheplayback",      1, 0, 2},
    {"mng_set_canvasstyle",        1, 0, 0},
    {"mng_set_dfltimggamma",       1, 0, 0},
#ifndef MNG_NO_DFLT_INFO
    {"mng_set_dfltimggammaint",    1, 0, 0},
#endif
    {"mng_set_displaygamma",       1, 0, 0},
    {"mng_set_displaygammaint",    1, 0, 0},
    {"mng_set_doprogressive",      1, 0, 2},
#ifdef MNG_ACCESS_JPEG
    {"mng_set_jpeg_dctmethod",     1, 0, 0},
    {"mng_set_jpeg_maxjdat",       1, 0, 0},
    {"mng_set_jpeg_optimized",     1, 0, 0},
    {"mng_set_jpeg_progressive",   1, 0, 0},
    {"mng_set_jpeg_quality",       1, 0, 0},
    {"mng_set_jpeg_smoothing",     1, 0, 0},
#endif
#ifndef MNG_SKIP_MAXCANVAS
    {"mng_set_maxcanvasheight",    1, 0, 0},
    {"mng_set_maxcanvassize",      1, 0, 0},
    {"mng_set_maxcanvaswidth",     1, 0, 0},
#endif
    {"mng_set_outputprofile",      1, 0, 0},
    {"mng_set_outputprofile2",     1, 0, 0},
    {"mng_set_outputsrgb",         1, 0, 1},
    {"mng_set_sectionbreaks",      1, 0, 0},
    {"mng_set_speed",              1, 0, 0},
    {"mng_set_srgb",               1, 0, 0},
    {"mng_set_srgbimplicit",       1, 0, 1},
    {"mng_set_srgbprofile",        1, 0, 0},
    {"mng_set_srgbprofile2",       1, 0, 0},
    {"mng_set_storechunks",        1, 0, 0},
    {"mng_set_suspensionmode",     1, 0, 0},
    {"mng_set_usebkgd",            1, 0, 0},
    {"mng_set_userdata",           1, 0, 0},
#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
    {"mng_set_viewgamma",          1, 0, 0},
    {"mng_set_viewgammaint",       1, 0, 0},
#endif
#ifdef MNG_ACCESS_ZLIB
    {"mng_set_zlib_level",         1, 0, 0},
    {"mng_set_zlib_maxidat",       1, 0, 0},
    {"mng_set_zlib_memlevel",      1, 0, 0},
    {"mng_set_zlib_method",        1, 0, 0},
    {"mng_set_zlib_strategy",      1, 0, 0},
    {"mng_set_zlib_windowbits",    1, 0, 0},
#endif
#ifndef MNG_NO_OPEN_CLOSE_STREAM
    {"mng_setcb_closestream",      1, 0, 0},
#endif
    {"mng_setcb_errorproc",        1, 0, 0},
    {"mng_setcb_getalphaline",     1, 0, 0},
    {"mng_setcb_getbkgdline",      1, 0, 0},
    {"mng_setcb_getcanvasline",    1, 0, 0},
    {"mng_setcb_gettickcount",     1, 0, 0},
    {"mng_setcb_memalloc",         1, 0, 0},
    {"mng_setcb_memfree",          1, 0, 0},
#ifndef MNG_NO_OPEN_CLOSE_STREAM
    {"mng_setcb_openstream",       1, 0, 0},
#endif
    {"mng_setcb_processarow",      1, 0, 0},
    {"mng_setcb_processchroma",    1, 0, 0},
    {"mng_setcb_processgamma",     1, 0, 0},
    {"mng_setcb_processheader",    1, 0, 0},
    {"mng_setcb_processiccp",      1, 0, 0},
    {"mng_setcb_processmend",      1, 0, 1},
    {"mng_setcb_processneed",      1, 0, 0},
    {"mng_setcb_processsave",      1, 0, 0},
    {"mng_setcb_processseek",      1, 0, 0},
    {"mng_setcb_processsrgb",      1, 0, 0},
    {"mng_setcb_processterm",      1, 0, 2},
    {"mng_setcb_processtext",      1, 0, 0},
    {"mng_setcb_processunknown",   1, 0, 0},
    {"mng_setcb_readdata",         1, 0, 0},
    {"mng_setcb_refresh",          1, 0, 0},
    {"mng_setcb_releasedata",      1, 0, 8},
    {"mng_setcb_settimer",         1, 0, 0},
    {"mng_setcb_traceproc",        1, 0, 0},
    {"mng_setcb_writedata",        1, 0, 0},
    {"mng_status_creating",        1, 0, 0},
    {"mng_status_displaying",      1, 0, 0},
    {"mng_status_dynamic",         1, 0, 5},
    {"mng_status_error",           1, 0, 0},
    {"mng_status_reading",         1, 0, 0},
    {"mng_status_running",         1, 0, 0},
    {"mng_status_runningevent",    1, 0, 5},
    {"mng_status_suspendbreak",    1, 0, 0},
    {"mng_status_timerbreak",      1, 0, 0},
    {"mng_status_writing",         1, 0, 0},
    {"mng_supports_func",          1, 0, 5},
    {"mng_trapevent",              1, 0, 5},
    {"mng_updatemngheader",        1, 0, 0},
    {"mng_updatemngsimplicity",    1, 0, 0},
    {"mng_version_beta",           1, 0, 5},
    {"mng_version_dll",            1, 0, 0},
    {"mng_version_major",          1, 0, 0},
    {"mng_version_minor",          1, 0, 0},
    {"mng_version_release",        1, 0, 0},
    {"mng_version_so",             1, 0, 0},
    {"mng_version_text",           1, 0, 0},
    {"mng_write",                  1, 0, 0},
  };

mng_bool MNG_DECL mng_supports_func (mng_pchar  zFunction,
                                     mng_uint8* iMajor,
                                     mng_uint8* iMinor,
                                     mng_uint8* iRelease)
{
  mng_int32       iTop, iLower, iUpper, iMiddle;
  mng_func_entryp pEntry;          /* pointer to found entry */
                                   /* determine max index of table */
  iTop = (sizeof (func_table) / sizeof (func_table [0])) - 1;

  iLower  = 0;                     /* initialize binary search */
  iMiddle = iTop >> 1;             /* start in the middle */
  iUpper  = iTop;
  pEntry  = 0;                     /* no goods yet! */

  do                               /* the binary search itself */
    {
      mng_int32 iRslt = strcmp(func_table [iMiddle].zFunction, zFunction);
      if (iRslt < 0)
        iLower = iMiddle + 1;
      else if (iRslt > 0)
        iUpper = iMiddle - 1;
      else
      {
        pEntry = &func_table [iMiddle];
        break;
      };

      iMiddle = (iLower + iUpper) >> 1;
    }
  while (iLower <= iUpper);

  if (pEntry)                      /* found it ? */
  {
    *iMajor   = pEntry->iMajor;
    *iMinor   = pEntry->iMinor;
    *iRelease = pEntry->iRelease;
    return MNG_TRUE;
  }
  else
  {
    *iMajor   = 0;
    *iMinor   = 0;
    *iRelease = 0;
    return MNG_FALSE;
  }
}
#endif

/* ************************************************************************** */
/* *                                                                        * */
/* * HLAPI routines                                                         * */
/* *                                                                        * */
/* ************************************************************************** */

mng_handle MNG_DECL mng_initialize (mng_ptr       pUserdata,
                                    mng_memalloc  fMemalloc,
                                    mng_memfree   fMemfree,
                                    mng_traceproc fTraceproc)
{
  mng_datap   pData;
#ifdef MNG_SUPPORT_DISPLAY
  mng_retcode iRetcode;
  mng_imagep  pImage;
#endif

#ifdef MNG_INTERNAL_MEMMNGMT           /* allocate the main datastruc */
  pData = (mng_datap)calloc (1, sizeof (mng_data));
#else
  pData = (mng_datap)fMemalloc (sizeof (mng_data));
#endif

  if (!pData)
    return MNG_NULL;                   /* error: out of memory?? */
                                       /* validate the structure */
  pData->iMagic                = MNG_MAGIC;
                                       /* save userdata field */
  pData->pUserdata             = pUserdata;
                                       /* remember trace callback */
  pData->fTraceproc            = fTraceproc;

#ifdef MNG_SUPPORT_TRACE
  if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE))
  {
    MNG_FREEX (pData, pData, sizeof (mng_data))
    return MNG_NULL;
  }
#endif
                                       /* default canvas styles are 8-bit RGB */
  pData->iCanvasstyle          = MNG_CANVAS_RGB8;
  pData->iBkgdstyle            = MNG_CANVAS_RGB8;

  pData->iBGred                = 0;  /* black */
  pData->iBGgreen              = 0;
  pData->iBGblue               = 0;

  pData->bUseBKGD              = MNG_TRUE;

#ifdef MNG_FULL_CMS
  pData->bIssRGB               = MNG_TRUE;
  pData->hProf1                = 0;    /* no profiles yet */
  pData->hProf2                = 0;
  pData->hProf3                = 0;
  pData->hTrans                = 0;
#endif

  pData->dViewgamma            = 1.0;
  pData->dDisplaygamma         = 2.2;
  pData->dDfltimggamma         = 0.45455;
                                       /* initially remember chunks */
  pData->bStorechunks          = MNG_TRUE;
                                       /* no breaks at section-borders */
  pData->bSectionbreaks        = MNG_FALSE;
                                       /* initially cache playback info */
  pData->bCacheplayback        = MNG_TRUE;
                                       /* progressive refresh for large images */
  pData->bDoProgressive        = MNG_TRUE;
                                       /* crc exists; should check; error for
                                          critical chunks; warning for ancillery;
                                          generate crc for output */
  pData->iCrcmode              = MNG_CRC_DEFAULT;
                                       /* normal animation-speed ! */
  pData->iSpeed                = mng_st_normal;
                                       /* initial image limits */
  pData->iMaxwidth             = 10000;
  pData->iMaxheight            = 10000;

#ifdef MNG_INTERNAL_MEMMNGMT           /* internal management */
  pData->fMemalloc             = MNG_NULL;
  pData->fMemfree              = MNG_NULL;
#else                                  /* keep callbacks */
  pData->fMemalloc             = fMemalloc;
  pData->fMemfree              = fMemfree;
#endif
                                       /* no value (yet) */
  pData->fReleasedata          = MNG_NULL;    
#ifndef MNG_NO_OPEN_CLOSE_STREAM
  pData->fOpenstream           = MNG_NULL;
  pData->fClosestream          = MNG_NULL;
#endif
  pData->fReaddata             = MNG_NULL;
  pData->fWritedata            = MNG_NULL;
  pData->fErrorproc            = MNG_NULL;
  pData->fProcessheader        = MNG_NULL;
  pData->fProcesstext          = MNG_NULL;
  pData->fProcesssave          = MNG_NULL;
  pData->fProcessseek          = MNG_NULL;
  pData->fProcessneed          = MNG_NULL;
  pData->fProcessmend          = MNG_NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -