Example #1
0
BOOL PAC_PackFileMovie_NextRead( MOVE_INFO *mi, void *dest, int draw_mode, int bai, int count, int skip )
{
	int			i;
	DWORD		esize;
	DWORD		now_esize;
	DWORD		key_frame=0;


	for(i=0;i<count;i++){
		if( mi->bmi.sabun ){
			now_esize = mi->next_size[0];
			key_frame = mi->next_size[1]&0x7fffffff;

			mi->count += LIM(11-skip,1,10);
			ReadFile( mi->fh, mi->buf, now_esize, &esize, NULL);
			
			mi->next_size[0] = *(DWORD*)&mi->buf[now_esize-8];
			mi->next_size[1] = *(DWORD*)&mi->buf[now_esize-4];

			PAC_DecodeMemoryBmpTbl( mi, dest, draw_mode, bai, now_esize-8 );

			if(now_esize > esize){
				return FALSE;
			}
		}else{
			now_esize = mi->next_size[0];
			key_frame = mi->next_size[1]&0x7fffffff;
			mi->count += LIM(11-skip,1,10);
			
			if(i+1==count || key_frame){

				ReadFile( mi->fh, mi->buf, now_esize, &esize, NULL);

				mi->next_size[0] = *(DWORD*)&mi->buf[now_esize-8];
				mi->next_size[1] = *(DWORD*)&mi->buf[now_esize-4];
				PAC_DecodeMemoryBmpTbl( mi, dest, draw_mode, bai, now_esize-8 );

				if(now_esize > esize){
					return FALSE;
				}
				break;
			}else{
				SetFilePointer( mi->fh, now_esize-8, NULL, FILE_CURRENT );
				
				ReadFile( mi->fh, mi->next_size, 8, &esize, NULL);
				if(8 > esize){
					SetFilePointer( mi->fh, -(int)(now_esize-8), NULL, FILE_CURRENT );
					ReadFile( mi->fh, mi->buf, now_esize, &esize, NULL );
					PAC_DecodeMemoryBmpTbl( mi, dest, draw_mode, bai, now_esize-8 );
					return FALSE;
				}
			}
		}
		if( key_frame )
			break;	
	}
	return TRUE;
}
Example #2
0
/* Verify anti-symmetry and transitivity for comparator CMP on sorted array
   of N SIZE-sized elements pointed to by BASE.  */
