Exemple #1
0
Local
FRAME *EasyFilter( FRAME *frame, EFFECT *effect, EXTBASE *PPTBase )
{
    FPTR X_EasyExec;
    char *X_EasyTitle, buf[80];
    APTR UtilityBase = PPTBase->lb_Utility;

    D(bug("EasyFilter()\n"));

    /* Init variables */
    sprintf(buf,XGetStr(mEXECUTING_EASYEXEC),effect->info.nd.ln_Name);
    X_EasyExec  = (FPTR)GetTagData( PPTX_EasyExec, NULL, effect->info.tags );
    X_EasyTitle = (char *)GetTagData( PPTX_EasyTitle, (ULONG)buf,effect->info.tags);

    /* Execute */

    InitProgress( frame, X_EasyTitle, frame->selbox.MinY, frame->selbox.MaxY, PPTBase );

    ExecEasyFilter( frame, X_EasyExec, PPTBase );

    FinishProgress( frame, PPTBase );

    if( frame->errorcode != PERR_OK )
        return NULL;

    return frame;
}
Exemple #2
0
PERROR MakeKeyMaterial( FRAME *frame, UBYTE *passphrase, struct PPTBase *PPTBase )
{
    ROWPTR cp, tmprow;
    WORD row;
    struct ExecBase *SysBase = PPTBase->lb_Sys;
    SHA_INFO sha = {0};
    PERROR res = PERR_OK;

    sha_init( &sha );

    InitProgress(frame,"Building key...", 0, frame->pix->height );

    /*
     *  First, use the passphrase for the key.
     */

    if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) );

    if( tmprow = AllocVec( frame->pix->bytes_per_row, 0L ) ) {
        for( row = 0; row < frame->pix->height; row++ ) {
            WORD col;

            cp = GetPixelRow( frame, row );

            if( Progress( frame, row ) ) {
                res = PERR_BREAK;
                break;
            }

            for( col = 0; col < frame->pix->bytes_per_row; col++ ) {
                /* Use only significant bytes */
                tmprow[col] = cp[col] & 0xFE;
            }

            sha_update( &sha, tmprow, frame->pix->bytes_per_row );
        }

        // Use the passphrase again (why?)

        if( strlen(passphrase) > 0 ) sha_update( &sha, passphrase, strlen(passphrase) );

        FinishProgress( frame );
        sha_final( &sha );

        memcpy( key, &sha.digest[0], SHA_DIGESTSIZE );

        D(sha_print( &sha ) );

        FreeVec( tmprow );
    } else {
        SetErrorCode( frame, PERR_OUTOFMEMORY );
        res = PERR_OUTOFMEMORY;
    }

    return res;
}
void CTreasureHuntingDuplicateManager::InitMgr()
{
	m_bInitFlag = false;
	m_ptrDuplicateIDList = CConfigManager::getSingleton()->GetDuplicateListByType(m_DuplicateType);

	InitProgress();
	///开启所有的副本关卡,因为秘境寻宝副本暂时没有激活或者不激活的概念,一开始玩家就可以挑战所有副本,只是等级有所限制
	ActiveAllDuplicate();
	m_bInitFlag = true;
}
LRESULT CProgressDlg::DlgProc
(
  HWND hWnd, 
  UINT uMsg, 
  WPARAM wParam, 
  LPARAM lParam
)
{

  switch(uMsg)
  {
  case WM_INITDIALOG:
  {
    INITCOMMONCONTROLSEX InitCtrlEx;

    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCtrlEx.dwICC  = ICC_PROGRESS_CLASS;
    InitCommonControlsEx(&InitCtrlEx);
    m_hWnd = hWnd;
    m_hWndProgress = CreateWindowEx(0, PROGRESS_CLASS, NULL,
		               WS_CHILD | WS_VISIBLE,
			      5, 5, 200, 20,
			      hWnd, NULL, NULL, NULL);
    break;
  }
  case WM_NOTIFY_PROGRESS:
    UpdateProgress();
    return TRUE;
  case WM_NOTIFY_TOTAL:
    InitProgress();
    return TRUE;
  case WM_NOTIFY_DONE:
    EndDialog(m_hWnd, 0);
    return TRUE;
  }
  return FALSE;
}
Exemple #5
0
//random supersampling
void Raytracer::Render(void)
{
	//need to have a camera, a render surface, and a scene
	if(!cam)
		return;
	if(!rs)
		return;
	if(!sc)
		return;


	//get the data we need
	Vector o = cam->position;
	Vector updir = cam->up;
	Vector rightdir = cam->right;

	int width = rs->GetWidth();
	int height = rs->GetHeight();
	Color *surface = rs->GetSurface();

	float invaspect = lrflti(height) / lrflti(width);
	float xmag = tanf(cam->fov);
	float ymag = xmag * invaspect;

	Vector topleft = o + cam->normal - rightdir * xmag + updir * ymag;
	Vector dx = rightdir * (2.0f * xmag / lrflti(width));
	Vector dy = updir * (-2.0f * ymag / lrflti(height));
	Vector screenpos, currline = topleft, dir;

	int numSamples = multisampling;
	Vector d = dx + dy;
	Vector offset = o + d * 0.5;
	Color accumulator;
	float divider = 1.0f / lrflti(numSamples);

	Ray r;
	r.origin = o;

	Color pixel;
	float dist = 0.0f;
	InitProgress();

	//render each line in parallel
	int y, x, s;
	float u = 0.0f, v = 0.0f;
#ifdef OMP_ENABLE
#pragma omp parallel for default(none) shared(height, width, dy, dx, o, surface, topleft, offset, numSamples, divider) private(x, y, screenpos, pixel, dir, s, accumulator, u, v) firstprivate(r, dist) schedule(dynamic, 2)
#endif
	for(y = 0; y < height; y++)
	{
		screenpos = topleft + (dy * lrflti(y));
		//now each pixel of that line
		for(x = 0; x < width; x++, screenpos += dx)
		{
			//for each sample of that pixel
			accumulator = Color::black;
			for(s = 0; s < numSamples; s++)
			{
				//clear out the pixel
				pixel = Color::black;
				//create the ray
#ifdef DISABLE_JITTER
				dir = screenpos - offset;
#else
				u = lrflti(rand()) * MAX_RAND_DIVIDER;
				v = lrflti(rand()) * MAX_RAND_DIVIDER;
				dir = screenpos - offset + (dx * u) + (dy * v);
#endif
				dir = dir / dir.Length();
				r.direction = dir;
				//trace the actual ray
				Raytrace(r, pixel, 0, dist);
				accumulator += pixel;
			}

			//update the pixel color
			surface[y * width + x] = accumulator * divider;

			//update the progression
			SetProgress(static_cast<float>(y * width + x) / static_cast<float>(width * height));
		}
	}

	FinishProgress();
}
Exemple #6
0
FRAME *DoTransparency( FRAME *frame, struct Values *v, struct PPTBase *PPTBase)
{
    FRAME *newframe = NULL;
    BOOL  hasalpha = FALSE;
    ULONG tol;

    tol = SQR(v->tolerance);

    if( frame->pix->colorspace == CS_ARGB )
        hasalpha = TRUE;

    // PDebug(MYNAME": Exec()\n");

    newframe = MakeFrame( frame );
    if(newframe) {
        newframe->pix->colorspace = CS_ARGB;
        newframe->pix->components = 4;

        if( InitFrame( newframe ) == PERR_OK ) {
            WORD row;

            InitProgress(frame,"Setting up transparency...",0,frame->pix->height);

            for( row = 0; row < frame->pix->height; row++ ) {
                RGBPixel *cp;
                ARGBPixel *dcp, *acp;
                WORD col;
                BOOL isin;

                if( Progress(frame, row) ) {
                    RemFrame(newframe);
                    newframe = NULL;
                    break;
                }

                cp = (RGBPixel *)GetPixelRow( frame, row );
                acp = (ARGBPixel *)cp;
                dcp = (ARGBPixel *)GetPixelRow( newframe, row );

                /*
                 *  Loopety loop.  If the pixel to be set is exactly
                 *  the color, then set the transparency.
                 */

                for( col = 0; col < frame->pix->width; col++ ) {
                    ULONG dist;

                    /*
                     *  Check if we're inside selbox
                     */

                    if( row >= frame->selbox.MinY && row < frame->selbox.MaxY &&
                        col >= frame->selbox.MinX && col < frame->selbox.MaxX ){
                        isin = TRUE;
                    } else {
                        isin = FALSE;
                    }

                    /*
                     *  Set the alpha channel, if we're inside the selbox
                     */
                    if( hasalpha ) {
                        dist = SQR((WORD)((WORD)acp->r - v->r))+
                               SQR((WORD)((WORD)acp->g - v->g))+
                               SQR((WORD)((WORD)acp->b - v->b));

                        if( (v->mode == MODE_ALL || dist <= tol) && isin)
                        {
                            dcp->a = (UBYTE) v->transp;
                        } else {
                            dcp->a = acp->a; /* Retain transparency */
                        }
                        dcp->r = acp->r;
                        dcp->g = acp->g;
                        dcp->b = acp->b;
                        acp++;
                        dcp++;
                    } else {
                        dist = SQR((WORD)((WORD)cp->r - v->r))+
                               SQR((WORD)((WORD)cp->g - v->g))+
                               SQR((WORD)((WORD)cp->b - v->b));

                        if( (v->mode == MODE_ALL || dist <= tol) && isin)
                        {
                            dcp->a = (UBYTE) v->transp;
                        } else {
                            dcp->a = 0; /* No transparency */
                        }
                        dcp->r = cp->r;
                        dcp->g = cp->g;
                        dcp->b = cp->b;
                        cp++;
                        dcp++;
                    }
                }

                PutPixelRow( newframe, row, dcp );
            }

            FinishProgress(frame);

        } else {
            RemFrame(newframe);
            newframe = NULL;
        }
    }

    return newframe;

}
Exemple #7
0
EFFECTEXEC(frame,tags,PPTBase,EffectBase)

