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

📄 libmng.txt

📁 Linux下的基于X11的图形开发环境。
💻 TXT
📖 第 1 页 / 共 3 页
字号:
This is the easiest method, providing you can compile the lcms package.Select the MNG_FULL_CMS directive during compilation, and sit back andrelax. The library will take care of all color-correction for you.> Using an OS- or application-supplied CMSIf you are so lucky to have access to CMS functionality from withinyour application, you may instruct the library to leave color-correctionto you.Select the MNG_APP_CMS directive during compilation of the library.You MUST also set the following callbacks:    mng_processgamma, mng_processchroma,    mng_processsrgb, mng_processiccp and    mng_processarowThe last callback is called when the library needs you to correctan arbitrary line of pixels. The other callbacks are called whenthe corresponding color-information is encountered in the file.You must store this information somewhere for use in themng_processarow() callback.> Using gamma-only correctionThis isn't a preferred method, but it's better than no correctionat all. Gamma-only correction will at least compensate forgamma-differences between the original recorder and your output device.Select the MNG_GAMMA_ONLY directive during compilationof the library. Your compiler MUST support fp operations.> No color correctionOuch. This is really bad. This is the least preferred method,but may be necessary if your system cannot use lcms, doesn'thave its own CMS, and does not allow fp operations, ruling outthe gamma-only option.Select the MNG_NO_CMS directive during compilation.Images will definitely not be displayed as seen by the Author!!!> Animations and timingAnimations require some form of timing support. The library relieson two callbacks for this purpose. The mng_gettickcount() andmng_settimer() callbacks. mng_gettickcount() is used to determinethe passing of time in milliseconds since the beginning of theanimation. This is also used to compensate during suspension-modeif you are using the mng_readdisplay() function to read & displaythe file simultaneously.The callback may return an arbitrary number of milliseconds, butthis number must increase proportionaly between calls. Most modernsystems will have some tickcount() function which derives itsinput from an internal clock. The value returned from this functionis more than adequate for libmng.The mng_settimer() callback is called when the library determinesa little "pause" is required before rendering another frame of theanimation. The pause interval is also expressed in milliseconds.Your application should store this value and return immediately.The library will then make appropriate arrangements to store itsinternal state and returns to your application with theMNG_NEEDTIMERWAIT code.At that point you should suspend processing and wait the giveninterval. Please use your OS features for this. Do not engage somesort of loop. That is real bad programming practice. Most modernsystems will have some timing functions. A simple wait() functionmay suffice, but this may prevent your applications main-task fromrunning, and possibly prevent the actual update of your output device.> The mng_refresh() callbackThe mng_refresh() callback is called whenever the library has"finished" drawing a new frame onto your canvas, and just before itwill call the mng_settimer() callback.This allows you to perform some actions necessary to "refresh" thecanvas onto your output device. Please do NOT suspend processinginside this callback. This must be handled after the mng_settimer()callback!> Displaying while readingThis method is preferred if you are reading from a slow input device(such as a dialup-line) and you wish to start displaying somethingas quickly as possible. This functionality is provided mainly forbrowser-type applications but may be appropriate for otherapplications as well.The method is usually used in unison with the suspension-mode ofthe read module. A typical implementation would look like this:    /* initiale library and set required callbacks */    /* activate suspension-mode */    myretcode = mng_set_suspensionmode (myhandle,                                         MNG_TRUE);    if (myretcode != MNG_NOERROR)      /* process error */;    myretcode = mng_readdisplay (myhandle);    while ((myretcode == MNG_NEEDMOREDATA) ||           (myretcode == MNG_NEEDTIMERWAIT)) {      if (myretcode == MNG_NEEDMOREDATA)        /* wait for more input-data */;      else        /* wait for timer interval */;      myretcode = mng_display_resume (myhandle);    }    if (myretcode != MNG_NOERROR)      /* process error */;More advanced programming methods may require a different approach,but the final result should function as in the code above.> Displaying after readingThis method is used to display a file that was previously read.It is primarily meant for viewers with direct file access, such as1a local harddisk.Once you have successfully read the file, all you need to do is:    myretcode = mng_display (myhandle);    while (myretcode == MNG_NEEDTIMERWAIT) {      /* wait for timer interval */;      myretcode = mng_display_resume (myhandle);    }    if (myretcode != MNG_NOERROR)      /* process error */;Again, more advanced programming methods may require a differentapproach, but the final result should function as in the code above.> Display manipulationSeveral HLAPI functions are provided to allow a user to manipulatethe normal flow of an animation.- mng_display_freeze (mng_handle hHandle)This will "freeze" the animation in place.- mng_display_resume (mng_handle hHandle)This function can be used to resume a frozen animation, or to forcethe library to advance the animation to the next frame.- mng_display_reset (mng_handle hHandle)This function will "reset" the animation into its pristine state.Calling mng_display_resume() afterwards will restart the animationfrom the first frame.- mng_display_golayer    (mng_handle hHandle,                          mng_uint32 iLayer)- mng_display_goframe    (mng_handle hHandle,                          mng_uint32 iFrame)- mng_display_goplaytime (mng_handle hHandle,                          mng_uint32 iPlaytime)These three functions can be used to "jump" to a specific layer, frameor timeslot in the animation. You must "freeze" the animation beforeusing any of these functions.All above functions may only be called during a timer interval!It is the applications responsibility to cleanup any resources withrespect to the timer wait.VI. WritingThe main focus of the library lies in its displaying capabilites.But it does offer writing support as well.You can create and write a file, or you can write a file youhave previously read, providing the storage of chunks was enabledand active.For this to work you must have compiled the library with theMNG_WRITE_SUPPO1RT and MNG_ACCESS_CHUNKS directives. The standard DLL andShared Library have this on by default!> SetupAs always you must have initialized the library and be the owner ofa mng_handle. The following callbacks are essential:    mng_openstream, mng_writedata, mng_closestreamYou can optionally define:    mng_errorproc, mng_traceprocThe creation and writing functions will fail if you are in the middleof reading, creating or writing a file.> Creating a new fileTo start a new file the library must be in its initial state.First you need to tell the library your intentions:    myretcode = mng_create (myhandle);    if (myretcode != MNG_NOERROR)      /* process error */;After that you start adding the appropriate chunks:    myretcode = mng_putchunk_mhdr (myhandle, ...);    if (myretcode != MNG_NOERROR)      /* process error */;And so on, and so forth. Note that the library will automatically signalthe logical end of the file by the ending chunk. Also the first chunkwill indicate the library the filetype (eg. PNG, JNG or MNG) and forcethe proper signature when writing the file.The code above can be simplified, as you can always get the last errorcodeby using the mng_getlasterror() function:    if ( (mng_putchunk_xxxx (myhandle, ...)) or         (mng_putchunk_xxxx (myhandle, ...)) or             ...etc...                          )      /* process error */;Please note that you must have a pretty good understanding of the chunkspecification. Unlike the read functions, there are virtually no checks,so it is quite possible to write completely wrong files.It is a good practice to read back your file into the library to verifyits integrity.Once you've got all the chunks added, all you do is:    myretcode mng_write (myhandle);    if (myretcode != MNG_NOERROR)      /* process error */;And presto. You're done. The real work is of course carried out inyour callbacks. Note that this is a single operation as opposed tothe read & display functions that may return with MNG_NEEDMOREDATAand/or MNG_NEEDTIMERWAIT. The write function just does the job, andonly returns after it's finished or if it encounters someunrecoverable error.> Writing a previously read fileIf you have already successfully read a file, you can use the library towrite it out as a copy or something. You MUST have compiled the librarywith the MNG_STORE_CHUNKS directive, and you must have donemng_set_storechunks (myhandle, MNG_TRUE).This doesn't require the MNG_ACCESS_CHUNKS directive, unless you wantto fiddle with the chunks as well.Again all you need to do is:    myretcode mng_write (myhandle);    if (myretcode != MNG_NOERROR)      /* process error */;VII. Modifying/Customizing libmng:to do> Compilation directivesto do> Platform dependant modificationto doReferences :libmng :  http://www.libmng.comzlib :   http://www.info-zip.org/pub/infozip/zlib/IJG JPEG library :  http://www.ijg.orglcms (little CMS) by Marti Maria Saguer :  http://www.littlecms.com/MNG specification:  http://www.libpng.org/pub/mngIn the case of any inconsistency between the MNG specificationand this library, the specification takes precedence.The contributing authors would like to thank all those who helpedwith testing, bug fixes, and patience.  This wouldn't have beenpossible without all of you!!!COPYRIGHT NOTICE:Copyright (c) 2000,2001 Gerard JuynFor the purposes of this copyright and license, "Contributing Authors"is defined as the following set of individuals:   Gerard JuynThe MNG Library is supplied "AS IS".  The Contributing Authorsdisclaim all warranties, expressed or implied, including, withoutlimitation, the warranties of merchantability and of fitness for anypurpose.  The Contributing Authors assume no liability for direct,indirect, incidental, special, exemplary, or consequential damages,which may result from the use of the MNG Library, even if advised ofthe possibility of such damage.Permission is hereby granted to use, copy, modify, and distribute thissource code, or portions hereof, for any purpose, without fee, subjectto the following restrictions:1. The origin of this source code must not be misrepresented;you must not claim that you wrote the original software.2. Altered versions must be plainly marked as such and must not bemisrepresented as being the original source.3. This Copyright notice may not be removed or altered from any sourceor altered source distribution.The Contributing Authors specifically permit, without fee, andencourage the use of this source code as a component to supportingthe MNG and JNG file format in commercial products.  If you use thissource code in a product, acknowledgment would be highly appreciated.Remarks :Parts of this software have been adapted from the libpng library.Although this library supports all features from the PNG specification(as MNG descends from it) it does not require the libpng library.It does require the zlib library and optionally the IJG JPEG library,and/or the "little-cms" library by Marti Maria Saguer (depending on theinclusion of support for JNG and Full-Color-Management respectively.This library's function is primarily to read and display MNGanimations. It is not meant as a full-featured image-editingcomponent! It does however offer creation and editing functionalityat the chunk level. (future modifications may include some moresupport for creation and or editing)

⌨️ 快捷键说明

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