void
qsort_chk (void *base, size_t n, size_t size,
	   int (*cmp)(const void *, const void *))
{
#if 0
#define LIM(n) (n)
#else
  /* Limit overall time complexity to O(n log n).  */
#define LIM(n) ((n) <= 16 ? (n) : 12 + floor_log2 (n))
#endif
#define ELT(i) ((const char *) base + (i) * size)
#define CMP(i, j) cmp (ELT (i), ELT (j))
#define ERR2(i, j) qsort_chk_error (ELT (i), ELT (j), NULL, cmp)
#define ERR3(i, j, k) qsort_chk_error (ELT (i), ELT (j), ELT (k), cmp)
  size_t i1, i2, i, j;
  /* This outer loop iterates over maximum spans [i1, i2) such that
     elements within each span compare equal to each other.  */
  for (i1 = 0; i1 < n; i1 = i2)
    {
      /* Position i2 one past last element that compares equal to i1'th.  */
      for (i2 = i1 + 1; i2 < n; i2++)
	if (CMP (i1, i2))
	  break;
	else if (CMP (i2, i1))
	  return ERR2 (i1, i2);
      size_t lim1 = LIM (i2 - i1), lim2 = LIM (n - i2);
      /* Verify that other pairs within current span compare equal.  */
      for (i = i1 + 1; i + 1 < i2; i++)
	for (j = i + 1; j < i1 + lim1; j++)
	  if (CMP (i, j))
	    return ERR3 (i, i1, j);
	  else if (CMP (j, i))
	    return ERR2 (i, j);
      /* Verify that elements within this span compare less than
         elements beyond the span.  */
      for (i = i1; i < i2; i++)
	for (j = i2; j < i2 + lim2; j++)
	  if (CMP (i, j) >= 0)
	    return ERR3 (i, i1, j);
	  else if (CMP (j, i) <= 0)
	    return ERR2 (i, j);
    }
#undef ERR3
#undef ERR2
#undef CMP
#undef ELT
#undef LIM
}
Example #3
0
void FORTE_F_FT_LIMIT::alg_REQ(void){

OUT() = VAL();

/*  limit the output */
if((OUT() < LIM_L())){
	LIM() = true;
	OUT() = LIM_L();
}
else
  if((OUT() > LIM_H())){
	LIM() = true;
	OUT() = LIM_H();
}
else{
	LIM() = false;
};
}
Example #4
0
void EnumAdapters( int nAdapter )
{
	int		i,n;
	char	buf[128];

	n = pD3D->GetAdapterModeCount(nAdapter);
	D3DCapsStruct.m_DisplayModeNum = n;

	if( D3DCapsStruct.m_DisplayMode==NULL )
		D3DCapsStruct.m_DisplayMode = (D3DDISPLAYMODE*)GAlloc( sizeof(D3DDISPLAYMODE)*n );

	for( i=0 ; i<n ; i++ ){
		if( pD3D->EnumAdapterModes(nAdapter,i,&D3DCapsStruct.m_DisplayMode[i]) == D3D_OK){
			wsprintf( buf, "%d x %d (%d Hz) - %s\n",
							D3DCapsStruct.m_DisplayMode[i].Width,
							D3DCapsStruct.m_DisplayMode[i].Height,
							D3DCapsStruct.m_DisplayMode[i].RefreshRate,
							TxFmtMode[ LIM(D3DCapsStruct.m_DisplayMode[i].Format,0,D3DFMT_D3DD_MAX-1) ] );
			DebugPrintf( buf );
		}
	}
}
Example #5
0
BOOL DEM_SystemMain(void )
{
	int		bmp_bpp = BPP(MainWindow.draw_mode2);
	BOOL	ret = TRUE;
	int		dc = (0x1000-DemoCounter[0])%96-16;
	int		r2 = STD_LimitLoop( GlobalCount2*4, 255 );

	int		r = timeGetTime();
	int		lr = STD_LimitLoop( r/8, 255 );
	int		x = r%DISP_X;
	int		y = r%DISP_Y;
	int		i=0,j=0;
	static int	flag = 0;
	char		*str = "<Aアクセント>が出せます。\n\\k<s6一次停止、<w30><s4スピード変更>とか>\\k表示中の演出挿入";
	static int	mh;
	int			Angle = 0;
	static		an=0;
	int			count = DemoCounter[1]*4;
	int			mx,my;
	MUS_GetMousePos( &mx, &my );

	MainWindow.draw_flag=1;

	Avg.frame=30;

	static int	wavw_cnt=0;
	AVG_GetGameKey();
	if(GameKey.click)
		wavw_cnt=0;
	
	if(GameKey.cansel)
		ChangeSetpCounter( 1, (DemoStep[1]+1)%2, 0 );
	
	if(KeyCond.trg.f1)
	{
	}
	if(KeyCond.trg.f2)
	{
	}
	if(KeyCond.trg.f3)
	{
	}
	if(KeyCond.trg.f4)
	{
	}

	r = SIN( timeGetTime()/10%256 )/2 ;

	switch( DemoStep[1] )
	{
		default:
		case 0:
			DSP_SetGraphPrim( 0, PRM_FLAT, POL_RECT, 0, ON );
			DSP_SetGraphPosRect( 0, 0,0,800,600 );
			DSP_SetGraphBright( 0, 255,128,50 );

			r = DemoCounter[0]*2%256;

			DSP_SetGraph( 1, 10 + (DemoCounter[0]*2/256+0)%4, 1, ON, CHK_NO );
			DSP_SetGraph( 2, 10 + (DemoCounter[0]*2/256+1)%4, 1, ON, CHK_NO );
			DSP_SetGraph( 3, 10 + (DemoCounter[0]*2/256+2)%4, 1, ON, CHK_NO );
			DSP_SetGraph( 4, 10 + (DemoCounter[0]*2/256+3)%4, 1, !!r, CHK_NO );

			DSP_SetGraphFade( 1, 64-r/8 );
			DSP_SetGraphPosPoly( 1, -r,    -r, 200-r*200/256, 150-r*150/256,
									-r, 600+r, 200-r*200/256, 150+300+r*150/256,
									0, 0, 400,   0, 0, 300, 400,     300 );

			DSP_SetGraphFade( 2, 128-r/4 );
			DSP_SetGraphPosPoly( 2, 200-r*200/256,     150-r*150/256, 200+400-r*400/256, 150,
									200-r*200/256, 300+150+r*150/256, 400+200-r*400/256, 150+300,
									0, 0, 400,   0, 0, 300, 400,     300 );

			DSP_SetGraphFade( 3, 64+r/4 );
			DSP_SetGraphPosPoly( 3, 400+200-r*400/256,     150, 800-r*200/256, 0+r*150/256,
									400+200-r*400/256, 300+150, 800-r*200/256, 600-r*150/256,
									0, 0, 400,   0, 0, 300, 400,     300 );

			DSP_SetGraphFade( 4, 32+r/8 );
			DSP_SetGraphPosPoly( 4, 800-r*200/256,     r*150/256, 800+256-r,    -256+r,
									800-r*200/256, 600-r*150/256, 800+256-r, 600+256-r,
									0, 0, 400,   0, 0, 300, 400,     300 );
			break;
		case 1:
			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_ResetGraph( 1);
			DSP_ResetGraph( 2);
			DSP_ResetGraph( 3);
			DSP_ResetGraph( 4);
			if(0)
			{
				long	xxx[36];
				long	yyy[36];
				long	xx[6];
				long	yy[6];

				if(wavw_cnt<256) wavw_cnt+=4;
				r = COS( wavw_cnt )*1536/4096;
				r = r/32;

				xxx[0*6+0] = r*3;	yyy[0*6+0] = r*3;
				xxx[0*6+1] = r*2;	yyy[0*6+1] = r*2;
				xxx[0*6+2] = r;		yyy[0*6+2] = r;
				xxx[0*6+3] = -r;	yyy[0*6+3] = r;
				xxx[0*6+4] = -r*2;	yyy[0*6+4] = r*2;
				xxx[0*6+5] = -r*3;	yyy[0*6+5] = r*3;

				xxx[1*6+0] = r*2;	yyy[1*6+0] = r*2;
				xxx[1*6+1] = r;		yyy[1*6+1] = r;
				xxx[1*6+2] = r/2;	yyy[1*6+2] = r/2;
				xxx[1*6+3] = -r/2;	yyy[1*6+3] = r/2;
				xxx[1*6+4] = -r;	yyy[1*6+4] = r;
				xxx[1*6+5] = -r*2;	yyy[1*6+5] = r*2;

				xxx[2*6+0] = r;		yyy[2*6+0] = r;
				xxx[2*6+1] = r/2;	yyy[2*6+1] = r/2;
				xxx[2*6+2] = -r;	yyy[2*6+2] = -r;
				xxx[2*6+3] = r;		yyy[2*6+3] = -r;
				xxx[2*6+4] = -r/2;	yyy[2*6+4] = r/2;
				xxx[2*6+5] = -r;	yyy[2*6+5] = r;

				xxx[3*6+0] = r;		yyy[3*6+0] = -r;
				xxx[3*6+1] = r/2;	yyy[3*6+1] = -r/2;
				xxx[3*6+2] = -r;	yyy[3*6+2] = r;
				xxx[3*6+3] = r;		yyy[3*6+3] = r;
				xxx[3*6+4] = -r/2;	yyy[3*6+4] = -r/2;
				xxx[3*6+5] = -r;	yyy[3*6+5] = -r;

				xxx[4*6+0] = r*2;	yyy[4*6+0] = -r*2;
				xxx[4*6+1] = r;		yyy[4*6+1] = -r;
				xxx[4*6+2] = r/2;	yyy[4*6+2] = -r/2;
				xxx[4*6+3] = -r/2;	yyy[4*6+3] = -r/2;
				xxx[4*6+4] = -r;	yyy[4*6+4] = -r;
				xxx[4*6+5] = -r*2;	yyy[4*6+5] = -r*2;

				xxx[5*6+0] = r*3;	yyy[5*6+0] = -r*3;
				xxx[5*6+1] = r*2;	yyy[5*6+1] = -r*2;
				xxx[5*6+2] = r*1;	yyy[5*6+2] = -r*1;
				xxx[5*6+3] = -r*1;	yyy[5*6+3] = -r*1;
				xxx[5*6+4] = -r*2;	yyy[5*6+4] = -r*2;
				xxx[5*6+5] = -r*3;	yyy[5*6+5] = -r*3;

				x=mx;
				y=my;
				xx[0] = -128;
				xx[1] = 128+x*1/5-128;
				xx[2] = 128+x*4/5-128;
				xx[3] = 128+x+(800-x)/5-128;
				xx[4] = 128+x+(800-x)*4/5-128;
				xx[5] = 800+256-128;

				yy[0] = -96;
				yy[1] = 96+y*1/5-96;
				yy[2] = 96+y*4/5-96;
				yy[3] = 96+y+(600-y)/5-96;
				yy[4] = 96+y+(600-y)*4/5-96;
				yy[5] = 600+192-96;

				for(i=0;i<5;i++)
				{
					for(j=0;j<5;j++)
					{
						DSP_SetGraph( i*5+j, 1, 0, ON, CHK_NO );
						DSP_SetGraphPosPoly( i*5+j,
							xx[j]+xxx[ i   *6+j],   yy[i  ]+yyy[ i   *6+j],   xx[j+1]+xxx[ i   *6+j+1], yy[i  ]+yyy[ i   *6+j+1],
							xx[j]+xxx[(i+1)*6+j],   yy[i+1]+yyy[(i+1)*6+j],   xx[j+1]+xxx[(i+1)*6+j+1], yy[i+1]+yyy[(i+1)*6+j+1],
							xx[j]+128, yy[i]+96,   xx[j+1]+128, yy[i]+96,   xx[j]+128, yy[i+1]+96,   xx[j+1]+128, yy[i+1]+96 );
					}
				}
			}
			break;
		case 2:
			for( i=0 ; i<RippleGno ; i++ )
				DSP_ResetGraph( i );

			SetRipple( (DrawCount)%256 );
			DRW_RenewRippleTable(1);

			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraphPos( 0, 0,0, 0,0, 800, 600 );
			DSP_SetGraphParam( 0, DRW_RP2( 255-LIM(r/10%512*4/3,0,255), r/20%256 ) );
			DSP_SetGraphFade( 0, 128-LIM(DrawCount%256-128,0,128) );
			break;
		case 3:
			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );
			DSP_SetGraphBSet2( 1, 2, 3, lr*lr/255 );
			break;
		case 4:
			DSP_SetTextStr( 0, "モザイクワイプ" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraphDisp( 1, OFF );
			DSP_SetGraphParam( 0, DRW_MOZ(count*2) );

			ChangeSetpCounter( 1, 5, 64 );
			break;
		case 5:
			DSP_SetGraph( 0, 1, 0, ON, CHK_NO );
			DSP_SetGraphDisp( 1, OFF );
			DSP_SetGraphParam( 0, DRW_MOZ(128-count*2) );

			ChangeSetpCounter( 1, 6, 64 );
			break;
		case 6:
			DSP_SetTextStr( 0, "モザイクフェード" );

			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );
			DSP_SetGraphParam( 0, DRW_BLD(count*4) );
			DSP_SetGraphParam( 1, DRW_MOZ(count*4) );

			ChangeSetpCounter( 1, 7, 64 );
			break;
		case 7:
			DSP_SetTextStr( 0, "パターンフェード1" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );
			DSP_SetGraphBSet( 1, 2, count*4 );

			ChangeSetpCounter( 1, 8, 64 );
			break;
		case 8:
			DSP_SetTextStr( 0, "パターンフェード2" );

			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );
			DSP_SetGraphBSet( 0, 3, count*4 );

			ChangeSetpCounter( 1, 9, 64 );
			break;
		case 9:
			DSP_SetTextStr( 0, "パターンフェード3" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );
			DSP_SetGraphBSet( 1, 4, count*4 );

			ChangeSetpCounter( 1, 10, 64 );
			break;
		case 10:
			DSP_SetTextStr( 0, "パターンフェード4(放射)" );
			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );
			DSP_SetGraphBSet( 0, 5, count*4 );
			ChangeSetpCounter( 1, 11, 64 );
			break;
		case 11:
			DSP_SetTextStr( 0, "パターンフェード5(文字)" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );
			DSP_SetGraphBSet( 1, 6, count*4 );
			ChangeSetpCounter( 1, 12, 64 );
			break;

		case 12:
			DSP_SetTextStr( 0, "スクロールワイプ(横)" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );

			r = count*count/64;
			x = 800*r/64;
			DSP_SetGraphMove( 0, x-800, 0 );
			DSP_SetGraphMove( 1, x, 0 );

			DSP_SetGraphParam( 0, DRW_BLD(32+r*2) );
			DSP_SetGraphParam( 1, DRW_BLD(32) );

			ChangeSetpCounter( 1, 13, 64 );
			break;

		case 13:
			DSP_SetTextStr( 0, "スクロールワイプ(縦)" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );

			r = count*count/64;
			y = -600*r/64;
			DSP_SetGraphMove( 0, 0, y );
			DSP_SetGraphPosRect( 1, 0, y+600, 800, 600 );

			DSP_SetGraphParam( 0, DRW_BLD(32) );
			DSP_SetGraphParam( 1, DRW_BLD(32+r*2) );

			ChangeSetpCounter( 1, 14, 64 );
			break;

		case 14:
			DSP_SetTextStr( 0, "ズームワイプ1" );

			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );

			r = 64-(64-count)*(64-count)/64;
			DSP_SetGraphZoom2( 1, 400, 300, r*4 );
			DSP_SetGraphParam( 0, DRW_BLD(r*4) );

			ChangeSetpCounter( 1, 15, 64 );
			break;
		case 15:
			DSP_SetTextStr( 0, "ズームワイプ2" );

			DSP_SetGraphDisp( 0, OFF );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );

			r = 64-count*count/64;
			DSP_SetGraphZoom2( 1, 400, 300, r*4 );
			DSP_SetGraphParam( 1, DRW_BLD(16+128-r*2) );

			ChangeSetpCounter( 1, 16, 64 );
			break;
		case 16:
			DSP_SetTextStr( 0, "ズームワイプ3" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );

			r = 64-count;
			r = r*r/64;
			DSP_SetGraphPos( 1, 0, 0, 0,0, 800, 600 );
			DSP_SetGraphZoom2( 1, 400, 300, r*4-256 );
			DSP_SetGraphParam( 1, DRW_BLD(r*4) );

			ChangeSetpCounter( 1, 17, 64 );
			break;
		case 17:
			DSP_SetTextStr( 0, "ズームワイプ4" );

			DSP_SetGraphDisp( 0, OFF );
			DSP_SetGraph( 1, 1, 1, ON, CHK_NO );

			r = 64-count;
			r = 64-r*r/64;
			DSP_SetGraphPos( 1, 0, 0, 0,0, 800, 600 );
			DSP_SetGraphZoom2( 1, 400, 300, r*4-256 );
			DSP_SetGraphParam( 1, DRW_BLD(r*2) );

			ChangeSetpCounter( 1, 18, 64 );
			break;
		case 18:
			DSP_SetTextStr( 0, "ノイズワイプ" );

			DSP_SetGraph( 0, 0, 1, ON, CHK_NO );
			DSP_SetGraph( 1, 1, 0, ON, CHK_NO );

			r = count*2;
			DSP_SetGraphParam( 0, DRW_NIS(r) );

			ChangeSetpCounter( 1, 19, 128 );
			break;
		case 19:
			DSP_SetTextStr( 0, "加算パターンホワイトフェード" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 5, 1, ON, CHK_NO );

			r = STD_LimitLoop( count, 64 )*4;
			DSP_SetGraphParam( 1, DRW_ADD );
			DSP_SetGraphFade( 1, r );

			ChangeSetpCounter( 1, 20, 128 );
			break;
		case 20:
			DSP_SetTextStr( 0, "減算パターンフェード" );

			DSP_SetGraph( 0, 0, 0, ON, CHK_NO );
			DSP_SetGraph( 1, 5, 1, ON, CHK_NO );

			r = STD_LimitLoop( count, 64 )*4;
			DSP_SetGraphParam( 1, DRW_SUB );
			DSP_SetGraphFade( 1, r );

			ChangeSetpCounter( 1, 0, 128 );
			break;
	}
	AVG_ControlWeather();
	return ret;
}
Example #6
0
void SetRipple( int go )
{
	short	*depth = DRW_GetRippleTableAddr();
	int		x,y;
	static int	wsctr = 0;

	if(wsctr<100)
	{
		if(wsctr%10==0)
		{
			for( y = -10; y<=10; y++ )
			{
				if( (DRW_GetRippleTableNwf()+y+150)%2 )
				{
					for( x = -10; x<=10; x++ )
					{
						if( sqrt( (double)(x*x+y*y) ) <80 )
						{

						}
					}
				}
			}
		}
	}

	if(wsctr%256==8)
	{
		for( y = -10; y<=10; y++ )
		{
			for( x = -10; x<=10; x++ )
			{
				if( sqrt( (double)(x*x+y*y) ) < 4 )
				{
					*(depth+(100+y)*400+150+x) = -LIM(256-(x*x+y*y),0,256);
				}
			}
		}
	}
	if(wsctr%256==16)
	{
		for( y = -10; y<=10; y++ )
		{
			for( x = -10; x<=10; x++ )
			{
				if( sqrt( (double)(x*x+y*y) ) < 6 )
				{
					*(depth+(160+y)*400+300+x) = -LIM(256-(x*x+y*y),0,256);
				}
			}
		}
	}
	if(wsctr%256==20)
	{
		for( y = -32; y<=32; y++ )
		{
			for( x = -32; x<=32; x++ )
			{


			}
		}
	}

	wsctr++;
}
void CLASS nikon_compressed_load_raw() // used when tag 0x103 of subifd1 == 0x8799 (34713)
{
  static const uchar nikon_tree[][32] = {
    { 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,	/* 12-bit lossy */
      5,4,3,6,2,7,1,0,8,9,11,10,12 },
    { 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,	/* 12-bit lossy after split */
      0x39,0x5a,0x38,0x27,0x16,5,4,3,2,1,0,11,12,12 },
    { 0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,  /* 12-bit lossless */
      5,4,6,3,7,2,8,1,9,0,10,11,12 },
    { 0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,	/* 14-bit lossy */
      5,6,4,7,8,3,9,2,1,0,10,11,12,13,14 },
    { 0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,	/* 14-bit lossy after split */
      8,0x5c,0x4b,0x3a,0x29,7,6,5,4,3,2,1,0,13,14 },
    { 0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,	/* 14-bit lossless */
      7,6,8,5,9,4,10,3,11,12,2,0,1,13,14 } };
  struct decode *dindex;
  ushort ver0, ver1, vpred[2][2], hpred[2], csize;
  int i, min, max, step=0, huff=0, split=0, row, col, len, shl, diff;

  fseek (ifp, meta_offset, SEEK_SET); // linearization curve (0x96)
  ver0 = fgetc(ifp);
  ver1 = fgetc(ifp);
  // ver0=0x44, ver1=0x20 for 12bits and 14bits lossy (d300)
  // 0x46, 0x30 for 12bits and 14 lossless (d300 and d700)
  printf("meta_offset=%d, tiff_bps=%d, ver0=%d, ver1=%d\n", meta_offset, tiff_bps, ver0, ver1);
  if (ver0 == 0x49 || ver1 == 0x58) // never seen. firmware update or nikon raw software?
    fseek (ifp, 2110, SEEK_CUR);
  if (ver0 == 0x46) huff = 2; // lossless (implicitly 12bits). have seen a d3x nef with ver0=0x46 and ver1=0x30 (exif 0x131="ver1.00")
  // with d300 lossless : ver0=0x46, ver1=0x30. d700/14b/lossless : ver0=0x46, ver1=0x30

  if (tiff_bps == 14) huff += 3; // 14bits lossly (if huff was ==0) or 14bits lossless if ver0==0x46
  read_shorts (vpred[0], 4); // vertical predictor values ?
  
  max = 1 << tiff_bps & 0x7fff;
  if ((csize = get2()) > 1) // curve size. 567 with D100/12bits/lossy. 32 with d3x/12bits/lossless. 
    step = max / (csize-1);
  if (ver0 == 0x44 && ver1 == 0x20 && step > 0) { // lossy (d300, d90 and d5000). 
  //tag 0x93 = 2. stored curve needs interpolation
    for (i=0; i < csize; i++) // read curve
      curve[i*step] = get2();
      // curve interpolation
    for (i=0; i < max; i++)
      curve[i] = ( curve[i-i%step]*(step-i%step) +
		   curve[i-i%step+step]*(i%step) ) / step;
		   
    fseek (ifp, meta_offset+562, SEEK_SET); // csize seems 257 for recent models (0x44/0x20) like d90 and d300
    // type 2 has the split value and uses a second huffman table
    split = get2();
  } else if (ver0 != 0x46 && csize <= 0x4001) // if not lossless. 
  // with D100/D200/D2X/D40/D80/D60 12bits/lossy : ver0==0x44 && ver1==0x10
    read_shorts (curve, max=csize);
  printf("csize=%d, step=%d, split=%d, huff=%d\n", csize, step, split, huff);

/*
0x96 (linearization table) tag format 

offset how_many   type   name
----+-----------+------+---------------------------------------------------------------------------------------------
0    1           byte   version0
1    1           byte   version1
                         ver0=0x44, ver1=0x20 for 12bits and 14bits lossy (d300)
                         0x44, 0x20 : lossy (d300, d90 and d5000)
                         0x46, 0x30 for 12bits and 14 lossless (d300 and d700)
                         0x46, 0x30 : d3x/12b/lossless
                         0x46, 0x30. with d300 lossless. and d700/14b/lossless
                         0x44, 0x10 : with D100/D200/D2X/D40/D80/D60 12bits/lossy 
                         tag 0x93 = 3 for lossless (0x46/0x30).
                         tag 0x93 = 4 for lossy type 2 (0x44/0x20) 
                         tag 0x93 = 1 for lossy type 1 (0x44/0x10)
2    4           shorts vpred[2][2] (when ver0 == 0x49 || ver1 == 0x58, fseek (ifp, 2110, SEEK_CUR) before)
0x0a 1           short  curve_size. 
                         32 with d3x/12bits/lossless, d300/12bits/lossless
                         34 with 14bits/lossless (d300 and d700)
                         257 with d300/12+14b/lossy.  
                         257 with 12b/lossy for d90
                         567 with D100/12bits/lossy. 
                         683 with 12b/lossy for d200,d2x,d40x,d40,d80,d60
0x0c curve_size  shorts curve[]
                         for lossy type 2, if curve_size == 257 (d90 and d300), end of curve table is 1+257*2 = 526
562  1           short  split_value (for 0x44/0x20 only (lossy type 2), d90 and d300) 
                         
 */

  while (curve[max-2] == curve[max-1]) max--;
  init_decoder();
  make_decoder (nikon_tree[huff], 0);
  fseek (ifp, data_offset, SEEK_SET);
  getbits(-1);
  for (min=row=0; row < height; row++) {
      if (split && row == split) {
      // for lossy type 2 (0x44/0x20)
      init_decoder();
      make_decoder (nikon_tree[huff+1], 0);
      max += (min = 16) << 1;
    }
    for (col=0; col < raw_width; col++) {
      for (dindex=first_decode; dindex->branch[0]; )
	      dindex = dindex->branch[getbits(1)]; // read 12 or 14bits value bit per bit and walking through the huffman tree to find the leaf
      len = dindex->leaf & 15; // length = 4 left most bits
      shl = dindex->leaf >> 4; // shift length? = 8 or 10bits
      diff = ((getbits(len-shl) << 1) + 1) << shl >> 1; // read diff value
      if ((diff & (1 << (len-1))) == 0) // left most bit is certainly the sign 
	      diff -= (1 << len) - !shl;
      if (col < 2) 
        hpred[col] = vpred[row & 1][col] += diff; // vpred used for columns 0 and 1
      else	   
        hpred[col & 1] += diff;
      // very close to jpeg lossless decompression (ljpeg_diff and ljpeg_row), except for the shl value...
      if ((ushort)(hpred[col & 1] + min) >= max) derror();
      if ((unsigned) (col-left_margin) < width)
	      BAYER(row,col-left_margin) = curve[LIM((short)hpred[col & 1],0,0x3fff)];
    }
  }
}
Example #8
0
int TXT_DrawTextEx( void *dest, int draw_mode2, int sx, int sy, int w, int h, int pixh_w, int pich_h, int *px2, int *py2, RECT *clip,
					int font, char *str, int color, int text_cnt, int step_cnt, int r, int g, int b, int alph, int kage, int cnt_flag, char *normal_str, int kaigyou_musi )
{

	int		digit;
	int		px = sx, py = sy;
	int		cnt = 0;
	int		cnt2 = 0;
	int		kflag = 0;
	int		cno = color;
	int		fno = font&0xff, fno2 = font&0xff;
	int		tag_cnt = 0;
	int		tag_param[16];
	int		tag_back[16];
	int		draw_flag=0;
	int		accent_flag=0;
	char	rubi_str[64];
	RGB32	rgb;
	int		rfno = 16;
	int		alph2=alph;
	int		wait=0;
	int		speed=10;
	int		step=0;
	int		end_flag=0;
	int		amari=0;
	int		kaig=0;
	int		px_bak=0;
	int		hankaku_err=0;
	
	static int hankaku_err_flag=0;
	if(font&0xff00 && hankaku_err_flag==0){
		hankaku_err_flag=1;
		hankaku_err=1;
	}

	font = font&0xff;
	enum{
		TAG_DIGIT,
		TAG_COLOR,
		TAG_FONT,
		TAG_RUBI,
		TAG_ACCENT,
		TAG_SPEED,
		TAG_WAIT,
	};
	TXT_GetMsgSpeed( -1 );
	if(str==NULL){
		return 0;
	}

	
	while( cnt2 < text_cnt || text_cnt==-1 || ( cnt2==text_cnt && !amari)  ) {	
		amari = TXT_GetMsgSpeed(-2);
		if(wait){
			wait--;

			cnt2++;
			continue;
		}
		if(alph==-1){
			if(text_cnt==-1){	alph2 = 256;							}
			else			{	alph2 = LIM(text_cnt-cnt2, 0, 16)*16;	}
			if(step<step_cnt){ alph2 = 256; }
		}
		
		switch( str[cnt] ){
			case '\0':		
				if( tag_cnt ){
					DebugBox( NULL, "�^�O���J�����܂܂ɂȂ��Ă��܂��B�K���‚��Ă�������" );
				}
				end_flag=1;
				break;
			case '\n':
				if(!kaig){
					px_bak=px;
					px = sx;
					py += fno2+pich_h;
					fno2 = fno;
					if(normal_str) { *normal_str = '\n'; normal_str++; }
				}
				kaig=0;
				break;
			case '^':	
				draw_flag = 1;
				str[cnt] = ' ';

				break;
			case '~':	
				str[cnt] = ',';
				draw_flag = 1;

				break;
			case '\\':
				cnt++;
				switch( str[cnt] ){
					case 'n':			
						if(!kaig){
							px_bak=px;
							px = sx;
							py += fno2+pich_h;
							fno2 = fno;

							if(normal_str) { *normal_str = '\n'; normal_str++; }
						}
						kaig=0;
						break;
					case 'k':			
						if(step>=step_cnt && step_cnt!=-1 ){
							end_flag=1;
						}
						step++;
						break;
					case '^':	case '~':
					case '<':	case '>':
					case '|':	case '\\':	
						draw_flag = 1;
						break;
				}
				break;
			case '<':		
				cnt++;
				if( tag_cnt >= 15 ){
					DebugBox( NULL, "�^�O���J���߂��ł��B�l�`�w �P�T" );
					break;
				}
				switch( str[cnt] ){
					case 'd':	case 'D':	
						tag_param[tag_cnt] = TAG_DIGIT;
						tag_back[tag_cnt]  = 0;
						tag_cnt++;

						cnt++;
						if( GetDigit( str, &cnt, &digit ) ){
						}
						break;
					case 'c':	case 'C':	
						tag_param[tag_cnt] = TAG_COLOR;
						tag_back[tag_cnt]  = cno;
						tag_cnt++;

						cnt++;
						if( GetDigit( str, &cnt, &digit ) ){
							cno = digit;
						}
						break;
					case 'f':	case 'F':	
						tag_param[tag_cnt] = TAG_FONT;
						tag_back[tag_cnt]  = fno;
						tag_cnt++;

						cnt++;
						if( GetDigit( str, &cnt, &digit ) ){
							fno = digit;
							fno2 = max(fno,fno2);
						}
						break;
					case 'r':	case 'R':	
						tag_param[tag_cnt] = TAG_RUBI;
						tag_back[tag_cnt]  = px;
						tag_cnt++;
						break;
					case 'a':	case 'A':	
						tag_param[tag_cnt] = TAG_ACCENT;
						tag_cnt++;
						accent_flag = 1;
						break;
					case 's':	case 'S':	
						tag_param[tag_cnt] = TAG_SPEED;
						tag_back[tag_cnt]  = speed;
						tag_cnt++;

						cnt++;
						if( GetDigit( str, &cnt, &digit ) ){
							switch(digit){
								case 0:	speed = 100;break;
								case 1:	speed = 80;	break;
								case 2:	speed = 60;	break;
								case 3:	speed = 40;	break;
								case 4:	speed = 20;	break;
								case 5:	speed = 10;	break;
								case 6:	speed = 6;	break;
								case 7:	speed = 4;	break;
								case 8:	speed = 2;	break;
								case 9:	speed = 1;	break;
								case 10:speed = 0;	break;
							}
						}
						break;
					case 'w':	case 'W':	
						tag_param[tag_cnt] = TAG_WAIT;
						tag_back[tag_cnt]  = 0;
						tag_cnt++;

						cnt++;
						if( GetDigit( str, &cnt, &digit ) ){
							wait = digit*2;
						}
						break;
				}
				break;
			case '|':		
				cnt++;
				switch(tag_param[tag_cnt-1]){
					case TAG_RUBI:	
						{
							int		i=0,rx,pw=0;
							while(str[cnt]!='>'){
								rubi_str[i++] = str[cnt++];
							}
							rubi_str[i] = '\0';
							rgb = BMP_ChangeBright_Full( FCT[cno], r, g, b );
							
							rx = ((px-tag_back[tag_cnt-1]) - i*rfno/2)/2;
							if(rx<=0){
								pw=0;
							}else{
								if( (0x21 <= rubi_str[0] && rubi_str[0] <= 0x7e) || (0xa1 <= rubi_str[0] && rubi_str[0] <= 0xdf) ){
									pw = rx*2/(i);
								}else{
									pw = rx*2/(i/2);
								}
								rx = pw/2;
							}

							rx = tag_back[tag_cnt-1]+rx;
							if(!cnt_flag) FNT_DrawText( dest, draw_mode2, rx, py-rfno-1,pw,0, rubi_str, rfno, clip, rgb.r, rgb.g, rgb.b, alph2, (kage)?kage-1:0 );
						}
						cnt--;
						break;
				}
				break;

			case '>':		
				if( tag_cnt <= 0 ){
					DebugBox( NULL, "�‚��^�O( > )�̐����A�J��������葽���Ȃ��Ă��܂�" );
					break;
				}
				tag_cnt--;
				if(!TH2_Flag){
					switch( tag_param[tag_cnt] ){
						case TAG_DIGIT:									break;
						case TAG_COLOR:		cno = tag_back[tag_cnt];	break;
						case TAG_FONT:
							fno = tag_back[tag_cnt];
							if(px==sx){
								fno2 = fno;
							}else{
								fno2 = max(fno,fno2);
							}
							break;
						case TAG_RUBI:									break;
						case TAG_ACCENT:	accent_flag = 0;			break;
						case TAG_SPEED:		speed = tag_back[tag_cnt];	break;
						case TAG_WAIT:									break;
					}
				}
				break;
			default:	
				draw_flag = 1;
				break;
		}
		if(draw_flag){
			draw_flag = 0;
			rgb = BMP_ChangeBright_Full( FCT[cno], r, g, b );
			if( (0x00<=str[cnt] && str[cnt]<0x80) || (0xa0<=str[cnt] && str[cnt]<0xe0) ) {
				
				if(normal_str) { *normal_str = str[cnt]; normal_str++; }
				if(!cnt_flag) FNT_DrawChar( dest, draw_mode2, px, py, str[cnt], fno, clip, rgb.r, rgb.g, rgb.b, alph2, kage, 1 );
				cnt2 += TXT_GetMsgSpeed( speed );

				if(accent_flag){
					if(!cnt_flag) FNT_DrawChar( dest, draw_mode2, px+(fno-rfno/2)/2, py-rfno+1, '�', rfno, clip, rgb.r, rgb.g, rgb.b, alph2, (kage)?kage-1:0, 1 );
				}
				
				px += fno/2+pixh_w;
				kaig=0;
				if(hankaku_err){
					DebugBox( NULL, "ToHert2�ł͔��p������͎g�p�ł��܂���I" );
				}
			}else{	
				
				if(normal_str) { *(WORD*)normal_str = *(WORD*)&str[cnt]; normal_str+=2; }
				if(!cnt_flag) FNT_DrawChar( dest, draw_mode2, px, py, *(WORD*)&str[cnt], fno, clip, rgb.r, rgb.g, rgb.b, alph2, kage, 0 );
				cnt++;
				cnt2 += TXT_GetMsgSpeed( speed );

				if(accent_flag){
					if(!cnt_flag) FNT_DrawChar( dest, draw_mode2, px+(fno-rfno/2)/2, py-rfno+1, '�', rfno, clip, rgb.r, rgb.g, rgb.b, alph2,  (kage)?kage-1:0, 1 );
				}
				
				px += fno+pixh_w;
				kaig=0;
			}
		}
		if(end_flag)break;
		cnt++;

		
		if( px-sx >= w*font-fno+1 ){
			if( tag_param[tag_cnt-1]!=TAG_RUBI ){
				if( kflag==1 ){
					if( strncmp( &str[ cnt ], "�@", 2 ) )
					{
						kflag = 0;
						px_bak = px;
						px = sx;
						py += fno2+pich_h;
						fno2 = fno;
						kaig=1;
					}
				}else{
					if(
						strncmp( &str[ cnt ], "�B", 2 ) && strncmp( &str[ cnt ], "�A", 2 ) &&
						strncmp( &str[ cnt ], "�C", 2 ) && strncmp( &str[ cnt ], "�D", 2 ) &&
						strncmp( &str[ cnt ], "�E", 2 ) && strncmp( &str[ cnt ], "�c", 2 ) &&
						strncmp( &str[ cnt ], "�[", 2 ) && strncmp( &str[ cnt ], "�[", 2 ) &&
						strncmp( &str[ cnt ], "�F", 2 ) && strncmp( &str[ cnt ], "�G", 2 ) &&
						strncmp( &str[ cnt ], "�H", 2 ) && strncmp( &str[ cnt ], "�I", 2 ) &&
						strncmp( &str[ cnt ], "�n", 2 ) && strncmp( &str[ cnt ], "�h", 2 ) &&
						strncmp( &str[ cnt ], "�@", 2 ) && strncmp( &str[ cnt ], "�j", 2 ) &&
						strncmp( &str[ cnt ], "�v", 2 ) && strncmp( &str[ cnt ], "�x", 2 ) &&

						strncmp( &str[ cnt ], "�D", 2 ) && strncmp( &str[ cnt ], "�C", 2 ) &&
						strncmp( &str[ cnt ], "�B", 2 ) && strncmp( &str[ cnt ], "�A", 2 ) &&
						strncmp( &str[ cnt ], "�F", 2 ) && strncmp( &str[ cnt ], "�F", 2 ) &&
						strncmp( &str[ cnt ], "�G", 2 ) && strncmp( &str[ cnt ], "�E", 2 ) && strncmp( &str[ cnt ], "�@", 2 ) )
					{
						px_bak = px;
						px = sx;
						py += fno2+pich_h;
						fno2 = fno;
						kaig=1;
					}else{
						kflag=1;
					}
				}
			}
		}
		if( py-sy >= h*(font+pich_h)-(fno+pich_h)+1 ){
			static int err=0;
			if( py-sy==h*(font+pich_h) && px==sx ){
			}else{
				if(err==0){
					err=1;

				}
				break;
			}
		}
	}
	if(px2){
		if(kaigyou_musi){
			*px2=px;
			if(py2) *py2 = py;
		}else{
			if(px==sx && py!=sy && (px_bak-sx <= w*font) ){
				*px2=px_bak;
				if(py2) *py2 = py- (fno2+pich_h);
			}else{
				*px2=px;
				if(py2) *py2 = py;
			}
		}
	}else{
		if(py2) *py2 = py;
	}
	
	return (cnt_flag) ? cnt2 : (px==sx)? py-sy : py-sy+fno;
}
Example #9
0
int D3DM_InitDevices( HWND hwnd, int w, int h, int full, HMENU menu )
{
	char	buf[256];
	int		i,j;
		LPDIRECTDRAW7 pDD = NULL;	
		HRESULT hr;
		if( FAILED( hr = DirectDrawCreateEx( NULL, (VOID**)&pDD, IID_IDirectDraw7, NULL ) ) )
			return DDENUMRET_CANCEL;

		D3DCapsStruct.m_ddCaps.dwSize = sizeof(DDCAPS);
		pDD->GetCaps( &D3DCapsStruct.m_ddCaps, NULL );
		if(pDD) {
			pDD->Release();
			pDD = NULL;
		}
	ZeroMemory( d3dTexture, sizeof(D3DD_TEXTURE)*D3DD_MAX_TEXTURE_AMOUNT );
	ZeroMemory( d3dText, sizeof(D3DD_TEXT)*D3DD_MAX_TEXT_AMOUNT );
	ZeroMemory( d3dDisp, sizeof(D3DD_DISP)*D3DD_MAX_DISP_AMOUNT );


	
	pD3D = Direct3DCreate8(D3D_SDK_VERSION);
	if(pD3D == NULL){
		MessageBox(NULL,"Direct3Dオブジェクトの生成に失敗しました。[DirectX8.1が入っていない?]","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}

	
	if( FAILED(pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCapsStruct.m_d3dCaps)) ){
		MessageBox(NULL,"デバイス能力の取得に失敗しました","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}
	
	EnumAdapters(D3DADAPTER_DEFAULT);

	
	if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureWidth < D3DD_TEXTURE_CONTROL_SIZE ){
		DebugBox( NULL, "このビデオカードは、幅 %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE);
		return FALSE;
	}else if( (int)D3DCapsStruct.m_d3dCaps.MaxTextureHeight < D3DD_TEXTURE_CONTROL_SIZE ){
		DebugBox( NULL, "このビデオカードは、高さ %d pixel 以上のサイズのテクスチャを生成できません。[%s]", D3DD_TEXTURE_CONTROL_SIZE );
		return FALSE;
	}

	if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_ALPHAGOURAUDBLEND) ){
		MessageBox(NULL,"このビデオデバイスはグーロブレンディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
	}
	if( !(D3DCapsStruct.m_d3dCaps.ShadeCaps&D3DPSHADECAPS_COLORGOURAUDRGB) ){
		MessageBox(NULL,"このビデオデバイスはグーロシェーディングに対応していません。\nゲームの画像が乱れることがあります","警告", MB_OK | MB_ICONSTOP);
	}

	if( D3DCapsStruct.m_d3dCaps.TextureCaps&D3DPTEXTURECAPS_SQUAREONLY ){
		DebugBox( NULL, "このビデオカードは長方形テクスチャを生成できません。[デバッグ用ダイアログ]" );
	}

	
	if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){	
		MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP);
		return FALSE;
	}
	D3DCapsStruct.m_WindowDisplayMode = D3DCapsStruct.m_NowDisplayMode;
	D3DMain.m_DrawHwnd = hwnd;
	D3DMain.m_MenuHwnd = menu;
	if( GetSystemMetrics(SM_CXFULLSCREEN)<=800 || GetSystemMetrics(SM_CYFULLSCREEN)<=600){
		D3DMain.m_FullScreenOnly = TRUE;
		D3DMain.m_WindowMode = FALSE;
	}else{
		D3DMain.m_FullScreenOnly = FALSE;
		D3DMain.m_WindowMode = !full;
	}


	ZeroMemory(&d3dppApp,sizeof(d3dppApp));
	


	WinWidth  = w;
	WinHeight = h;



	d3dppApp.SwapEffect = D3DSWAPEFFECT_COPY;

	d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format;
	d3dppApp.BackBufferCount = 1;
	d3dppApp.BackBufferWidth  = WinWidth;
	d3dppApp.BackBufferHeight = WinHeight;





	d3dppApp.Windowed = TRUE;							
	d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

	
	HRESULT	ret;
	ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
	if( FAILED(ret) ){	
		ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
		if( FAILED(ret) ){	
			D3DMain.m_FullScreenOnly = TRUE;
		}
	}
	if(D3DMain.m_FullScreenOnly==TRUE){
		RELEASE_3D(pD3DDevice);

		D3DMain.m_WindowMode = FALSE;
		ZeroMemory(&d3dppApp,sizeof(d3dppApp));
		for(i=0;i<D3DCapsStruct.m_DisplayModeNum;i++){
			if( D3DCapsStruct.m_DisplayMode[i].Width  == 800 && D3DCapsStruct.m_DisplayMode[i].Height == 600 ){
				switch( D3DCapsStruct.m_DisplayMode[i].Format ){
					case D3DFMT_R5G6B5:		case D3DFMT_X1R5G5B5:
					case D3DFMT_A1R5G5B5:	case D3DFMT_A4R4G4B4:
					case D3DFMT_X4R4G4B4:
						D3DCapsStruct.m_FullModeNum=i;

						d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
						d3dppApp.Windowed = D3DMain.m_WindowMode;		
						d3dppApp.SwapEffect = FULL_FLIP;		
						d3dppApp.BackBufferFormat = D3DCapsStruct.m_DisplayMode[i].Format;	
						d3dppApp.BackBufferCount = 1;
						d3dppApp.BackBufferWidth  = WinWidth;
						d3dppApp.BackBufferHeight = WinHeight;



						break;
				}
			}
			if(d3dppApp.SwapEffect) break;
		}
		if(!full){
			wsprintf( buf, "このビデオカードの現在のモードではゲームを実行できません。フルスクリーン化しますか?\n[%d]", D3DCapsStruct.m_DisplayMode[i].RefreshRate );
			if( MessageBox( NULL, buf, "問い合わせ", MB_YESNO )==IDNO ){
				RELEASE_3D(pD3D);
				return FALSE;
			}
		}

		ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
		if( FAILED(ret) ){	
			ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
			if( FAILED(ret) ){	
				switch(ret){
				default:
				case D3DERR_OUTOFVIDEOMEMORY:
					DebugBox( NULL, "Direct3D が処理を行うのに十分なディスプレイ メモリがありません。" );
					RELEASE_3D(pD3D);
					return FALSE;
				case D3DERR_INVALIDCALL:
					DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_INVALIDCALL]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" );
					RELEASE_3D(pD3D);
					return FALSE;
				case D3DERR_NOTAVAILABLE:
					DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_NOTAVAILABLE]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" );
					RELEASE_3D(pD3D);
					return FALSE;
				}
			}
		}
	}else{
		if(D3DMain.m_WindowMode){	
		}else{
			RELEASE_3D(pD3DDevice);
			ZeroMemory(&d3dppApp,sizeof(d3dppApp));

	
			d3dppApp.SwapEffect = FULL_FLIP;
	
	
			d3dppApp.BackBufferCount = 1;
			d3dppApp.BackBufferWidth  = WinWidth;
			d3dppApp.BackBufferHeight = WinHeight;

		
			d3dppApp.Windowed = FALSE;							
			d3dppApp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;


			if(DrawSetting.full_16bit){
				d3dppApp.BackBufferFormat=D3DFMT_UNKNOWN;
				for(i=0;i<D3DCapsStruct.m_DisplayModeNum;i++){
					if( D3DCapsStruct.m_DisplayMode[i].Width  == 800 && D3DCapsStruct.m_DisplayMode[i].Height == 600 ){
						switch( D3DCapsStruct.m_DisplayMode[i].Format ){
							case D3DFMT_R5G6B5:		case D3DFMT_X1R5G5B5:
							case D3DFMT_A1R5G5B5:	case D3DFMT_A4R4G4B4:
							case D3DFMT_X4R4G4B4:
								D3DCapsStruct.m_FullModeNum=i;
								d3dppApp.BackBufferFormat = D3DCapsStruct.m_DisplayMode[i].Format;	
								break;
						}
					}
					if(d3dppApp.BackBufferFormat!=D3DFMT_UNKNOWN) break;
				}
			}else{
				d3dppApp.BackBufferFormat = D3DCapsStruct.m_NowDisplayMode.Format;
			}

			ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
			if( FAILED(ret) ){	
				ret = pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dppApp,&pD3DDevice);
				if( FAILED(ret) ){	
					switch(ret){
					default:
					case D3DERR_OUTOFVIDEOMEMORY:
						DebugBox( NULL, "Direct3D が処理を行うのに十分なディスプレイ メモリがありません。" );
						RELEASE_3D(pD3D);
						return FALSE;
					case D3DERR_INVALIDCALL:
						DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_INVALIDCALL]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" );
						RELEASE_3D(pD3D);
						return FALSE;
					case D3DERR_NOTAVAILABLE:
						DebugBox( NULL, "Direct3Dの初期化に失敗しました[D3DERR_NOTAVAILABLE]\nこのグラフィックカードは必要な機能をサポートしていないか、\nあるいはDirectX8に対応したドライバが入っていません。" );
						RELEASE_3D(pD3D);
						return FALSE;
					}
				}
			}
		}
	}



	if( FAILED(pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&D3DCapsStruct.m_NowDisplayMode)) ){	
		MessageBox(NULL,"ディスプレイモードの取得に失敗しました。[なにゆえ?]","致命的なエラー", MB_OK | MB_ICONSTOP);
		RELEASE_3D(pD3D);
		return FALSE;
	}
	D3DCapsStruct.m_ttCaps.m_R8G8B8		= IsTextureFormatOk( D3DFMT_R8G8B8,   D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_X8R8G8B8	= IsTextureFormatOk( D3DFMT_X8R8G8B8, D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_A8R8G8B8	= IsTextureFormatOk( D3DFMT_A8R8G8B8, D3DCapsStruct.m_NowDisplayMode.Format);

	D3DCapsStruct.m_ttCaps.m_R5G6B5		= IsTextureFormatOk( D3DFMT_R5G6B5,   D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_X1R5G5B5	= IsTextureFormatOk( D3DFMT_X1R5G5B5, D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_A1R5G5B5	= IsTextureFormatOk( D3DFMT_A1R5G5B5, D3DCapsStruct.m_NowDisplayMode.Format);

	D3DCapsStruct.m_ttCaps.m_X4R4G4B4	= IsTextureFormatOk( D3DFMT_X4R4G4B4, D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_A4R4G4B4	= IsTextureFormatOk( D3DFMT_A4R4G4B4, D3DCapsStruct.m_NowDisplayMode.Format);

	D3DCapsStruct.m_ttCaps.m_A8P8		= IsTextureFormatOk( D3DFMT_A8P8,     D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_P8			= IsTextureFormatOk( D3DFMT_P8,       D3DCapsStruct.m_NowDisplayMode.Format);
	D3DCapsStruct.m_ttCaps.m_A8			= IsTextureFormatOk( D3DFMT_A8,       D3DCapsStruct.m_NowDisplayMode.Format);
	
	D3DD_SetBackBuffer( WinWidth, WinHeight );
	pD3DDevice->Clear(0,NULL,D3DCLEAR_TARGET,D3DCOLOR_ARGB(0,0,0,0),1.0,0);

	if(0){
		char	buf2[512];

		wsprintf( buf, "実行ディスプレイモード[%s]\n", TxFmtMode[ LIM(d3dppApp.BackBufferFormat,0,D3DFMT_D3DD_MAX-1) ] );
		MBS_CPY(buf2,buf);

		MBS_CAT(buf2,"使用可能テクスチャ列挙\n");
		for(i=1;i<D3DFMT_D3DD_MAX-1;i++){
			if( TxFmtMode[i] ){
				j = IsTextureFormatOk( (D3DFORMAT)i, D3DCapsStruct.m_NowDisplayMode.Format);
				if(j){
					wsprintf(buf,"%-15s[%s]\n", TxFmtMode[i], (j==2)?"OK":"OK(NotRenderTarget)" );
					MBS_CAT(buf2,buf);
				}else{
					wsprintf(buf,"%-15s[%s]\n", TxFmtMode[i], "--Not--" );
					MBS_CAT(buf2,buf);
				}
			}
		}

		
		DebugBox(NULL,buf2);



	}

	D3DD_CreateTable();

	return TRUE;
}
Example #10
0
#include <errno.h>
#include <limits.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif

struct limit {
    const char *name;
    int resource;
    int scale;
    int has_limit;
    struct rlimit limit;
} limits[] = {
#define LIM(X, S) { #X, RLIMIT_##X, S, 0 }
    LIM(CORE, 1024),
    LIM(CPU, 60),
    LIM(DATA, 1024),
    LIM(FSIZE, 1024),
#ifdef RLIMIT_MEMLOCK
    LIM(MEMLOCK, 1024),
#endif
    LIM(NOFILE, 1),
#ifdef RLIMIT_NPROC
    LIM(NPROC, 1),
#endif
#ifdef RLIMIT_RSS
    LIM(RSS, 1024),
#endif
    LIM(STACK, 1024),
Example #11
0
void CLASS lmmse_interpolate(int gamma_apply)
{
  ushort (*pix)[4];
  int row, col, c, d, w1, w2, w3, w4, ii, ba, rr1, cc1, rr, cc, pass;
  float h0, h1, h2, h3, h4, hs;
  float p1, p2, p3, p4, p5, p6, p7, p8, p9, temp;
  float Y, v0, mu, vx, vn, xh, vh, xv, vv;
  float (*rix)[6], (*qix)[6];
  float (*glut);
  char  *buffer;
  clock_t t1, t2;
  double dt;
#ifdef DCRAW_VERBOSE
  if (verbose) fprintf(stderr,_("LMMSE interpolation...\n"));
#endif
  t1 = clock();
  // allocate work with boundary
  ba = 10;
  rr1 = height + 2*ba;
  cc1 = width + 2*ba;
  if (gamma_apply)
    buffer = (char *)calloc(rr1*cc1*6*sizeof(float)+65536*sizeof(float),1);
  else
    buffer = (char *)calloc(rr1*cc1*6*sizeof(float),1);
  merror(buffer,"lmmse_interpolate()");
  qix = (float (*)[6])buffer;
  if (gamma_apply) {
    glut = (float *)(buffer + rr1*cc1*24);
    for (ii=0; ii < 65536; ii++) {
      v0 = (float)ii / 65535.0;
      if (v0 <= 0.0031308)
	glut[ii] = v0*12.92;
      else
	glut[ii] = 1.055*pow((double)v0,1./2.4) - 0.055; } }
  // indices
  w1 = cc1;
  w2 = 2*w1;
  w3 = 3*w1;
  w4 = 4*w1;
  // define low pass filter (sigma=2, L=4)
  h0 = 1.0;
  h1 = exp( -1.0/8.0);
  h2 = exp( -4.0/8.0);
  h3 = exp( -9.0/8.0);
  h4 = exp(-16.0/8.0);
  hs = h0 + 2.0*(h1 + h2 + h3 + h4);
  h0 /= hs;
  h1 /= hs;
  h2 /= hs;
  h3 /= hs;
  h4 /= hs;
  // copy CFA values
  for (rr=0; rr < rr1; rr++)
    for (cc=0, row=rr-ba; cc < cc1; cc++) {
      col = cc - ba;
      rix = qix + rr*cc1 + cc;
      if ((row >= 0) & (row < height) & (col >= 0) & (col < width))
	if (gamma_apply)
	  rix[0][4] = glut[image[row*width+col][FC(row,col)]];
	else
	  rix[0][4] = (double)image[row*width+col][FC(row,col)]/65535.0;
      else
	rix[0][4] = 0; }
  // G-R(B)
  for (rr=2; rr < rr1-2; rr++) {
    // G-R(B) at R(B) location
    for (cc=2+(FC(rr,2)&1); cc < cc1-2; cc+=2) {
      rix = qix + rr*cc1 + cc;
      // v0 = 0.25R + 0.25B, Y = 0.25R + 0.5B + 0.25B
      v0 = 0.0625*(rix[-w1-1][4]+rix[-w1+1][4]+rix[w1-1][4]+rix[w1+1][4]) +
	0.25*rix[0][4];
      // horizontal
      rix[0][0] = -0.25*(rix[ -2][4] + rix[ 2][4])
	+ 0.5*(rix[ -1][4] + rix[0][4] + rix[ 1][4]);
      Y = v0 + 0.5*rix[0][0];
      if (rix[0][4] > 1.75*Y)
	rix[0][0] = ULIM(rix[0][0],rix[ -1][4],rix[ 1][4]);
      else
	rix[0][0] = LIM(rix[0][0],0.0,1.0);
      rix[0][0] -= rix[0][4];
      // vertical
      rix[0][1] = -0.25*(rix[-w2][4] + rix[w2][4])
	+ 0.5*(rix[-w1][4] + rix[0][4] + rix[w1][4]);
      Y = v0 + 0.5*rix[0][1];
      if (rix[0][4] > 1.75*Y)
	rix[0][1] = ULIM(rix[0][1],rix[-w1][4],rix[w1][4]);
      else
	rix[0][1] = LIM(rix[0][1],0.0,1.0);
      rix[0][1] -= rix[0][4]; }
    // G-R(B) at G location
    for (cc=2+(FC(rr,3)&1); cc < cc1-2; cc+=2) {
      rix = qix + rr*cc1 + cc;
      rix[0][0] = 0.25*(rix[ -2][4] + rix[ 2][4])
	- 0.5*(rix[ -1][4] + rix[0][4] + rix[ 1][4]);
      rix[0][1] = 0.25*(rix[-w2][4] + rix[w2][4])
	- 0.5*(rix[-w1][4] + rix[0][4] + rix[w1][4]);
      rix[0][0] = LIM(rix[0][0],-1.0,0.0) + rix[0][4];
      rix[0][1] = LIM(rix[0][1],-1.0,0.0) + rix[0][4];
    } }
  // apply low pass filter on differential colors
  for (rr=4; rr < rr1-4; rr++)
    for (cc=4; cc < cc1-4; cc++) {
      rix = qix + rr*cc1 + cc;
      rix[0][2] = h0*rix[0][0] +
	h1*(rix[ -1][0] + rix[ 1][0]) + h2*(rix[ -2][0] + rix[ 2][0]) +
	h3*(rix[ -3][0] + rix[ 3][0]) + h4*(rix[ -4][0] + rix[ 4][0]);
      rix[0][3] = h0*rix[0][1] +
	h1*(rix[-w1][1] + rix[w1][1]) + h2*(rix[-w2][1] + rix[w2][1]) +
	h3*(rix[-w3][1] + rix[w3][1]) + h4*(rix[-w4][1] + rix[w4][1]); }
  // interpolate G-R(B) at R(B)
  for (rr=4; rr < rr1-4; rr++)
    for (cc=4+(FC(rr,4)&1); cc < cc1-4; cc+=2) {
      rix = qix + rr*cc1 + cc;
      // horizontal
      mu = (rix[-4][2] + rix[-3][2] + rix[-2][2] + rix[-1][2] + rix[0][2]+
	    rix[ 1][2] + rix[ 2][2] + rix[ 3][2] + rix[ 4][2]) / 9.0;
      p1 = rix[-4][2] - mu;
      p2 = rix[-3][2] - mu;
      p3 = rix[-2][2] - mu;
      p4 = rix[-1][2] - mu;
      p5 = rix[ 0][2] - mu;
      p6 = rix[ 1][2] - mu;
      p7 = rix[ 2][2] - mu;
      p8 = rix[ 3][2] - mu;
      p9 = rix[ 4][2] - mu;
      vx = 1e-7+p1*p1+p2*p2+p3*p3+p4*p4+p5*p5+p6*p6+p7*p7+p8*p8+p9*p9;
      p1 = rix[-4][0] - rix[-4][2];
      p2 = rix[-3][0] - rix[-3][2];
      p3 = rix[-2][0] - rix[-2][2];
      p4 = rix[-1][0] - rix[-1][2];
      p5 = rix[ 0][0] - rix[ 0][2];
      p6 = rix[ 1][0] - rix[ 1][2];
      p7 = rix[ 2][0] - rix[ 2][2];
      p8 = rix[ 3][0] - rix[ 3][2];
      p9 = rix[ 4][0] - rix[ 4][2];
      vn = 1e-7+p1*p1+p2*p2+p3*p3+p4*p4+p5*p5+p6*p6+p7*p7+p8*p8+p9*p9;
      xh = (rix[0][0]*vx + rix[0][2]*vn)/(vx + vn);
      vh = vx*vn/(vx + vn);
      // vertical
      mu = (rix[-w4][3] + rix[-w3][3] + rix[-w2][3] + rix[-w1][3] + rix[0][3]+
	    rix[ w1][3] + rix[ w2][3] + rix[ w3][3] + rix[ w4][3]) / 9.0;
      p1 = rix[-w4][3] - mu;
      p2 = rix[-w3][3] - mu;
      p3 = rix[-w2][3] - mu;
      p4 = rix[-w1][3] - mu;
      p5 = rix[  0][3] - mu;
      p6 = rix[ w1][3] - mu;
      p7 = rix[ w2][3] - mu;
      p8 = rix[ w3][3] - mu;
      p9 = rix[ w4][3] - mu;
      vx = 1e-7+p1*p1+p2*p2+p3*p3+p4*p4+p5*p5+p6*p6+p7*p7+p8*p8+p9*p9;
      p1 = rix[-w4][1] - rix[-w4][3];
      p2 = rix[-w3][1] - rix[-w3][3];
      p3 = rix[-w2][1] - rix[-w2][3];
      p4 = rix[-w1][1] - rix[-w1][3];
      p5 = rix[  0][1] - rix[  0][3];
      p6 = rix[ w1][1] - rix[ w1][3];
      p7 = rix[ w2][1] - rix[ w2][3];
      p8 = rix[ w3][1] - rix[ w3][3];
      p9 = rix[ w4][1] - rix[ w4][3];
      vn = 1e-7+p1*p1+p2*p2+p3*p3+p4*p4+p5*p5+p6*p6+p7*p7+p8*p8+p9*p9;
      xv = (rix[0][1]*vx + rix[0][3]*vn)/(vx + vn);
      vv = vx*vn/(vx + vn);
      // interpolated G-R(B)
      rix[0][4] = (xh*vv + xv*vh)/(vh + vv); }
  // copy CFA values
  for (rr=0; rr < rr1; rr++)
    for (cc=0, row=rr-ba; cc < cc1; cc++) {
      col=cc-ba;
      rix = qix + rr*cc1 + cc;
      c = FC(rr,cc);
      if ((row >= 0) & (row < height) & (col >= 0) & (col < width))
	if (gamma_apply)
	  rix[0][c] = glut[image[row*width+col][c]];
	else
	  rix[0][c] = (double)image[row*width+col][c]/65535.0;
      else
	rix[0][c] = 0;
      if (c != 1) rix[0][1] = rix[0][c] + rix[0][4]; }
  // bilinear interpolation for R/B
  // interpolate R/B at G location
  for (rr=1; rr < rr1-1; rr++)
    for (cc=1+(FC(rr,2)&1), c=FC(rr,cc+1); cc < cc1-1; cc+=2) {
      rix = qix + rr*cc1 + cc;
      rix[0][c] = rix[0][1]
	+ 0.5*(rix[ -1][c] - rix[ -1][1] + rix[ 1][c] - rix[ 1][1]);
      c = 2 - c;
      rix[0][c] = rix[0][1]
	+ 0.5*(rix[-w1][c] - rix[-w1][1] + rix[w1][c] - rix[w1][1]);
      c = 2 - c; }
  // interpolate R/B at B/R location
  for (rr=1; rr < rr1-1; rr++)
    for (cc=1+(FC(rr,1)&1), c=2-FC(rr,cc); cc < cc1-1; cc+=2) {
      rix = qix + rr*cc1 + cc;
      rix[0][c] = rix[0][1]
	+ 0.25*(rix[-w1][c] - rix[-w1][1] + rix[ -1][c] - rix[ -1][1]+
		rix[  1][c] - rix[  1][1] + rix[ w1][c] - rix[ w1][1]); }
  // median filter
  for (pass=1; pass <= 3; pass++) {
    for (c=0; c < 3; c+=2) {
      // Compute median(R-G) and median(B-G)
      d = c + 3;
      for (ii=0; ii < rr1*cc1; ii++) qix[ii][d] = qix[ii][c] - qix[ii][1];
      // Apply 3x3 median fileter
      for (rr=1; rr < rr1-1; rr++)
	for (cc=1; cc < cc1-1; cc++) {
	  rix = qix + rr*cc1 + cc;
	  // Assign 3x3 differential color values
	  p1 = rix[-w1-1][d]; p2 = rix[-w1][d]; p3 = rix[-w1+1][d];
	  p4 = rix[   -1][d]; p5 = rix[  0][d]; p6 = rix[    1][d];
	  p7 = rix[ w1-1][d]; p8 = rix[ w1][d]; p9 = rix[ w1+1][d];
	  // Sort for median of 9 values
	  PIX_SORT(p2,p3); PIX_SORT(p5,p6); PIX_SORT(p8,p9);
	  PIX_SORT(p1,p2); PIX_SORT(p4,p5); PIX_SORT(p7,p8);
	  PIX_SORT(p2,p3); PIX_SORT(p5,p6); PIX_SORT(p8,p9);
	  PIX_SORT(p1,p4); PIX_SORT(p6,p9); PIX_SORT(p5,p8);
	  PIX_SORT(p4,p7); PIX_SORT(p2,p5); PIX_SORT(p3,p6);
	  PIX_SORT(p5,p8); PIX_SORT(p5,p3); PIX_SORT(p7,p5);
	  PIX_SORT(p5,p3);
	  rix[0][4] = p5; }
      for (ii=0; ii < rr1*cc1; ii++) qix[ii][d] = qix[ii][4]; }
    // red/blue at GREEN pixel locations
    for (rr=0; rr < rr1; rr++)
      for (cc=(FC(rr,1)&1), c=FC(rr,cc+1); cc < cc1; cc+=2) {
	rix = qix + rr*cc1 + cc;
	rix[0][0] = rix[0][1] + rix[0][3];
	rix[0][2] = rix[0][1] + rix[0][5]; }
    // red/blue and green at BLUE/RED pixel locations
    for (rr=0; rr < rr1; rr++)
      for (cc=(FC(rr,0)&1), c=2-FC(rr,cc), d=c+3; cc < cc1; cc+=2) {
	rix = qix + rr*cc1 + cc;
	rix[0][c] = rix[0][1] + rix[0][d];
	rix[0][1] = 0.5*(rix[0][0] - rix[0][3] + rix[0][2] - rix[0][5]); } }
  // copy result back to image matrix
  for (row=0; row < height; row++)
    for (col=0, rr=row+ba; col < width; col++) {
      cc = col+ba;
      pix = image + row*width + col;
      rix = qix + rr*cc1 + cc;
      c = FC(row,col);
      if (gamma_apply) {
	for (ii=0; ii < 3; ii++)
	  if (ii != c) {
	    v0 = rix[0][ii];
	    if (v0 <= 0.04045)
	      v0 /= 12.92;
	    else
	      v0 = pow((v0 + 0.055)/1.055,2.4);
	    pix[0][ii] = CLIP((int)(65535.0*v0 + 0.5)); } }
      else
	for (ii=0; ii < 3; ii++)
	  if (ii != c)
	    pix[0][ii] = CLIP((int)(65535.0*rix[0][ii] + 0.5));
    }
  // Done
  free(buffer);
  t2 = clock();
  dt = ((double)(t2-t1)) / CLOCKS_PER_SEC;
#ifdef DCRAW_VERBOSE
  if (verbose) fprintf(stderr,_("\telapsed time     = %5.3fs\n"),dt);
#endif
}
Example #12
0
void MUS_GetMousePos( int *mx, int *my )
{
	*mx = LIM(MouseStruct.mx,0,799);
	*my = LIM(MouseStruct.my,0,599);
	return ;
}