{
    ROWPTR cp[3];
    WORD row, comps = frame->pix->components;

//    PDebug(MYNAME": Exec()\n");

    InitProgress( frame, "Removing isolated pixels...", frame->selbox.MinY, frame->selbox.MaxY );
//    PDebug("\tBegin\n");

    for( row = frame->selbox.MinY; row < frame->selbox.MaxY; row++ ) {
        UWORD col;

        //PDebug("\Reading around row %d\n",row);

        if(GetNPixelRows(frame, cp, row-1, 3) == 0) { /* Get immediate vicinity */
            frame = NULL;
            goto quit;
        }

        if(Progress(frame, row)) {
            frame = NULL;
            goto quit;
        }

        for(col = frame->selbox.MinX; col < frame->selbox.MaxX; col++ ) {
            UWORD count = 0;
            WORD i;
            UBYTE r,g,b;

            switch(frame->pix->colorspace) {

            case CS_RGB:
                if(col == 0) { /* Pick from right side */
                    r = cp[1][ (col+1) * 3 ];
                    g = cp[1][ (col+1) * 3 +1 ];
                    b = cp[1][ (col+1) * 3 +2 ];
                } else { /* pick from left side */
                    r = cp[1][ (col-1) * 3 ];
                    g = cp[1][ (col-1) * 3 +1 ];
                    b = cp[1][ (col-1) * 3 +2 ];
                }
                count = 0;

                // PDebug("\t(%d,%d) : Ref=(%02X-%02X-%02X)\n",row,col,r,g,b);
                for( i = 0; i <= 2; i++) {
                    if( cp[i] ) { /* Skip NULLs */
                        WORD j;
                        for(j = -1; j <= 1; j++ ) {
                            ULONG offset;
                            offset = (col+j)*3;
                            if( cp[i][ offset ] == r ) {
                                if( cp[i][ offset+1 ] == g ) {
                                    if( cp[i][ offset+2 ] == b ) {
                                        // PDebug("\t\tMatch found at (%d,%d)\n", row+i, col+j);
                                        if( !(i == 1 && j == 0) ) /* Don't count middle */
                                            count++;
                                    }
                                }
                            }
                        }
                    }
                }
                break;


            case CS_ARGB:
                if(col == 0) { /* Pick from right side */
                    r = cp[1][ (col+1) * 4 +1 ];
                    g = cp[1][ (col+1) * 4 +2 ];
                    b = cp[1][ (col+1) * 4 +3 ];
                } else { /* pick from left side */
                    r = cp[1][ (col-1) * 4 + 1];
                    g = cp[1][ (col-1) * 4 + 2];
                    b = cp[1][ (col-1) * 4 + 3];
                }
                count = 0;

                // PDebug("\t(%d,%d) : Ref=(%02X-%02X-%02X)\n",row,col,r,g,b);
                for( i = 0; i <= 2; i++) {
                    if( cp[i] ) { /* Skip NULLs */
                        WORD j;
                        for(j = -1; j <= 1; j++ ) {
                            ULONG offset;
                            offset = (col+j)*4;
                            if( cp[i][ offset + 1 ] == r ) {
                                if( cp[i][ offset+2 ] == g ) {
                                    if( cp[i][ offset+3 ] == b ) {
                                        // PDebug("\t\tMatch found at (%d,%d)\n", row+i, col+j);
                                        if( !(i == 1 && j == 0) ) /* Don't count middle */
                                            count++;
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case CS_GRAYLEVEL:
                /* Colorspace is greyscale */
                if(col == 0)  /* Pick from right side */
                    r = cp[1][ (col+1) ];
                else  /* pick from left side */
                    r = cp[1][ (col-1) ];
                count = 0;

                // PDebug("\t(%d,%d) : Ref=(%02X-%02X-%02X)\n",row,col,r,g,b);
                for( i = 0; i <= 2; i++) {
                    if( cp[i] ) {
                        WORD j;

                        for(j = -1; j <= 1; j++ ) {
                            if( cp[i][ (col+j) ] == r ) {
                                // PDebug("\t\tMatch found at (%d,%d)\n", row+i, col+j);
                                if( !(i == 1 && j == 0) ) /* Don't count middle */
                                    count++;
                            }
                        }
                    }
                }
                break;
            }

            // PDebug("\t\tcount = %d\n",count);
            /* Was this one alone? */
            if(count == 8) {
                UBYTE *scp, *dcp;
                WORD i;

                // PDebug("\tPixel at (%d,%d) is alone\n",row,col);
                dcp = cp[1] + col*comps;
                if( col == 0 )
                    scp = cp[1]+(col+1)*comps;
                else
                    scp = cp[1]+(col-1)*comps;

                for(i = 0; i < comps; i++) {
                    *dcp++ = *scp++;
                }
            } /* count */

        } /* for(col = ...) */
        PutNPixelRows(frame,cp,row-1,3);
    } /* for(row = ...) */

quit:
    FinishProgress(frame);

    return frame;
}
Exemple #8
0
extern "C" __declspec(dllexport) int sikou( int tesu, unsigned char kifu[][2],
		int* timer_sec, int* i_moto, int* i_saki, int* i_naru ){
/**************************************************************
思考ルーチンの呼び出し
**************************************************************/
	HANDLE hThread;
	DWORD ret;
	MOVE move;
	int i;

	if( sikou_flag )
		return 0;

	// 相手番思考スレッドの終了を待つ。
	if( g_hPonder != INVALID_HANDLE_VALUE ){
		chudanPonder = 1;
		WaitForSingleObject( g_hPonder, INFINITE );
		CloseHandle( g_hPonder );
		g_hPonder = INVALID_HANDLE_VALUE;
	}

	// 思考中情報表示の初期化
	InitProgress();

	if( pshogi == NULL ){
		if( ( pshogi = new ShogiEval ) == NULL )
			return 0;
	}

	if( pthink == NULL ){
		if( ( pthink = new Match ) == NULL )
			return 0;
	}

	while( pshogi->GoBack() )
		;

	// 現在の局面を作る。
	for( i = 0 ; i < tesu ; i++ ){
		// 移動元
		if( kifu[i][1] <= 81 ){
			// 盤上
			move.from = CSA2SUN( kifu[i][1] );
		}
		else{
			// 駒台
			move.from = kifu[i][1] - 100;
			move.from |= pshogi->GetSengo() | DAI;
		}

		// 移動先
		if( kifu[i][0] <= 81 ){
			// 成らない場合
			move.to = CSA2SUN( kifu[i][0] );
			move.nari = 0;
		}
		else{
			// 成る場合
			move.to = CSA2SUN( kifu[i][0] - 100 );
			move.nari = 1;
		}

		// 差し手を入力
		if( !pshogi->Move( move ) )
			return 0;
	}

	// 思考開始
	chudan = 0;
	chudanDfPn = 0;
	hThread = (HANDLE)_beginthreadex( NULL, 0, ThinkThread, (LPVOID)&move, 0, NULL );
	for( ; ; ){
		GetExitCodeThread( hThread, &ret );
		if( ret != STILL_ACTIVE ){
			if( ret == 0 )
				return 0;
			break;
		}
		if( chudan_flag != NULL && *chudan_flag != 0 ){
			chudan = 1;
			chudanDfPn = 1;
		}
		dispatch();
		Sleep( 10 );
	}

	CloseHandle( hThread );

	// 結果を返す。

	// 移動元
	if( move.from & DAI ){
		// 駒台
		*i_moto = ( move.from & ~(DAI | SENGO) ) + 100;
	}
	else{
		// 盤上
		*i_moto = SUN2CSA( move.from );
	}

	// 移動先
	*i_saki = SUN2CSA( move.to );
	*i_naru = move.nari;

	// 相手番思考を開始
	if( bPonder && chudan_flag != NULL ){
		// 思考中情報表示の初期化
		InitProgress();

		chudanPonder = 0;
		pshogi->MoveD( move );
		g_hPonder = (HANDLE)_beginthreadex( NULL, 0, PonderSearchThread, (LPVOID)NULL, 0, NULL );
	}

	return 1;
}
Exemple #9
0
int DoConvolute( FRAME *src, FRAME *dest, struct convargs *cargs, struct PPTBase *PPTBase )
{
    UWORD row, xstart = src->selbox.MinX, xend = src->selbox.MaxX;
    WORD crow;
    int d;
    PERROR res = PERR_OK;
    UBYTE buf[40],cspace = src->pix->colorspace;
    ULONG xoffset;
    ROWPTR buffer[7]; /* Has room for 7x7 matrices */

#ifdef DEBUG_MODE
    PDebug("\tDoConvolute()\n");
#endif

    if(SetFilterSize( cargs ) == 0)
        return PERR_GENERAL;

    sprintf(buf,"Convolute: %s [%dx%d]...",cargs->name,cargs->size, cargs->size);

    InitProgress( src, buf, src->selbox.MinY, src->selbox.MaxY );

    d = cargs->size >> 1;
#ifdef DEBUG_MODE
    PDebug("\tConvolution matrix size is %d x %d (%d...%d)\n",cargs->size,cargs->size,-d,d);
#endif
    xoffset = xstart * src->pix->components;

    /*
     *  Do the convolute.
     */

    for( row = src->selbox.MinY; row < src->selbox.MaxY; row++ ) {
        ROWPTR dcp, dcp2;
        WORD col;

        dcp2 = dcp = GetPixelRow( dest, row );
        dcp += xoffset;
        if(GetNPixelRows( src, buffer, row - d, cargs->size ) == 0) {
            res = PERR_GENERAL;
            goto quit;
        }

        if(Progress( src, row )) {
            res = PERR_BREAK;
            goto quit;
        }

        for( col = xstart; col < xend; col++ ) {
            int i;
            LONG valr,valg,valb,vala;

            /*
             *  Now, go through all values
             */

            valr = valb = valg = vala = 0L;

            for(i = -d; i <= d; i++) {
                UBYTE *scp;

                crow = row + i;
                scp = buffer[ i + d ];

                if( crow >= 0 && crow < src->pix->height ) {
                    int j;

                    for(j = -d; j <= d; j++ ) {
                        WORD ccol;

                        ccol = (WORD)col + j;
                        if( ccol >= 0 && ccol < src->pix->width ) {
                            /* Actual convolution */
                            int wt;
                            if( ( wt = cargs->weights[i+3][j+3]) ) {
                                UBYTE *pptr;
                                switch(cspace) {
                                    case CS_RGB:
                                        pptr = scp + MULS16(ccol,3);
                                        valr += (*pptr++) * wt;
                                        valg += (*pptr++) * wt;
                                        valb += (*pptr++) * wt;
                                        break;

                                    case CS_GRAYLEVEL:
                                        pptr = scp + ccol;
                                        valr += (*pptr++) *wt;
                                        break;

                                    case CS_ARGB:
                                        pptr = scp + (ccol<<2);
                                        if( i == 0 && j == 0 ) vala = *pptr;
                                        pptr++; /* Skip alpha */
                                        valr += (*pptr++) * wt;
                                        valg += (*pptr++) * wt;
                                        valb += (*pptr++) * wt;
                                        break;
                                }
                            }
                        } /* if ccol */
                    }
                } /* if crow */
            }

            switch(cspace) {
                case CS_GRAYLEVEL:
                    valr = valr / cargs->div + cargs->bias;
                    if(valr < 0) valr = 0;
                    else { if(valr > 255) valr = 255; }
                    *dcp++ = (UBYTE)valr;
                    break;

                case CS_ARGB:
                    *dcp++ = vala;
                    /* FALLTHROUGH INTENDED */

                case CS_RGB:
                    /* RED  */
                    valr = valr / cargs->div + cargs->bias;
                    if(valr < 0) valr = 0;
                    else { if(valr > 255) valr = 255; }
                    *dcp++ = (UBYTE)valr;

                    /* GREEN*/
                    valg = valg / cargs->div + cargs->bias;
                    if(valg < 0) valg = 0;
                    else { if(valg > 255) valg = 255; }
                    *dcp++ = (UBYTE)valg;

                    /* BLUE */
                    valb = valb / cargs->div + cargs->bias;
                    if(valb < 0) valb = 0;
                    else { if(valb > 255) valb = 255; }
                    *dcp++ = (UBYTE)valb;
                    break;
            }

        }
        PutPixelRow( dest, row, dcp2 );

    }
quit:
    FinishProgress(src);

    return res;
}
Exemple #10
0
FRAME *DoComposite( FRAME *dest, FRAME *src, struct gFixRectMessage *gfr,
                    MethodID how, WORD mixratio, BOOL tile, struct PPTBase *PPTBase )
{
    WORD row, col;
    WORD dcomps = dest->pix->components,
         scomps = src->pix->components;
    WORD dest_has_alpha = 0, src_has_alpha = 0;
    WORD top, bottom, left, right;

    D(bug("Doing the composite.  gfr = %d,%d,%d,%d\n",
           gfr->x, gfr->y, gfr->dim.Width, gfr->dim.Height));

    /*
     *  Initialize
     */

    if( src->pix->colorspace == CS_ARGB )
        src_has_alpha = 1;

    if( dest->pix->colorspace == CS_ARGB )
        dest_has_alpha = 1;

    if( tile ) {
        top = dest->selbox.MinY;
        left = dest->selbox.MinX;
        bottom = dest->selbox.MaxY;
        right = dest->selbox.MaxX;
    } else {
        top = gfr->y;
        bottom = gfr->y + gfr->dim.Height;
        left = gfr->x;
        right = gfr->x + gfr->dim.Width;
    }

    InitProgress( dest, "Compositing...", top, bottom );

    for( row = top; row < bottom; row++ ) {
        ROWPTR scp, dcp;
        WORD srow;

        srow = (row - gfr->y) % gfr->dim.Height;
        if( srow < 0 && tile ) srow += gfr->dim.Height;

        scp = GetPixelRow(src,  srow);
        dcp = GetPixelRow(dest, row);

        if( !dcp ) continue; /* Skip all areas that are outside */

        if( Progress(dest, row) )
            return NULL;

        for( col = left; col < right; col++ ) {
            LONG a, tr,tg,tb;
            UBYTE *s, *d;
            WORD scol;

            /*
             *  Sanitation check.  Let's not overwrite innocent
             *  memory.
             */

            if( col < 0 || col >= dest->pix->width ) continue;

            scol = ( col - gfr->x ) % gfr->dim.Width;
            if( scol < 0 && tile ) scol += gfr->dim.Width;

            if( src_has_alpha )
                a = (LONG)scp[scomps*scol];

            d = &dcp[dcomps*col+dest_has_alpha];
            s = &scp[scomps*scol+src_has_alpha];

            tr = *(d+0);
            tg = *(d+1);
            tb = *(d+2);

            switch( how ) {
                case Direct:
                    tr = *s; tg = *(s+1); tb = *(s+2);
                    break;

                case Minimum:
                    if( VECTOR_LEN(tr, tg, tb) > VECTOR_LEN(*s, *(s+1), *(s+2)) ) {
                        tr = *s; tg = *(s+1); tb = *(s+2);
                    }
                    break;

                case Maximum:
                    if( VECTOR_LEN(tr, tg, tb) < VECTOR_LEN(*s, *(s+1), *(s+2)) ) {
                        tr = *s; tg = *(s+1); tb = *(s+2);
                    }
                    break;

                case Mix:
                    tr = (mixratio * (*s) + (255-mixratio) * tr ) / 255;
                    tg = (mixratio * (*(s+1)) + (255-mixratio) * tg ) / 255;
                    tb = (mixratio * (*(s+2)) + (255-mixratio) * tb ) / 255;
                    break;

                case TransparentBlack:
                    if( *s || *(s+1) || *(s+2) ) {
                        tr = *s; tg = *(s+1); tb = *(s+2);
                    }
                    break;

                case Add:
                    tr = CLAMP_UP(*(s+0) + tr, 255);
                    tg = CLAMP_UP(*(s+1) + tg, 255);
                    tb = CLAMP_UP(*(s+2) + tb, 255);
                    break;

                case Subtract:
                    tr = CLAMP_DOWN( tr - *(s+0), 0 );
                    tg = CLAMP_DOWN( tg - *(s+1), 0 );
                    tb = CLAMP_DOWN( tb - *(s+2), 0 );
                    break;

                case Multiply:
                    tr = (tr * *(s+0)) / 256;
                    tg = (tg * *(s+1)) / 256;
                    tb = (tb * *(s+2)) / 256;
                    break;
            }

            if( src_has_alpha ) {
                tr = ((255-a) * tr + a * *(d+0) ) /256;
                tg = ((255-a) * tg + a * *(d+1) ) /256;
                tb = ((255-a) * tb + a * *(d+2) ) /256;
            }

            *d     = tr;
            if( dest->pix->colorspace != CS_GRAYLEVEL ) {
                *(d+1) = tg;
                *(d+2) = tb;
            }

#if 0
            for( pix = 0; pix < colors; pix++ ) {
                UBYTE s,d;
                LONG  t;

                d = dcp[dcomps*col+pix+dest_has_alpha];
                s = scp[scomps*(col-gfr->x)+pix+src_has_alpha];
                t = (LONG)d;

                switch(how) {
                    case Direct:
                        t = s;
                        break;

                    case Minimum:
                        if( d > s ) t = s;
                        break;

                    case Maximum:
                        if( d < s ) t = s;
                        break;

                    case Mix:
                        t = (mixratio*s + (255-mixratio)*d)/255;
                        break;

                    case TransparentBlack:
                        if( s != 0 ) t = s;
                        break;

                    case Add:
                        t = d+s;
                        if( t > 255 ) t = 255;
                        break;

                    case Subtract:
                        t = d-s;
                        if( t < 0 ) t = 0;
                        break;

                    case Multiply:
                        t = ((LONG)d * (LONG)s) / 256;
                        break;

                }

                if( src_has_alpha )
                    t = ((255-a) * t + a*d)/255;

                dcp[dcomps*col+pix+dest_has_alpha] = (UBYTE)t;
            }
#endif
        }
        PutPixelRow(dest,row,dcp);
    }

    FinishProgress(dest);

    return dest;
}