PageRenderTime 74ms CodeModel.GetById 16ms app.highlight 50ms RepoModel.GetById 1ms app.codeStats 0ms

/src/FreeImage/Source/LibMNG/libmng_prop_xs.c

https://bitbucket.org/cabalistic/ogredeps/
C | 2175 lines | 1445 code | 487 blank | 243 comment | 80 complexity | 2ca65cac1d74d51d03ddfefac8f89f64 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1/* ************************************************************************** */
   2/* *             For conditions of distribution and use,                    * */
   3/* *                see copyright notice in libmng.h                        * */
   4/* ************************************************************************** */
   5/* *                                                                        * */
   6/* * project   : libmng                                                     * */
   7/* * file      : libmng_prop_xs.c          copyright (c) 2000-2006 G.Juyn   * */
   8/* * version   : 1.0.10                                                     * */
   9/* *                                                                        * */
  10/* * purpose   : property get/set interface (implementation)                * */
  11/* *                                                                        * */
  12/* * author    : G.Juyn                                                     * */
  13/* *                                                                        * */
  14/* * comment   : implementation of the property get/set functions           * */
  15/* *                                                                        * */
  16/* * changes   : 0.5.1 - 05/08/2000 - G.Juyn                                * */
  17/* *             - fixed calling convention                                 * */
  18/* *             - changed strict-ANSI stuff                                * */
  19/* *             0.5.1 - 05/11/2000 - G.Juyn                                * */
  20/* *             - added set_outputprofile2 & set_srgbprofile2              * */
  21/* *             0.5.1 - 05/12/2000 - G.Juyn                                * */
  22/* *             - changed trace to macro for callback error-reporting      * */
  23/* *                                                                        * */
  24/* *             0.5.2 - 05/23/2000 - G.Juyn                                * */
  25/* *             - changed inclusion of cms-routines                        * */
  26/* *             0.5.2 - 05/24/2000 - G.Juyn                                * */
  27/* *             - added support for get/set default zlib/IJG parms         * */
  28/* *             0.5.2 - 05/31/2000 - G.Juyn                                * */
  29/* *             - fixed up punctuation (contribution by Tim Rowley)        * */
  30/* *             0.5.2 - 06/05/2000 - G.Juyn                                * */
  31/* *             - added support for RGB8_A8 canvasstyle                    * */
  32/* *                                                                        * */
  33/* *             0.5.3 - 06/21/2000 - G.Juyn                                * */
  34/* *             - added get/set for speedtype to facilitate testing        * */
  35/* *             - added get for imagelevel during processtext callback     * */
  36/* *             0.5.3 - 06/26/2000 - G.Juyn                                * */
  37/* *             - changed userdata variable to mng_ptr                     * */
  38/* *             0.5.3 - 06/29/2000 - G.Juyn                                * */
  39/* *             - fixed incompatible return-types                          * */
  40/* *                                                                        * */
  41/* *             0.9.1 - 07/08/2000 - G.Juyn                                * */
  42/* *             - added get routines for internal display variables        * */
  43/* *             - added get/set routines for suspensionmode variable       * */
  44/* *             0.9.1 - 07/15/2000 - G.Juyn                                * */
  45/* *             - added get/set routines for sectionbreak variable         * */
  46/* *                                                                        * */
  47/* *             0.9.2 - 07/31/2000 - G.Juyn                                * */
  48/* *             - added status_xxxx functions                              * */
  49/* *             0.9.2 - 08/05/2000 - G.Juyn                                * */
  50/* *             - changed file-prefixes                                    * */
  51/* *                                                                        * */
  52/* *             0.9.3 - 10/10/2000 - G.Juyn                                * */
  53/* *             - added support for alpha-depth prediction                 * */
  54/* *             0.9.3 - 10/16/2000 - G.Juyn                                * */
  55/* *             - added functions to retrieve PNG/JNG specific header-info * */
  56/* *             0.9.3 - 10/20/2000 - G.Juyn                                * */
  57/* *             - added get/set for bKGD preference setting                * */
  58/* *             0.9.3 - 10/21/2000 - G.Juyn                                * */
  59/* *             - added get function for interlace/progressive display     * */
  60/* *                                                                        * */
  61/* *             1.0.1 - 04/21/2001 - G.Juyn (code by G.Kelly)              * */
  62/* *             - added BGRA8 canvas with premultiplied alpha              * */
  63/* *             1.0.1 - 05/02/2001 - G.Juyn                                * */
  64/* *             - added "default" sRGB generation (Thanks Marti!)          * */
  65/* *                                                                        * */
  66/* *             1.0.2 - 06/23/2001 - G.Juyn                                * */
  67/* *             - added optimization option for MNG-video playback         * */
  68/* *             1.0.2 - 06/25/2001 - G.Juyn                                * */
  69/* *             - added option to turn off progressive refresh             * */
  70/* *                                                                        * */
  71/* *             1.0.3 - 08/06/2001 - G.Juyn                                * */
  72/* *             - added get function for last processed BACK chunk         * */
  73/* *                                                                        * */
  74/* *             1.0.4 - 06/22/2002 - G.Juyn                                * */
  75/* *             - B495442 - invalid returnvalue in mng_get_suspensionmode  * */
  76/* *                                                                        * */
  77/* *             1.0.5 - 09/14/2002 - G.Juyn                                * */
  78/* *             - added event handling for dynamic MNG                     * */
  79/* *             1.0.5 - 09/22/2002 - G.Juyn                                * */
  80/* *             - added bgrx8 canvas (filler byte)                         * */
  81/* *             1.0.5 - 11/07/2002 - G.Juyn                                * */
  82/* *             - added support to get totals after mng_read()             * */
  83/* *                                                                        * */
  84/* *             1.0.6 - 05/11/2003 - G. Juyn                               * */
  85/* *             - added conditionals around canvas update routines         * */
  86/* *             1.0.6 - 07/07/2003 - G.R-P                                 * */
  87/* *             - added conditionals around some JNG-supporting code       * */
  88/* *             1.0.6 - 07/11/2003 - G.R-P                                 * */
  89/* *             - added conditionals zlib and jpeg property accessors      * */
  90/* *             1.0.6 - 07/14/2003 - G.R-P                                 * */
  91/* *             - added conditionals around various unused functions       * */
  92/* *                                                                        * */
  93/* *             1.0.7 - 11/27/2003 - R.A                                   * */
  94/* *             - added CANVAS_RGB565 and CANVAS_BGR565                    * */
  95/* *             1.0.7 - 12/06/2003 - R.A                                   * */
  96/* *             - added CANVAS_RGBA565 and CANVAS_BGRA565                  * */
  97/* *             1.0.7 - 01/25/2004 - J.S                                   * */
  98/* *             - added premultiplied alpha canvas' for RGBA, ARGB, ABGR   * */
  99/* *             1.0.7 - 03/07/2004 - G.R-P.                                * */
 100/* *             - put gamma, cms-related functions inside #ifdef           * */
 101/* *                                                                        * */
 102/* *             1.0.8 - 04/02/2004 - G.Juyn                                * */
 103/* *             - added CRC existence & checking flags                     * */
 104/* *                                                                        * */
 105/* *             1.0.9 - 09/18/2004 - G.R-P.                                * */
 106/* *             - added some MNG_SUPPORT_WRITE conditionals                * */
 107/* *             1.0.9 - 10/03/2004 - G.Juyn                                * */
 108/* *             - added function to retrieve current FRAM delay            * */
 109/* *             1.0.9 - 10/14/2004 - G.Juyn                                * */
 110/* *             - added bgr565_a8 canvas-style (thanks to J. Elvander)     * */
 111/* *             1.0.9 - 12/20/2004 - G.Juyn                                * */
 112/* *             - cleaned up macro-invocations (thanks to D. Airlie)       * */
 113/* *                                                                        * */
 114/* *             1.0.10 - 03/07/2006 - (thanks to W. Manthey)               * */
 115/* *             - added CANVAS_RGB555 and CANVAS_BGR555                    * */
 116/* *                                                                        * */
 117/* ************************************************************************** */
 118
 119#include "libmng.h"
 120#include "libmng_data.h"
 121#include "libmng_error.h"
 122#include "libmng_trace.h"
 123#ifdef __BORLANDC__
 124#pragma hdrstop
 125#endif
 126#include "libmng_objects.h"
 127#include "libmng_memory.h"
 128#include "libmng_cms.h"
 129
 130#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
 131#pragma option -A                      /* force ANSI-C */
 132#endif
 133
 134/* ************************************************************************** */
 135/* *                                                                        * */
 136/* *  Property set functions                                                * */
 137/* *                                                                        * */
 138/* ************************************************************************** */
 139
 140mng_retcode MNG_DECL mng_set_userdata (mng_handle hHandle,
 141                                       mng_ptr    pUserdata)
 142{
 143#ifdef MNG_SUPPORT_TRACE
 144  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_START);
 145#endif
 146
 147  MNG_VALIDHANDLE (hHandle)
 148  ((mng_datap)hHandle)->pUserdata = pUserdata;
 149
 150#ifdef MNG_SUPPORT_TRACE
 151  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USERDATA, MNG_LC_END);
 152#endif
 153
 154  return MNG_NOERROR;
 155}
 156
 157/* ************************************************************************** */
 158
 159mng_retcode MNG_DECL mng_set_canvasstyle (mng_handle hHandle,
 160                                          mng_uint32 iStyle)
 161{
 162#ifdef MNG_SUPPORT_TRACE
 163  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_START);
 164#endif
 165
 166  MNG_VALIDHANDLE (hHandle)
 167
 168  switch (iStyle)
 169  {
 170#ifndef MNG_SKIPCANVAS_RGB8
 171    case MNG_CANVAS_RGB8    : break;
 172#endif
 173#ifndef MNG_SKIPCANVAS_RGBA8
 174    case MNG_CANVAS_RGBA8   : break;
 175#endif
 176#ifndef MNG_SKIPCANVAS_RGBA8_PM
 177    case MNG_CANVAS_RGBA8_PM: break;
 178#endif
 179#ifndef MNG_SKIPCANVAS_ARGB8
 180    case MNG_CANVAS_ARGB8   : break;
 181#endif
 182#ifndef MNG_SKIPCANVAS_ARGB8_PM
 183    case MNG_CANVAS_ARGB8_PM: break;
 184#endif
 185#ifndef MNG_SKIPCANVAS_RGB8_A8
 186    case MNG_CANVAS_RGB8_A8 : break;
 187#endif
 188#ifndef MNG_SKIPCANVAS_BGR8
 189    case MNG_CANVAS_BGR8    : break;
 190#endif
 191#ifndef MNG_SKIPCANVAS_BGRX8
 192    case MNG_CANVAS_BGRX8   : break;
 193#endif
 194#ifndef MNG_SKIPCANVAS_BGRA8
 195    case MNG_CANVAS_BGRA8   : break;
 196#endif
 197#ifndef MNG_SKIPCANVAS_BGRA8_PM
 198    case MNG_CANVAS_BGRA8_PM: break;
 199#endif
 200#ifndef MNG_SKIPCANVAS_ABGR8
 201    case MNG_CANVAS_ABGR8   : break;
 202#endif
 203#ifndef MNG_SKIPCANVAS_ABGR8_PM
 204    case MNG_CANVAS_ABGR8_PM: break;
 205#endif
 206#ifndef MNG_SKIPCANVAS_RGB565
 207    case MNG_CANVAS_RGB565  : break;
 208#endif
 209#ifndef MNG_SKIPCANVAS_RGBA565
 210    case MNG_CANVAS_RGBA565 : break;
 211#endif
 212#ifndef MNG_SKIPCANVAS_BGR565
 213    case MNG_CANVAS_BGR565  : break;
 214#endif
 215#ifndef MNG_SKIPCANVAS_BGRA565
 216    case MNG_CANVAS_BGRA565 : break;
 217#endif
 218#ifndef MNG_SKIPCANVAS_BGR565_A8
 219    case MNG_CANVAS_BGR565_A8 : break;
 220#endif
 221#ifndef MNG_SKIPCANVAS_RGB555
 222    case MNG_CANVAS_RGB555  : break;
 223#endif
 224#ifndef MNG_SKIPCANVAS_BGR555
 225    case MNG_CANVAS_BGR555  : break;
 226#endif
 227/*    case MNG_CANVAS_RGB16   : break; */
 228/*    case MNG_CANVAS_RGBA16  : break; */
 229/*    case MNG_CANVAS_ARGB16  : break; */
 230/*    case MNG_CANVAS_BGR16   : break; */
 231/*    case MNG_CANVAS_BGRA16  : break; */
 232/*    case MNG_CANVAS_ABGR16  : break; */
 233/*    case MNG_CANVAS_INDEX8  : break; */
 234/*    case MNG_CANVAS_INDEXA8 : break; */
 235/*    case MNG_CANVAS_AINDEX8 : break; */
 236/*    case MNG_CANVAS_GRAY8   : break; */
 237/*    case MNG_CANVAS_GRAY16  : break; */
 238/*    case MNG_CANVAS_GRAYA8  : break; */
 239/*    case MNG_CANVAS_GRAYA16 : break; */
 240/*    case MNG_CANVAS_AGRAY8  : break; */
 241/*    case MNG_CANVAS_AGRAY16 : break; */
 242/*    case MNG_CANVAS_DX15    : break; */
 243/*    case MNG_CANVAS_DX16    : break; */
 244    default                 : { MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE) };
 245  }
 246
 247  ((mng_datap)hHandle)->iCanvasstyle = iStyle;
 248
 249#ifdef MNG_SUPPORT_TRACE
 250  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CANVASSTYLE, MNG_LC_END);
 251#endif
 252
 253  return MNG_NOERROR;
 254}
 255
 256/* ************************************************************************** */
 257
 258mng_retcode MNG_DECL mng_set_bkgdstyle (mng_handle hHandle,
 259                                        mng_uint32 iStyle)
 260{
 261#ifdef MNG_SUPPORT_TRACE
 262  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_START);
 263#endif
 264
 265  MNG_VALIDHANDLE (hHandle)
 266
 267  switch (iStyle)                      /* alpha-modes not supported */
 268  {
 269#ifndef MNG_SKIPCANVAS_RGB8
 270    case MNG_CANVAS_RGB8    : break;
 271#endif
 272#ifndef MNG_SKIPCANVAS_BGR8
 273    case MNG_CANVAS_BGR8    : break;
 274#endif
 275#ifndef MNG_SKIPCANVAS_BGRX8
 276    case MNG_CANVAS_BGRX8   : break;
 277#endif
 278#ifndef MNG_SKIPCANVAS_RGB565
 279    case MNG_CANVAS_RGB565  : break;
 280#endif
 281#ifndef MNG_SKIPCANVAS_BGR565
 282    case MNG_CANVAS_BGR565  : break;
 283#endif
 284/*    case MNG_CANVAS_RGB16   : break; */
 285/*    case MNG_CANVAS_BGR16   : break; */
 286/*    case MNG_CANVAS_INDEX8  : break; */
 287/*    case MNG_CANVAS_GRAY8   : break; */
 288/*    case MNG_CANVAS_GRAY16  : break; */
 289/*    case MNG_CANVAS_DX15    : break; */
 290/*    case MNG_CANVAS_DX16    : break; */
 291    default                 : MNG_ERROR (((mng_datap)hHandle), MNG_INVALIDCNVSTYLE);
 292  }
 293
 294  ((mng_datap)hHandle)->iBkgdstyle = iStyle;
 295
 296#ifdef MNG_SUPPORT_TRACE
 297  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BKGDSTYLE, MNG_LC_END);
 298#endif
 299
 300  return MNG_NOERROR;
 301}
 302
 303/* ************************************************************************** */
 304
 305mng_retcode MNG_DECL mng_set_bgcolor (mng_handle hHandle,
 306                                      mng_uint16 iRed,
 307                                      mng_uint16 iGreen,
 308                                      mng_uint16 iBlue)
 309{
 310#ifdef MNG_SUPPORT_TRACE
 311  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_START);
 312#endif
 313
 314  MNG_VALIDHANDLE (hHandle)
 315  ((mng_datap)hHandle)->iBGred   = iRed;
 316  ((mng_datap)hHandle)->iBGgreen = iGreen;
 317  ((mng_datap)hHandle)->iBGblue  = iBlue;
 318  ((mng_datap)hHandle)->bUseBKGD = MNG_FALSE;
 319
 320#ifdef MNG_SUPPORT_TRACE
 321  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_BGCOLOR, MNG_LC_END);
 322#endif
 323
 324  return MNG_NOERROR;
 325}
 326
 327/* ************************************************************************** */
 328
 329mng_retcode MNG_DECL mng_set_usebkgd (mng_handle hHandle,
 330                                      mng_bool   bUseBKGD)
 331{
 332#ifdef MNG_SUPPORT_TRACE
 333  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_START);
 334#endif
 335
 336  MNG_VALIDHANDLE (hHandle)
 337  ((mng_datap)hHandle)->bUseBKGD = bUseBKGD;
 338
 339#ifdef MNG_SUPPORT_TRACE
 340  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_USEBKGD, MNG_LC_END);
 341#endif
 342
 343  return MNG_NOERROR;
 344}
 345
 346/* ************************************************************************** */
 347
 348mng_retcode MNG_DECL mng_set_storechunks (mng_handle hHandle,
 349                                          mng_bool   bStorechunks)
 350{
 351#ifdef MNG_SUPPORT_TRACE
 352  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_START);
 353#endif
 354
 355  MNG_VALIDHANDLE (hHandle)
 356  ((mng_datap)hHandle)->bStorechunks = bStorechunks;
 357
 358#ifdef MNG_SUPPORT_TRACE
 359  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_STORECHUNKS, MNG_LC_END);
 360#endif
 361
 362  return MNG_NOERROR;
 363}
 364
 365/* ************************************************************************** */
 366
 367mng_retcode MNG_DECL mng_set_sectionbreaks (mng_handle hHandle,
 368                                            mng_bool   bSectionbreaks)
 369{
 370#ifdef MNG_SUPPORT_TRACE
 371  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_START);
 372#endif
 373
 374  MNG_VALIDHANDLE (hHandle)
 375  ((mng_datap)hHandle)->bSectionbreaks = bSectionbreaks;
 376
 377#ifdef MNG_SUPPORT_TRACE
 378  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SECTIONBREAKS, MNG_LC_END);
 379#endif
 380
 381  return MNG_NOERROR;
 382}
 383
 384/* ************************************************************************** */
 385
 386mng_retcode MNG_DECL mng_set_cacheplayback (mng_handle hHandle,
 387                                            mng_bool   bCacheplayback)
 388{
 389#ifdef MNG_SUPPORT_TRACE
 390  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_START);
 391#endif
 392
 393  MNG_VALIDHANDLE (hHandle)
 394
 395  if (((mng_datap)hHandle)->bHasheader)
 396    MNG_ERROR (((mng_datap)hHandle), MNG_FUNCTIONINVALID);
 397
 398  ((mng_datap)hHandle)->bCacheplayback = bCacheplayback;
 399
 400#ifdef MNG_SUPPORT_TRACE
 401  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CACHEPLAYBACK, MNG_LC_END);
 402#endif
 403
 404  return MNG_NOERROR;
 405}
 406
 407/* ************************************************************************** */
 408
 409mng_retcode MNG_DECL mng_set_doprogressive (mng_handle hHandle,
 410                                            mng_bool   bDoProgressive)
 411{
 412#ifdef MNG_SUPPORT_TRACE
 413  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_START);
 414#endif
 415
 416  MNG_VALIDHANDLE (hHandle)
 417
 418  ((mng_datap)hHandle)->bDoProgressive = bDoProgressive;
 419
 420#ifdef MNG_SUPPORT_TRACE
 421  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DOPROGRESSIVE, MNG_LC_END);
 422#endif
 423
 424  return MNG_NOERROR;
 425}
 426
 427/* ************************************************************************** */
 428
 429mng_retcode MNG_DECL mng_set_crcmode (mng_handle hHandle,
 430                                      mng_uint32 iCrcmode)
 431{
 432#ifdef MNG_SUPPORT_TRACE
 433  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CRCMODE, MNG_LC_START);
 434#endif
 435
 436  MNG_VALIDHANDLE (hHandle)
 437
 438  ((mng_datap)hHandle)->iCrcmode = iCrcmode;
 439
 440#ifdef MNG_SUPPORT_TRACE
 441  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_CRCMODE, MNG_LC_END);
 442#endif
 443
 444  return MNG_NOERROR;
 445}
 446
 447/* ************************************************************************** */
 448
 449#ifdef MNG_SUPPORT_DISPLAY
 450mng_retcode MNG_DECL mng_set_srgb (mng_handle hHandle,
 451                                   mng_bool   bIssRGB)
 452{
 453#ifdef MNG_SUPPORT_TRACE
 454  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_START);
 455#endif
 456
 457  MNG_VALIDHANDLE (hHandle)
 458  ((mng_datap)hHandle)->bIssRGB = bIssRGB;
 459
 460#ifdef MNG_SUPPORT_TRACE
 461  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGB, MNG_LC_END);
 462#endif
 463
 464  return MNG_NOERROR;
 465}
 466#endif /* MNG_SUPPORT_DISPLAY */
 467
 468/* ************************************************************************** */
 469
 470#ifdef MNG_SUPPORT_DISPLAY
 471#ifndef MNG_SKIPCHUNK_iCCP
 472mng_retcode MNG_DECL mng_set_outputprofile (mng_handle hHandle,
 473                                            mng_pchar  zFilename)
 474{
 475#ifdef MNG_INCLUDE_LCMS
 476  mng_datap pData;
 477#endif
 478
 479#ifdef MNG_SUPPORT_TRACE
 480  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_START);
 481#endif
 482
 483#ifdef MNG_INCLUDE_LCMS
 484  MNG_VALIDHANDLE (hHandle)
 485
 486  pData = (mng_datap)hHandle;          /* address the structure */
 487
 488  if (pData->hProf2)                   /* previously defined ? */
 489    mnglcms_freeprofile (pData->hProf2);
 490                                       /* allocate new CMS profile handle */
 491  pData->hProf2 = mnglcms_createfileprofile (zFilename);
 492
 493  if (!pData->hProf2)                  /* handle error ? */
 494    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 495#endif /* MNG_INCLUDE_LCMS */
 496
 497#ifdef MNG_SUPPORT_TRACE
 498  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE, MNG_LC_END);
 499#endif
 500
 501  return MNG_NOERROR;
 502}
 503#endif
 504#endif /* MNG_SUPPORT_DISPLAY */
 505
 506/* ************************************************************************** */
 507
 508#ifdef MNG_SUPPORT_DISPLAY
 509#ifndef MNG_SKIPCHUNK_iCCP
 510mng_retcode MNG_DECL mng_set_outputprofile2 (mng_handle hHandle,
 511                                             mng_uint32 iProfilesize,
 512                                             mng_ptr    pProfile)
 513{
 514#ifdef MNG_INCLUDE_LCMS
 515  mng_datap pData;
 516#endif
 517
 518#ifdef MNG_SUPPORT_TRACE
 519  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_START);
 520#endif
 521
 522#ifdef MNG_INCLUDE_LCMS
 523  MNG_VALIDHANDLE (hHandle)
 524
 525  pData = (mng_datap)hHandle;          /* address the structure */
 526
 527  if (pData->hProf2)                   /* previously defined ? */
 528    mnglcms_freeprofile (pData->hProf2);
 529                                       /* allocate new CMS profile handle */
 530  pData->hProf2 = mnglcms_creatememprofile (iProfilesize, pProfile);
 531
 532  if (!pData->hProf2)                  /* handle error ? */
 533    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 534#endif /* MNG_INCLUDE_LCMS */
 535
 536#ifdef MNG_SUPPORT_TRACE
 537  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTPROFILE2, MNG_LC_END);
 538#endif
 539
 540  return MNG_NOERROR;
 541}
 542#endif
 543#endif /* MNG_SUPPORT_DISPLAY */
 544
 545/* ************************************************************************** */
 546
 547mng_retcode MNG_DECL mng_set_outputsrgb (mng_handle hHandle)
 548{
 549#ifdef MNG_INCLUDE_LCMS
 550  mng_datap pData;
 551#endif
 552
 553#ifdef MNG_SUPPORT_TRACE
 554  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_START);
 555#endif
 556
 557#ifdef MNG_INCLUDE_LCMS
 558  MNG_VALIDHANDLE (hHandle)
 559
 560  pData = (mng_datap)hHandle;          /* address the structure */
 561
 562  if (pData->hProf2)                   /* previously defined ? */
 563    mnglcms_freeprofile (pData->hProf2);
 564                                       /* allocate new CMS profile handle */
 565  pData->hProf2 = mnglcms_createsrgbprofile ();
 566
 567  if (!pData->hProf2)                  /* handle error ? */
 568    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 569#endif /* MNG_INCLUDE_LCMS */
 570
 571#ifdef MNG_SUPPORT_TRACE
 572  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_OUTPUTSRGB, MNG_LC_END);
 573#endif
 574
 575  return MNG_NOERROR;
 576}
 577
 578/* ************************************************************************** */
 579
 580#ifdef MNG_SUPPORT_DISPLAY
 581mng_retcode MNG_DECL mng_set_srgbprofile (mng_handle hHandle,
 582                                          mng_pchar  zFilename)
 583{
 584#ifdef MNG_INCLUDE_LCMS
 585  mng_datap pData;
 586#endif
 587
 588#ifdef MNG_SUPPORT_TRACE
 589  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_START);
 590#endif
 591
 592#ifdef MNG_INCLUDE_LCMS
 593  MNG_VALIDHANDLE (hHandle)
 594
 595  pData = (mng_datap)hHandle;          /* address the structure */
 596
 597  if (pData->hProf3)                   /* previously defined ? */
 598    mnglcms_freeprofile (pData->hProf3);
 599                                       /* allocate new CMS profile handle */
 600  pData->hProf3 = mnglcms_createfileprofile (zFilename);
 601
 602  if (!pData->hProf3)                  /* handle error ? */
 603    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 604#endif /* MNG_INCLUDE_LCMS */
 605
 606#ifdef MNG_SUPPORT_TRACE
 607  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE2, MNG_LC_END);
 608#endif
 609
 610  return MNG_NOERROR;
 611}
 612#endif /* MNG_SUPPORT_DISPLAY */
 613
 614/* ************************************************************************** */
 615
 616#ifdef MNG_SUPPORT_DISPLAY
 617mng_retcode MNG_DECL mng_set_srgbprofile2 (mng_handle hHandle,
 618                                           mng_uint32 iProfilesize,
 619                                           mng_ptr    pProfile)
 620{
 621#ifdef MNG_INCLUDE_LCMS
 622  mng_datap pData;
 623#endif
 624
 625#ifdef MNG_SUPPORT_TRACE
 626  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_START);
 627#endif
 628
 629#ifdef MNG_INCLUDE_LCMS
 630  MNG_VALIDHANDLE (hHandle)
 631
 632  pData = (mng_datap)hHandle;          /* address the structure */
 633
 634  if (pData->hProf3)                   /* previously defined ? */
 635    mnglcms_freeprofile (pData->hProf3);
 636                                       /* allocate new CMS profile handle */
 637  pData->hProf3 = mnglcms_creatememprofile (iProfilesize, pProfile);
 638
 639  if (!pData->hProf3)                  /* handle error ? */
 640    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 641#endif /* MNG_INCLUDE_LCMS */
 642
 643#ifdef MNG_SUPPORT_TRACE
 644  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBPROFILE, MNG_LC_END);
 645#endif
 646
 647  return MNG_NOERROR;
 648}
 649#endif /* MNG_SUPPORT_DISPLAY */
 650
 651/* ************************************************************************** */
 652
 653mng_retcode MNG_DECL mng_set_srgbimplicit (mng_handle hHandle)
 654{
 655#ifdef MNG_INCLUDE_LCMS
 656  mng_datap pData;
 657#endif
 658
 659#ifdef MNG_SUPPORT_TRACE
 660  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_START);
 661#endif
 662
 663#ifdef MNG_INCLUDE_LCMS
 664  MNG_VALIDHANDLE (hHandle)
 665
 666  pData = (mng_datap)hHandle;          /* address the structure */
 667
 668  if (pData->hProf3)                   /* previously defined ? */
 669    mnglcms_freeprofile (pData->hProf3);
 670                                       /* allocate new CMS profile handle */
 671  pData->hProf3 = mnglcms_createsrgbprofile ();
 672
 673  if (!pData->hProf3)                  /* handle error ? */
 674    MNG_ERRORL (pData, MNG_LCMS_NOHANDLE);
 675#endif /* MNG_INCLUDE_LCMS */
 676
 677#ifdef MNG_SUPPORT_TRACE
 678  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SRGBIMPLICIT, MNG_LC_END);
 679#endif
 680
 681  return MNG_NOERROR;
 682}
 683
 684/* ************************************************************************** */
 685
 686#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
 687mng_retcode MNG_DECL mng_set_viewgamma (mng_handle hHandle,
 688                                        mng_float  dGamma)
 689{
 690#ifdef MNG_SUPPORT_TRACE
 691  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START);
 692#endif
 693
 694  MNG_VALIDHANDLE (hHandle)
 695  ((mng_datap)hHandle)->dViewgamma = dGamma;
 696
 697#ifdef MNG_SUPPORT_TRACE
 698  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END);
 699#endif
 700
 701  return MNG_NOERROR;
 702}
 703#endif
 704
 705/* ************************************************************************** */
 706
 707mng_retcode MNG_DECL mng_set_displaygamma (mng_handle hHandle,
 708                                           mng_float  dGamma)
 709{
 710#ifdef MNG_SUPPORT_TRACE
 711  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START);
 712#endif
 713
 714  MNG_VALIDHANDLE (hHandle)
 715  ((mng_datap)hHandle)->dDisplaygamma = dGamma;
 716
 717#ifdef MNG_SUPPORT_TRACE
 718  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END);
 719#endif
 720
 721  return MNG_NOERROR;
 722}
 723
 724/* ************************************************************************** */
 725
 726mng_retcode MNG_DECL mng_set_dfltimggamma (mng_handle hHandle,
 727                                           mng_float  dGamma)
 728{
 729#ifdef MNG_SUPPORT_TRACE
 730  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START);
 731#endif
 732
 733  MNG_VALIDHANDLE (hHandle)
 734  ((mng_datap)hHandle)->dDfltimggamma = dGamma;
 735
 736#ifdef MNG_SUPPORT_TRACE
 737  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END);
 738#endif
 739
 740  return MNG_NOERROR;
 741}
 742
 743/* ************************************************************************** */
 744
 745#if defined(MNG_FULL_CMS) || defined(MNG_GAMMA_ONLY) || defined(MNG_APP_CMS)
 746mng_retcode MNG_DECL mng_set_viewgammaint (mng_handle hHandle,
 747                                           mng_uint32 iGamma)
 748{
 749#ifdef MNG_SUPPORT_TRACE
 750  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_START);
 751#endif
 752
 753  MNG_VALIDHANDLE (hHandle)
 754  ((mng_datap)hHandle)->dViewgamma = (mng_float)iGamma / 100000;
 755
 756#ifdef MNG_SUPPORT_TRACE
 757  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_VIEWGAMMA, MNG_LC_END);
 758#endif
 759
 760  return MNG_NOERROR;
 761}
 762#endif
 763
 764/* ************************************************************************** */
 765
 766mng_retcode MNG_DECL mng_set_displaygammaint (mng_handle hHandle,
 767                                              mng_uint32 iGamma)
 768{
 769#ifdef MNG_SUPPORT_TRACE
 770  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_START);
 771#endif
 772
 773  MNG_VALIDHANDLE (hHandle)
 774  ((mng_datap)hHandle)->dDisplaygamma = (mng_float)iGamma / 100000;
 775
 776#ifdef MNG_SUPPORT_TRACE
 777  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DISPLAYGAMMA, MNG_LC_END);
 778#endif
 779
 780  return MNG_NOERROR;
 781}
 782
 783/* ************************************************************************** */
 784
 785#ifndef MNG_NO_DFLT_INFO
 786mng_retcode MNG_DECL mng_set_dfltimggammaint (mng_handle hHandle,
 787                                              mng_uint32 iGamma)
 788{
 789#ifdef MNG_SUPPORT_TRACE
 790  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_START);
 791#endif
 792
 793  MNG_VALIDHANDLE (hHandle)
 794  ((mng_datap)hHandle)->dDfltimggamma = (mng_float)iGamma / 100000;
 795
 796#ifdef MNG_SUPPORT_TRACE
 797  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_DFLTIMGGAMMA, MNG_LC_END);
 798#endif
 799
 800  return MNG_NOERROR;
 801}
 802#endif
 803
 804/* ************************************************************************** */
 805
 806#ifndef MNG_SKIP_MAXCANVAS
 807mng_retcode MNG_DECL mng_set_maxcanvaswidth (mng_handle hHandle,
 808                                             mng_uint32 iMaxwidth)
 809{
 810#ifdef MNG_SUPPORT_TRACE
 811  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_START);
 812#endif
 813
 814  MNG_VALIDHANDLE (hHandle)
 815  ((mng_datap)hHandle)->iMaxwidth = iMaxwidth;
 816
 817#ifdef MNG_SUPPORT_TRACE
 818  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASWIDTH, MNG_LC_END);
 819#endif
 820
 821  return MNG_NOERROR;
 822}
 823
 824/* ************************************************************************** */
 825
 826mng_retcode MNG_DECL mng_set_maxcanvasheight (mng_handle hHandle,
 827                                              mng_uint32 iMaxheight)
 828{
 829#ifdef MNG_SUPPORT_TRACE
 830  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_START);
 831#endif
 832
 833  MNG_VALIDHANDLE (hHandle)
 834  ((mng_datap)hHandle)->iMaxheight = iMaxheight;
 835
 836#ifdef MNG_SUPPORT_TRACE
 837  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASHEIGHT, MNG_LC_END);
 838#endif
 839
 840  return MNG_NOERROR;
 841}
 842
 843/* ************************************************************************** */
 844
 845mng_retcode MNG_DECL mng_set_maxcanvassize (mng_handle hHandle,
 846                                            mng_uint32 iMaxwidth,
 847                                            mng_uint32 iMaxheight)
 848{
 849#ifdef MNG_SUPPORT_TRACE
 850  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_START);
 851#endif
 852
 853  MNG_VALIDHANDLE (hHandle)
 854  ((mng_datap)hHandle)->iMaxwidth  = iMaxwidth;
 855  ((mng_datap)hHandle)->iMaxheight = iMaxheight;
 856
 857#ifdef MNG_SUPPORT_TRACE
 858  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_MAXCANVASSIZE, MNG_LC_END);
 859#endif
 860
 861  return MNG_NOERROR;
 862}
 863#endif
 864
 865/* ************************************************************************** */
 866
 867#ifdef MNG_INCLUDE_ZLIB
 868#ifdef MNG_ACCESS_ZLIB
 869#ifdef MNG_SUPPORT_WRITE
 870mng_retcode MNG_DECL mng_set_zlib_level (mng_handle hHandle,
 871                                         mng_int32  iZlevel)
 872{
 873#ifdef MNG_SUPPORT_TRACE
 874  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_START);
 875#endif
 876
 877  MNG_VALIDHANDLE (hHandle)
 878  ((mng_datap)hHandle)->iZlevel = iZlevel;
 879
 880#ifdef MNG_SUPPORT_TRACE
 881  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_LEVEL, MNG_LC_END);
 882#endif
 883
 884  return MNG_NOERROR;
 885}
 886#endif /* MNG_SUPPORT_WRITE */
 887#endif /* MNG_ACCESS_ZLIB */
 888#endif /* MNG_INCLUDE_ZLIB */
 889
 890/* ************************************************************************** */
 891
 892#ifdef MNG_INCLUDE_ZLIB
 893#ifdef MNG_ACCESS_ZLIB
 894#ifdef MNG_SUPPORT_WRITE
 895mng_retcode MNG_DECL mng_set_zlib_method (mng_handle hHandle,
 896                                          mng_int32  iZmethod)
 897{
 898#ifdef MNG_SUPPORT_TRACE
 899  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_START);
 900#endif
 901
 902  MNG_VALIDHANDLE (hHandle)
 903  ((mng_datap)hHandle)->iZmethod = iZmethod;
 904
 905#ifdef MNG_SUPPORT_TRACE
 906  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_METHOD, MNG_LC_END);
 907#endif
 908
 909  return MNG_NOERROR;
 910}
 911#endif /* MNG_SUPPORT_WRITE */
 912#endif /* MNG_ACCESS_ZLIB */
 913#endif /* MNG_INCLUDE_ZLIB */
 914
 915/* ************************************************************************** */
 916
 917#ifdef MNG_INCLUDE_ZLIB
 918#ifdef MNG_ACCESS_ZLIB
 919#ifdef MNG_SUPPORT_WRITE
 920mng_retcode MNG_DECL mng_set_zlib_windowbits (mng_handle hHandle,
 921                                              mng_int32  iZwindowbits)
 922{
 923#ifdef MNG_SUPPORT_TRACE
 924  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_START);
 925#endif
 926
 927  MNG_VALIDHANDLE (hHandle)
 928  ((mng_datap)hHandle)->iZwindowbits = iZwindowbits;
 929
 930#ifdef MNG_SUPPORT_TRACE
 931  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_WINDOWBITS, MNG_LC_END);
 932#endif
 933
 934  return MNG_NOERROR;
 935}
 936#endif /* MNG_SUPPORT_WRITE */
 937#endif /* MNG_ACCESS_ZLIB */
 938#endif /* MNG_INCLUDE_ZLIB */
 939
 940/* ************************************************************************** */
 941
 942#ifdef MNG_INCLUDE_ZLIB
 943#ifdef MNG_ACCESS_ZLIB
 944#ifdef MNG_SUPPORT_WRITE
 945mng_retcode MNG_DECL mng_set_zlib_memlevel (mng_handle hHandle,
 946                                            mng_int32  iZmemlevel)
 947{
 948#ifdef MNG_SUPPORT_TRACE
 949  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_START);
 950#endif
 951
 952  MNG_VALIDHANDLE (hHandle)
 953  ((mng_datap)hHandle)->iZmemlevel = iZmemlevel;
 954
 955#ifdef MNG_SUPPORT_TRACE
 956  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MEMLEVEL, MNG_LC_END);
 957#endif
 958
 959  return MNG_NOERROR;
 960}
 961#endif /* MNG_SUPPORT_WRITE */
 962#endif /* MNG_ACCESS_ZLIB */
 963#endif /* MNG_INCLUDE_ZLIB */
 964
 965/* ************************************************************************** */
 966
 967#ifdef MNG_INCLUDE_ZLIB
 968#ifdef MNG_ACCESS_ZLIB
 969#ifdef MNG_SUPPORT_WRITE
 970mng_retcode MNG_DECL mng_set_zlib_strategy (mng_handle hHandle,
 971                                            mng_int32  iZstrategy)
 972{
 973#ifdef MNG_SUPPORT_TRACE
 974  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_START);
 975#endif
 976
 977  MNG_VALIDHANDLE (hHandle)
 978  ((mng_datap)hHandle)->iZstrategy = iZstrategy;
 979
 980#ifdef MNG_SUPPORT_TRACE
 981  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_STRATEGY, MNG_LC_END);
 982#endif
 983
 984  return MNG_NOERROR;
 985}
 986#endif /* MNG_SUPPORT_WRITE */
 987#endif /* MNG_ACCESS_ZLIB */
 988#endif /* MNG_INCLUDE_ZLIB */
 989
 990/* ************************************************************************** */
 991
 992#ifdef MNG_INCLUDE_ZLIB
 993#ifdef MNG_ACCESS_ZLIB
 994#ifdef MNG_SUPPORT_WRITE
 995mng_retcode MNG_DECL mng_set_zlib_maxidat (mng_handle hHandle,
 996                                           mng_uint32 iMaxIDAT)
 997{
 998#ifdef MNG_SUPPORT_TRACE
 999  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_START);
