📄 libmng_display.c
字号:
/* ************************************************************************** *//* * For conditions of distribution and use, * *//* * see copyright notice in libmng.h * *//* ************************************************************************** *//* * * *//* * project : libmng * *//* * file : libmng_display.c copyright (c) 2000 G.Juyn * *//* * version : 1.0.2 * *//* * * *//* * purpose : Display management (implementation) * *//* * * *//* * author : G.Juyn * *//* * web : http://www.3-t.com * *//* * email : mailto:info@3-t.com * *//* * * *//* * comment : implementation of the display management routines * *//* * * *//* * changes : 0.5.1 - 05/08/2000 - G.Juyn * *//* * - changed strict-ANSI stuff * *//* * 0.5.1 - 05/11/2000 - G.Juyn * *//* * - added callback error-reporting support * *//* * - fixed frame_delay misalignment * *//* * 0.5.1 - 05/12/2000 - G.Juyn * *//* * - added sanity check for frozen status * *//* * - changed trace to macro for callback error-reporting * *//* * 0.5.1 - 05/13/2000 - G.Juyn * *//* * - changed display_mend to reset state to initial or SAVE * *//* * - added eMNGma hack (will be removed in 1.0.0 !!!) * *//* * - added TERM animation object pointer (easier reference) * *//* * - added process_save & process_seek routines * *//* * 0.5.1 - 05/14/2000 - G.Juyn * *//* * - added save_state and restore_state for SAVE/SEEK/TERM * *//* * processing * *//* * * *//* * 0.5.2 - 05/20/2000 - G.Juyn * *//* * - added JNG support (JHDR/JDAT) * *//* * 0.5.2 - 05/23/2000 - G.Juyn * *//* * - fixed problem with DEFI clipping * *//* * 0.5.2 - 05/30/2000 - G.Juyn * *//* * - added delta-image support (DHDR,PROM,IPNG,IJNG) * *//* * 0.5.2 - 05/31/2000 - G.Juyn * *//* * - fixed pointer confusion (contributed by Tim Rowley) * *//* * 0.5.2 - 06/03/2000 - G.Juyn * *//* * - fixed makeup for Linux gcc compile * *//* * 0.5.2 - 06/05/2000 - G.Juyn * *//* * - added support for RGB8_A8 canvasstyle * *//* * 0.5.2 - 06/09/2000 - G.Juyn * *//* * - fixed timer-handling to run with Mozilla (Tim Rowley) * *//* * 0.5.2 - 06/10/2000 - G.Juyn * *//* * - fixed some compilation-warnings (contrib Jason Morris) * *//* * * *//* * 0.5.3 - 06/12/2000 - G.Juyn * *//* * - fixed display of stored JNG images * *//* * 0.5.3 - 06/13/2000 - G.Juyn * *//* * - fixed problem with BASI-IEND as object 0 * *//* * 0.5.3 - 06/16/2000 - G.Juyn * *//* * - changed progressive-display processing * *//* * 0.5.3 - 06/17/2000 - G.Juyn * *//* * - changed delta-image processing * *//* * 0.5.3 - 06/20/2000 - G.Juyn * *//* * - fixed some minor stuff * *//* * 0.5.3 - 06/21/2000 - G.Juyn * *//* * - added speed-modifier to timing routine * *//* * 0.5.3 - 06/22/2000 - G.Juyn * *//* * - added support for PPLT chunk processing * *//* * 0.5.3 - 06/29/2000 - G.Juyn * *//* * - swapped refresh parameters * *//* * * *//* * 0.9.0 - 06/30/2000 - G.Juyn * *//* * - changed refresh parameters to 'x,y,width,height' * *//* * * *//* * 0.9.1 - 07/07/2000 - G.Juyn * *//* * - implemented support for freeze/reset/resume & go_xxxx * *//* * 0.9.1 - 07/08/2000 - G.Juyn * *//* * - added support for improved timing * *//* * 0.9.1 - 07/14/2000 - G.Juyn * *//* * - changed EOF processing behavior * *//* * - fixed TERM delay processing * *//* * 0.9.1 - 07/15/2000 - G.Juyn * *//* * - fixed freeze & reset processing * *//* * 0.9.1 - 07/16/2000 - G.Juyn * *//* * - fixed storage of images during mng_read() * *//* * - fixed support for mng_display() after mng_read() * *//* * 0.9.1 - 07/24/2000 - G.Juyn * *//* * - fixed reading of still-images * *//* * * *//* * 0.9.2 - 08/05/2000 - G.Juyn * *//* * - changed file-prefixes * *//* * * *//* * 0.9.3 - 08/07/2000 - G.Juyn * *//* * - B111300 - fixup for improved portability * *//* * 0.9.3 - 08/21/2000 - G.Juyn * *//* * - fixed TERM processing delay of 0 msecs * *//* * 0.9.3 - 08/26/2000 - G.Juyn * *//* * - added MAGN chunk * *//* * 0.9.3 - 09/10/2000 - G.Juyn * *//* * - fixed problem with no refresh after TERM * *//* * - fixed DEFI behavior * *//* * 0.9.3 - 09/16/2000 - G.Juyn * *//* * - fixed timing & refresh behavior for single PNG/JNG * *//* * 0.9.3 - 09/19/2000 - G.Juyn * *//* * - refixed timing & refresh behavior for single PNG/JNG * *//* * 0.9.3 - 10/02/2000 - G.Juyn * *//* * - fixed timing again (this is getting boring...) * *//* * - refixed problem with no refresh after TERM * *//* * 0.9.3 - 10/16/2000 - G.Juyn * *//* * - added JDAA chunk * *//* * 0.9.3 - 10/17/2000 - G.Juyn * *//* * - fixed support for bKGD * *//* * 0.9.3 - 10/18/2000 - G.Juyn * *//* * - fixed delta-processing behavior * *//* * 0.9.3 - 10/19/2000 - G.Juyn * *//* * - added storage for pixel-/alpha-sampledepth for delta's * *//* * 0.9.3 - 10/27/2000 - G.Juyn * *//* * - fixed seperate read() & display() processing * *//* * * *//* * 0.9.4 - 10/31/2000 - G.Juyn * *//* * - fixed possible loop in display_resume() (Thanks Vova!) * *//* * 0.9.4 - 11/20/2000 - G.Juyn * *//* * - fixed unwanted repetition in mng_readdisplay() * *//* * 0.9.4 - 11/24/2000 - G.Juyn * *//* * - moved restore of object 0 to libmng_display * *//* * - added restore of object 0 to TERM processing !!! * *//* * - fixed TERM delay processing * *//* * - fixed TERM end processing (count = 0) * *//* * 0.9.4 - 12/16/2000 - G.Juyn * *//* * - fixed mixup of data- & function-pointers (thanks Dimitri)* *//* * 0.9.4 - 1/18/2001 - G.Juyn * *//* * - removed test filter-methods 1 & 65 * *//* * - set default level-set for filtertype=64 to all zeroes * *//* * * *//* * 0.9.5 - 1/20/2001 - G.Juyn * *//* * - fixed compiler-warnings Mozilla (thanks Tim) * *//* * 0.9.5 - 1/23/2001 - G.Juyn * *//* * - fixed timing-problem with switching framing_modes * *//* * * *//* * 1.0.1 - 02/08/2001 - G.Juyn * *//* * - added MEND processing callback * *//* * 1.0.1 - 02/13/2001 - G.Juyn * *//* * - fixed first FRAM_MODE=4 timing problem * *//* * 1.0.1 - 04/21/2001 - G.Juyn * *//* * - fixed memory-leak for JNGs with alpha (Thanks Gregg!) * *//* * - added BGRA8 canvas with premultiplied alpha * *//* * * *//* * 1.0.2 - 06/25/2001 - G.Juyn * *//* * - fixed memory-leak with delta-images (Thanks Michael!) * *//* * * *//* ************************************************************************** */#include "libmng.h"#include "libmng_data.h"#include "libmng_error.h"#include "libmng_trace.h"#ifdef __BORLANDC__#pragma hdrstop#endif#include "libmng_objects.h"#include "libmng_object_prc.h"#include "libmng_memory.h"#include "libmng_zlib.h"#include "libmng_jpeg.h"#include "libmng_cms.h"#include "libmng_pixels.h"#include "libmng_display.h"#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)#pragma option -A /* force ANSI-C */#endif/* ************************************************************************** */#ifdef MNG_INCLUDE_DISPLAY_PROCS/* ************************************************************************** */mng_retcode set_delay (mng_datap pData, mng_uint32 iInterval){ if (!iInterval) /* at least 1 msec please! */ iInterval = 1; if (!pData->fSettimer ((mng_handle)pData, iInterval)) MNG_ERROR (pData, MNG_APPTIMERERROR) pData->bTimerset = MNG_TRUE; /* and indicate so */ return MNG_NOERROR;}/* ************************************************************************** *//* * * *//* * Progressive display refresh - does the call to the refresh callback * *//* * and sets the timer to allow the app to perform the actual refresh to * *//* * the screen (eg. process its main message-loop) * *//* * * *//* ************************************************************************** */mng_retcode display_progressive_refresh (mng_datap pData, mng_uint32 iInterval){ if (!pData->bSearching) /* we mustn't be searching !!! */ { if ((pData->bRunning) && /* let the app refresh first ? */ (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) { if (!pData->fRefresh (((mng_handle)pData), pData->iUpdateleft, pData->iUpdatetop, pData->iUpdateright - pData->iUpdateleft, pData->iUpdatebottom - pData->iUpdatetop)) MNG_ERROR (pData, MNG_APPMISCERROR) pData->iUpdateleft = 0; /* reset update-region */ pData->iUpdateright = 0; pData->iUpdatetop = 0; pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ pData->bNeedrefresh = MNG_FALSE; /* interval requested ? */ if ((!pData->bFreezing) && (iInterval)) { /* setup the timer */ mng_retcode iRetcode = set_delay (pData, iInterval); if (iRetcode) /* on error bail out */ return iRetcode; } } } return MNG_NOERROR;}/* ************************************************************************** *//* * * *//* * Generic display routines * *//* * * *//* ************************************************************************** */mng_retcode interframe_delay (mng_datap pData){ mng_uint32 iWaitfor = 0; mng_uint32 iInterval; mng_uint32 iRuninterval; mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (pData, MNG_FN_INTERFRAME_DELAY, MNG_LC_START)#endif if (!pData->bSearching) /* we mustn't be searching !!! */ { if (pData->iFramedelay > 0) /* real delay ? */ { if ((pData->bRunning) && /* let the app refresh first ? */ (pData->iUpdatetop < pData->iUpdatebottom) && (pData->iUpdateleft < pData->iUpdateright)) if (!pData->fRefresh (((mng_handle)pData), pData->iUpdateleft, pData->iUpdatetop, pData->iUpdateright - pData->iUpdateleft, pData->iUpdatebottom - pData->iUpdatetop)) MNG_ERROR (pData, MNG_APPMISCERROR) pData->iUpdateleft = 0; /* reset update-region */ pData->iUpdateright = 0; pData->iUpdatetop = 0; pData->iUpdatebottom = 0; /* reset refreshneeded indicator */ pData->bNeedrefresh = MNG_FALSE; /* get current tickcount */ pData->iRuntime = pData->fGettickcount ((mng_handle)pData); /* calculate interval since last sync-point */ if (pData->iRuntime < pData->iSynctime) iRuninterval = pData->iRuntime + ~pData->iSynctime + 1; else iRuninterval = pData->iRuntime - pData->iSynctime; /* calculate actual run-time */ if (pData->iRuntime < pData->iStarttime) pData->iRuntime = pData->iRuntime + ~pData->iStarttime + 1; else pData->iRuntime = pData->iRuntime - pData->iStarttime; if (pData->iTicks) /* what are we aiming for */ { switch (pData->iSpeed) /* honor speed modifier */ { case mng_st_fast : { iWaitfor = (mng_uint32)(( 500 * pData->iFramedelay) / pData->iTicks); break; } case mng_st_slow : { iWaitfor = (mng_uint32)((3000 * pData->iFramedelay) / pData->iTicks); break; } case mng_st_slowest : { iWaitfor = (mng_uint32)((8000 * pData->iFramedelay) / pData->iTicks); break; } default :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -