示例#1
0
void Transformer( LPTFORM lpTForm, LPPOINT lpPoint, LPINT lpx, LPINT lpy )
/***********************************************************************/
{
    long x, y;
    LFIXED fx, fy;

    x = lpPoint->x;
    y = lpPoint->y;

#ifndef USING_FIXED16

    fx = (lpTForm->ax * x) + (lpTForm->bx * y) + lpTForm->cx;
    fy = (lpTForm->ay * x) + (lpTForm->by * y) + lpTForm->cy;
    *lpx = FROUND(fx);
    *lpy = FROUND(fy);

#else

    fx = (lpTForm->ax * x) + (lpTForm->bx * y) + lpTForm->cx + HALF;
    fy = (lpTForm->ay * x) + (lpTForm->by * y) + lpTForm->cy + HALF;
    *lpx = (INT16)HIWORD( fx );
    *lpy = (INT16)HIWORD( fy );

#endif
}
示例#2
0
//************************************************************************
//			lut_draw
// PARAMETERS:
//					LPRECT lpArea- The area to update.
//					BOOL bOn- draw ON or draw OFF?
//
// DESCRIPTION:
//			Draws the given range from lpData.  If lpData==NULL then it 
//			will use lpdata->Map (setup in lut_compute).	 Draws handles 
//			unless (dwFlags & MS_NOHANDLES). 
// RETURNS:
//
//************************************************************************
LOCAL void lut_draw(LPLUTCTL lpdata, HDC hDC, LPRECT lpArea, BOOL bOn)
//***********************************************************************
{
	LFIXED rateX, rateY, lVal;
	BOOL bInvX = FALSE, bInvY = FALSE;
	POINT offset;
	POINT DataOut[256];
	int OldROP;
	int i, lut, nLuts, maxx, maxy, num;
	LPTR lpLut;
        RGBS rgb;
	HPEN hOldPen, hPen;
	RECT rArea;
	POINT	point;

	if ((lpdata->nLuts <= 0) || !lpdata->lpLut)
		return;

	// subtract one cause we are using PolyLine
	rArea = *lpArea;
	--rArea.bottom;
	--rArea.right;

//	bInvX = (lpdata->dwStyle & MS_INVERTX);
//	bInvY = (lpdata->dwStyle & MS_INVERTY);
	offset.x = (bInvX ? rArea.right : rArea.left);
	offset.y = (bInvY ? rArea.top: rArea.bottom);

	for (lut = 0; lut < lpdata->nLuts; ++lut)
	{
		// determine source data
		lpLut = lpdata->lpLut;
		lpLut += lut;
		nLuts = lpdata->nLuts;

		maxx = RectWidth(&rArea)-1;
		maxy = RectHeight(&rArea)-1;
	   	rateX = FGET(maxx, MAXVAL);
   		rateY = FGET(maxy, MAXVAL);

		// convert to screen coords
		if (rateX < FUNITY)
		{
			// go through pixels
	   		rateX = FGET(MAXVAL, maxx);
			num = maxx+1;
			for (i=0; i<num; i++)
			{
				DataOut[i].x = i;
				DataOut[i].y = FMUL(lpLut[FMUL(i,rateX)*nLuts], rateY);
			}
		}
		else
		{
			// go through map
			lVal = 0;
			num = 256;
	 		for (i=0; i<num;i++)
			{
			  	DataOut[i].x = FROUND(lVal);
				DataOut[i].y = FMUL(lpLut[i*nLuts], rateY);
				lVal += rateX;
			}
		}
	
		// convert to screen coords
		for (i=0; i<num;i++)
		{
			DataOut[i].x = (bInvX ? (offset.x-DataOut[i].x) : (offset.x+DataOut[i].x));
			DataOut[i].y = (bInvY ? (offset.y+DataOut[i].y) : (offset.y-DataOut[i].y));
		}
	
		// draw line
		rgb = lpdata->Colors[lut];
		hPen = CreatePen(PS_SOLID, 1, RGB(rgb.red, rgb.green, rgb.blue));
		hOldPen = (HPEN)SelectObject(hDC, hPen);
		Polyline(hDC, DataOut, num);
		// make sure we draw on endpoint
		MoveToEx(hDC, DataOut[num-1].x, DataOut[num-1].y, &point);
		LineTo(hDC, DataOut[num-1].x+1, DataOut[num-1].y-1);
		SelectObject(hDC, hOldPen);
		DeleteObject(hPen);
	}
}
示例#3
0
void    epsf_special(DviContext *dvi, char *prefix, char *arg)
{
    char    *file;
    char    *special;
    char    *psfile;
    char    *tmp;
    EpsfBox    box = {0, 0, 0, 0};
    int    x, y;
    int    w, h;
    double    xf, vf;
    struct stat buf;
    
    file = parse_epsf_special(&box, &special, prefix, arg);
    if (file != NULL)
        mdvi_free (special);

    xf = dvi->params.dpi * dvi->params.mag / (72.0 * dvi->params.hshrink);
    vf = dvi->params.vdpi * dvi->params.mag / (72.0 * dvi->params.vshrink);
    w = FROUND(box.bw * xf);
    h = FROUND(box.bh * vf);
    x = FROUND(box.ox * xf) + dvi->pos.hh;
    y = FROUND(box.oy * vf) + dvi->pos.vv - h + 1;

    if (!file || !dvi->device.draw_ps) {
        dvi->device.draw_rule (dvi, x, y, w, h, 0);
        return;
    }

    if (file[0] == '/') { /* Absolute path */
        if (stat (file, &buf) == 0)
            dvi->device.draw_ps (dvi, file, x, y, w, h);
        else
            dvi->device.draw_rule (dvi, x, y, w, h, 0);
        return;
    }

    tmp = mdvi_strrstr (dvi->filename, "/");
    if (tmp) { /* Document directory */
        int path_len = strlen (dvi->filename) - strlen (tmp + 1);
        int file_len = strlen (file);
        
        psfile = mdvi_malloc (path_len + file_len + 1);
        psfile[0] = '\0';
        strncat (psfile, dvi->filename, path_len);
        strncat (psfile, file, file_len);

        if (stat (psfile, &buf) == 0) {
            dvi->device.draw_ps (dvi, psfile, x, y, w, h);
            mdvi_free (psfile);

            return;
        }

        mdvi_free (psfile);
    }
            
    psfile = mdvi_build_path_from_cwd (file);
    if (stat (psfile, &buf) == 0) { /* Current working dir */
        dvi->device.draw_ps (dvi, psfile, x, y, w, h);
        mdvi_free (psfile);

        return;
    }

    mdvi_free (psfile);
    
    psfile = kpse_find_pict (file);
    if (psfile) { /* kpse */
        dvi->device.draw_ps (dvi, psfile, x, y, w, h);
    } else {
        dvi->device.draw_rule(dvi, x, y, w, h, 0);
    }

    free (psfile);
}