1000#endif
1001
1002  MNG_VALIDHANDLE (hHandle)
1003  ((mng_datap)hHandle)->iMaxIDAT = iMaxIDAT;
1004
1005#ifdef MNG_SUPPORT_TRACE
1006  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_ZLIB_MAXIDAT, MNG_LC_END);
1007#endif
1008
1009  return MNG_NOERROR;
1010}
1011#endif /* MNG_SUPPORT_WRITE */
1012#endif /* MNG_ACCESS_ZLIB */
1013#endif /* MNG_INCLUDE_ZLIB */
1014
1015/* ************************************************************************** */
1016
1017#ifdef MNG_INCLUDE_JNG
1018#ifdef MNG_ACCESS_JPEG
1019#ifdef MNG_SUPPORT_WRITE
1020mng_retcode MNG_DECL mng_set_jpeg_dctmethod (mng_handle        hHandle,
1021                                             mngjpeg_dctmethod eJPEGdctmethod)
1022{
1023#ifdef MNG_SUPPORT_TRACE
1024  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_START);
1025#endif
1026
1027  MNG_VALIDHANDLE (hHandle)
1028  ((mng_datap)hHandle)->eJPEGdctmethod = eJPEGdctmethod;
1029
1030#ifdef MNG_SUPPORT_TRACE
1031  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_DCTMETHOD, MNG_LC_END);
1032#endif
1033
1034  return MNG_NOERROR;
1035}
1036#endif MNG_SUPPORT_WRITE
1037#endif /* MNG_ACCESS_JPEG */
1038#endif /* MNG_INCLUDE_JNG */
1039
1040/* ************************************************************************** */
1041
1042#ifdef MNG_INCLUDE_JNG
1043#ifdef MNG_ACCESS_JPEG
1044#ifdef MNG_SUPPORT_WRITE
1045mng_retcode MNG_DECL mng_set_jpeg_quality (mng_handle hHandle,
1046                                           mng_int32  iJPEGquality)
1047{
1048#ifdef MNG_SUPPORT_TRACE
1049  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_START);
1050#endif
1051
1052  MNG_VALIDHANDLE (hHandle)
1053  ((mng_datap)hHandle)->iJPEGquality = iJPEGquality;
1054
1055#ifdef MNG_SUPPORT_TRACE
1056  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_QUALITY, MNG_LC_END);
1057#endif
1058
1059  return MNG_NOERROR;
1060}
1061#endif /* MNG_SUPPORT_WRITE */
1062#endif /* MNG_ACCESS_JPEG */
1063#endif /* MNG_INCLUDE_JNG */
1064
1065/* ************************************************************************** */
1066
1067#ifdef MNG_INCLUDE_JNG
1068#ifdef MNG_ACCESS_JPEG
1069#ifdef MNG_SUPPORT_WRITE
1070mng_retcode MNG_DECL mng_set_jpeg_smoothing (mng_handle hHandle,
1071                                             mng_int32  iJPEGsmoothing)
1072{
1073#ifdef MNG_SUPPORT_TRACE
1074  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_START);
1075#endif
1076
1077  MNG_VALIDHANDLE (hHandle)
1078  ((mng_datap)hHandle)->iJPEGsmoothing = iJPEGsmoothing;
1079
1080#ifdef MNG_SUPPORT_TRACE
1081  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_SMOOTHING, MNG_LC_END);
1082#endif
1083
1084  return MNG_NOERROR;
1085}
1086#endif /* MNG_SUPPORT_WRITE */
1087#endif /* MNG_ACCESS_JPEG */
1088#endif /* MNG_INCLUDE_JNG */
1089
1090/* ************************************************************************** */
1091
1092#ifdef MNG_INCLUDE_JNG
1093#ifdef MNG_ACCESS_JPEG
1094#ifdef MNG_SUPPORT_WRITE
1095mng_retcode MNG_DECL mng_set_jpeg_progressive (mng_handle hHandle,
1096                                               mng_bool   bJPEGprogressive)
1097{
1098#ifdef MNG_SUPPORT_TRACE
1099  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_START);
1100#endif
1101
1102  MNG_VALIDHANDLE (hHandle)
1103  ((mng_datap)hHandle)->bJPEGcompressprogr = bJPEGprogressive;
1104
1105#ifdef MNG_SUPPORT_TRACE
1106  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_PROGRESSIVE, MNG_LC_END);
1107#endif
1108
1109  return MNG_NOERROR;
1110}
1111#endif /* MNG_SUPPORT_WRITE */
1112#endif /* MNG_ACCESS_JPEG */
1113#endif /* MNG_INCLUDE_JNG */
1114
1115/* ************************************************************************** */
1116
1117#ifdef MNG_INCLUDE_JNG
1118#ifdef MNG_ACCESS_JPEG
1119#ifdef MNG_SUPPORT_WRITE
1120mng_retcode MNG_DECL mng_set_jpeg_optimized (mng_handle hHandle,
1121                                             mng_bool   bJPEGoptimized)
1122{
1123#ifdef MNG_SUPPORT_TRACE
1124  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_START);
1125#endif
1126
1127  MNG_VALIDHANDLE (hHandle)
1128  ((mng_datap)hHandle)->bJPEGcompressopt = bJPEGoptimized;
1129
1130#ifdef MNG_SUPPORT_TRACE
1131  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_OPTIMIZED, MNG_LC_END);
1132#endif
1133
1134  return MNG_NOERROR;
1135}
1136#endif /* MNG_SUPPORT_WRITE */
1137#endif /* MNG_ACCESS_JPEG */
1138#endif /* MNG_INCLUDE_JNG */
1139
1140/* ************************************************************************** */
1141
1142#ifdef MNG_INCLUDE_JNG
1143#ifdef MNG_ACCESS_JPEG
1144#ifdef MNG_SUPPORT_WRITE
1145mng_retcode MNG_DECL mng_set_jpeg_maxjdat (mng_handle hHandle,
1146                                           mng_uint32 iMaxJDAT)
1147{
1148#ifdef MNG_SUPPORT_TRACE
1149  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_START);
1150#endif
1151
1152  MNG_VALIDHANDLE (hHandle)
1153  ((mng_datap)hHandle)->iMaxJDAT = iMaxJDAT;
1154
1155#ifdef MNG_SUPPORT_TRACE
1156  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_JPEG_MAXJDAT, MNG_LC_END);
1157#endif
1158
1159  return MNG_NOERROR;
1160}
1161#endif /* MNG_SUPPORT_WRITE */
1162#endif /* MNG_ACCESS_JPEG */
1163#endif /* MNG_INCLUDE_JNG */
1164
1165/* ************************************************************************** */
1166
1167#ifdef MNG_SUPPORT_READ
1168mng_retcode MNG_DECL mng_set_suspensionmode (mng_handle hHandle,
1169                                             mng_bool   bSuspensionmode)
1170{
1171#ifdef MNG_SUPPORT_TRACE
1172  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_START);
1173#endif
1174
1175  MNG_VALIDHANDLE (hHandle)
1176
1177  if (((mng_datap)hHandle)->bReading)  /* we must NOT be reading !!! */
1178    MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID);
1179
1180  ((mng_datap)hHandle)->bSuspensionmode = bSuspensionmode;
1181
1182#ifdef MNG_SUPPORT_TRACE
1183  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SUSPENSIONMODE, MNG_LC_END);
1184#endif
1185
1186  return MNG_NOERROR;
1187}
1188#endif /* MNG_SUPPORT_READ */
1189
1190/* ************************************************************************** */
1191
1192#ifdef MNG_SUPPORT_DISPLAY
1193mng_retcode MNG_DECL mng_set_speed (mng_handle    hHandle,
1194                                    mng_speedtype iSpeed)
1195{
1196#ifdef MNG_SUPPORT_TRACE
1197  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_START);
1198#endif
1199
1200  MNG_VALIDHANDLE (hHandle)
1201  ((mng_datap)hHandle)->iSpeed = iSpeed;
1202
1203#ifdef MNG_SUPPORT_TRACE
1204  MNG_TRACE (((mng_datap)hHandle), MNG_FN_SET_SPEED, MNG_LC_END);
1205#endif
1206
1207  return MNG_NOERROR;
1208}
1209#endif /* MNG_SUPPORT_DISPLAY */
1210
1211/* ************************************************************************** */
1212/* *                                                                        * */
1213/* *  Property get functions                                                * */
1214/* *                                                                        * */
1215/* ************************************************************************** */
1216
1217mng_ptr MNG_DECL mng_get_userdata (mng_handle hHandle)
1218{                            /* no tracing in here to prevent recursive calls */
1219  MNG_VALIDHANDLEX (hHandle)
1220  return ((mng_datap)hHandle)->pUserdata;
1221}
1222
1223/* ************************************************************************** */
1224
1225mng_imgtype MNG_DECL mng_get_sigtype (mng_handle hHandle)
1226{
1227#ifdef MNG_SUPPORT_TRACE
1228  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_START);
1229#endif
1230
1231  if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC))
1232    return mng_it_unknown;
1233
1234#ifdef MNG_SUPPORT_TRACE
1235  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIGTYPE, MNG_LC_END);
1236#endif
1237
1238  return ((mng_datap)hHandle)->eSigtype;
1239}
1240
1241/* ************************************************************************** */
1242
1243mng_imgtype MNG_DECL mng_get_imagetype (mng_handle hHandle)
1244{
1245#ifdef MNG_SUPPORT_TRACE
1246  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_START);
1247#endif
1248
1249  if ((hHandle == 0) || (((mng_datap)hHandle)->iMagic != MNG_MAGIC))
1250    return mng_it_unknown;
1251
1252#ifdef MNG_SUPPORT_TRACE
1253  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGETYPE, MNG_LC_END);
1254#endif
1255
1256  return ((mng_datap)hHandle)->eImagetype;
1257}
1258
1259/* ************************************************************************** */
1260
1261mng_uint32 MNG_DECL mng_get_imagewidth (mng_handle hHandle)
1262{
1263#ifdef MNG_SUPPORT_TRACE
1264  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START);
1265#endif
1266
1267  MNG_VALIDHANDLEX (hHandle)
1268
1269#ifdef MNG_SUPPORT_TRACE
1270  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_END);
1271#endif
1272
1273  return ((mng_datap)hHandle)->iWidth;
1274}
1275
1276/* ************************************************************************** */
1277
1278mng_uint32 MNG_DECL mng_get_imageheight (mng_handle hHandle)
1279{
1280#ifdef MNG_SUPPORT_TRACE
1281  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEWIDTH, MNG_LC_START);
1282#endif
1283
1284  MNG_VALIDHANDLEX (hHandle)
1285
1286#ifdef MNG_SUPPORT_TRACE
1287  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_IMAGEHEIGHT, MNG_LC_END);
1288#endif
1289
1290  return ((mng_datap)hHandle)->iHeight;
1291}
1292
1293/* ************************************************************************** */
1294
1295mng_uint32 MNG_DECL mng_get_ticks (mng_handle hHandle)
1296{
1297#ifdef MNG_SUPPORT_TRACE
1298  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_START);
1299#endif
1300
1301  MNG_VALIDHANDLEX (hHandle)
1302
1303#ifdef MNG_SUPPORT_TRACE
1304  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_TICKS, MNG_LC_END);
1305#endif
1306
1307  return ((mng_datap)hHandle)->iTicks;
1308}
1309
1310/* ************************************************************************** */
1311
1312mng_uint32 MNG_DECL mng_get_framecount (mng_handle hHandle)
1313{
1314#ifdef MNG_SUPPORT_TRACE
1315  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_START);
1316#endif
1317
1318  MNG_VALIDHANDLEX (hHandle)
1319
1320#ifdef MNG_SUPPORT_TRACE
1321  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FRAMECOUNT, MNG_LC_END);
1322#endif
1323
1324  return ((mng_datap)hHandle)->iFramecount;
1325}
1326
1327/* ************************************************************************** */
1328
1329mng_uint32 MNG_DECL mng_get_layercount (mng_handle hHandle)
1330{
1331#ifdef MNG_SUPPORT_TRACE
1332  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_START);
1333#endif
1334
1335  MNG_VALIDHANDLEX (hHandle)
1336
1337#ifdef MNG_SUPPORT_TRACE
1338  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_LAYERCOUNT, MNG_LC_END);
1339#endif
1340
1341  return ((mng_datap)hHandle)->iLayercount;
1342}
1343
1344/* ************************************************************************** */
1345
1346mng_uint32 MNG_DECL mng_get_playtime (mng_handle hHandle)
1347{
1348#ifdef MNG_SUPPORT_TRACE
1349  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_START);
1350#endif
1351
1352  MNG_VALIDHANDLEX (hHandle)
1353
1354#ifdef MNG_SUPPORT_TRACE
1355  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_PLAYTIME, MNG_LC_END);
1356#endif
1357
1358  return ((mng_datap)hHandle)->iPlaytime;
1359}
1360
1361/* ************************************************************************** */
1362
1363mng_uint32 MNG_DECL mng_get_simplicity (mng_handle hHandle)
1364{
1365#ifdef MNG_SUPPORT_TRACE
1366  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_START);
1367#endif
1368
1369  MNG_VALIDHANDLEX (hHandle)
1370
1371#ifdef MNG_SUPPORT_TRACE
1372  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_SIMPLICITY, MNG_LC_END);
1373#endif
1374
1375  return ((mng_datap)hHandle)->iSimplicity;
1376}
1377
1378/* ************************************************************************** */
1379
1380mng_uint8 MNG_DECL mng_get_bitdepth (mng_handle hHandle)
1381{
1382  mng_uint8 iRslt;
1383
1384#ifdef MNG_SUPPORT_TRACE
1385  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_START);
1386#endif
1387
1388  MNG_VALIDHANDLEX (hHandle)
1389
1390  if (((mng_datap)hHandle)->eImagetype == mng_it_png)
1391    iRslt = ((mng_datap)hHandle)->iBitdepth;
1392  else
1393#ifdef MNG_INCLUDE_JNG
1394  if (((mng_datap)hHandle)->eImagetype == mng_it_jng)
1395    iRslt = ((mng_datap)hHandle)->iJHDRimgbitdepth;
1396  else
1397#endif
1398    iRslt = 0;
1399
1400#ifdef MNG_SUPPORT_TRACE
1401  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_BITDEPTH, MNG_LC_END);
1402#endif
1403
1404  return iRslt;
1405}
1406
1407/* ************************************************************************** */
1408
1409mng_uint8 MNG_DECL mng_get_colortype (mng_handle hHandle)
1410{
1411  mng_uint8 iRslt;
1412
1413#ifdef MNG_SUPPORT_TRACE
1414  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_START);
1415#endif
1416
1417  MNG_VALIDHANDLEX (hHandle)
1418
1419  if (((mng_datap)hHandle)->eImagetype == mng_it_png)
1420    iRslt = ((mng_datap)hHandle)->iColortype;
1421  else
1422#ifdef MNG_INCLUDE_JNG
1423  if (((mng_datap)hHandle)->eImagetype == mng_it_jng)
1424    iRslt = ((mng_datap)hHandle)->iJHDRcolortype;
1425  else
1426#endif
1427    iRslt = 0;
1428
1429#ifdef MNG_SUPPORT_TRACE
1430  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COLORTYPE, MNG_LC_END);
1431#endif
1432
1433  return iRslt;
1434}
1435
1436/* ************************************************************************** */
1437
1438mng_uint8 MNG_DECL mng_get_compression (mng_handle hHandle)
1439{
1440  mng_uint8 iRslt;
1441
1442#ifdef MNG_SUPPORT_TRACE
1443  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_START);
1444#endif
1445
1446  MNG_VALIDHANDLEX (hHandle)
1447
1448  if (((mng_datap)hHandle)->eImagetype == mng_it_png)
1449    iRslt = ((mng_datap)hHandle)->iCompression;
1450  else
1451#ifdef MNG_INCLUDE_JNG
1452  if (((mng_datap)hHandle)->eImagetype == mng_it_jng)
1453    iRslt = ((mng_datap)hHandle)->iJHDRimgcompression;
1454  else
1455#endif
1456    iRslt = 0;
1457
1458#ifdef MNG_SUPPORT_TRACE
1459  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_COMPRESSION, MNG_LC_END);
1460#endif
1461
1462  return iRslt;
1463}
1464
1465/* ************************************************************************** */
1466
1467mng_uint8 MNG_DECL mng_get_filter (mng_handle hHandle)
1468{
1469  mng_uint8 iRslt;
1470
1471#ifdef MNG_SUPPORT_TRACE
1472  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_START);
1473#endif
1474
1475  MNG_VALIDHANDLEX (hHandle)
1476
1477  if (((mng_datap)hHandle)->eImagetype == mng_it_png)
1478    iRslt = ((mng_datap)hHandle)->iFilter;
1479  else
1480    iRslt = 0;
1481
1482#ifdef MNG_SUPPORT_TRACE
1483  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_FILTER, MNG_LC_END);
1484#endif
1485
1486  return iRslt;
1487}
1488
1489/* ************************************************************************** */
1490
1491mng_uint8 MNG_DECL mng_get_interlace (mng_handle hHandle)
1492{
1493  mng_uint8 iRslt;
1494
1495#ifdef MNG_SUPPORT_TRACE
1496  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_START);
1497#endif
1498
1499  MNG_VALIDHANDLEX (hHandle)
1500
1501  if (((mng_datap)hHandle)->eImagetype == mng_it_png)
1502    iRslt = ((mng_datap)hHandle)->iInterlace;
1503  else
1504#ifdef MNG_INCLUDE_JNG
1505  if (((mng_datap)hHandle)->eImagetype == mng_it_jng)
1506    iRslt = ((mng_datap)hHandle)->iJHDRimginterlace;
1507  else
1508#endif
1509    iRslt = 0;
1510
1511#ifdef MNG_SUPPORT_TRACE
1512  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_INTERLACE, MNG_LC_END);
1513#endif
1514
1515  return iRslt;
1516}
1517
1518/* ************************************************************************** */
1519
1520mng_uint8 MNG_DECL mng_get_alphabitdepth (mng_handle hHandle)
1521{
1522  mng_uint8 iRslt;
1523
1524#ifdef MNG_SUPPORT_TRACE
1525  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_START);
1526#endif
1527
1528  MNG_VALIDHANDLEX (hHandle)
1529
1530#ifdef MNG_INCLUDE_JNG
1531  if (((mng_datap)hHandle)->eImagetype == mng_it_jng)
1532    iRslt = ((mng_datap)hHandle)->iJHDRalphabitdepth;
1533  else
1534#endif
1535    iRslt = 0;
1536
1537#ifdef MNG_SUPPORT_TRACE
1538  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_ALPHABITDEPTH, MNG_LC_END);
1539#endif
1540
1541  return iRslt;
1542}
1543
1544/* ************************************************************************** */
1545
1546#ifdef MNG_SUPPORT_DISPLAY
1547mng_uint8 MNG_DECL mng_get_refreshpass (mng_handle hHandle)
1548{
1549  mng_uint8 iRslt;
1550  mng_datap pData;
1551
1552#ifdef MNG_SUPPORT_TRACE
1553  MNG_TRACEX (((mng_datap)hHandle), MNG_FN_GET_REFRESHPASS, MNG_LC_START);
1554#endif
1555
1556  MNG_VALIDHANDLEX (hHandle)
1557
1558  pData = (mng_datap)hHandle;
1559                                       /* for PNG we know the exact pass */
1560  if ((pData->eImagetype == mng_it_png) && (pData->iPass >= 0))
1561    iRslt = pData->iPass;
1562#ifdef MNG_INCLUDE_JNG
1563  else                                 /* for JNG we'll fake it... */
1564  if ((pData->eImagetype == mng_it_jng) &&
1565      (pData->bJPEGhasheader) && (pData->bJPEGdecostarted) &&
1566      (pData->bJPEGprogressive))
1567  {
1568    if (pData->pJPEGdinfo->input_scan_number <= 1)
1569      iRslt = 0;                       /* first pass (I think...) */
1570    else
1571    if (jpeg_input_complete (pData->pJPEGdinfo))
1572      iRslt = 7;                       /* input complete; aka final pass */
1573    else
1574

Large files files are truncated, but you can click here to view the full file