Ejemplo n.º 1
0
BOOL CChildView::EncodeCrop(LPPOINT lptStart, LPPOINT lptEnd, LPRECT lpRect)
{
    int x, y, c1, c2, c;
    double slope;

    c1 = EncodePoint(lptStart, lpRect);
    c2 = EncodePoint(lptEnd  , lpRect);

    if (c1 & c2)
        return FALSE;

    if (lptStart->x == lptEnd->x)
    {
        if (c1 & BOTTOM) lptStart->y = lpRect->bottom;
        else if (c1 & TOP) lptStart->y = lpRect->top;
        if (c2 & BOTTOM) lptEnd->y = lpRect->bottom;
        else if (c2 & TOP) lptEnd->y = lpRect->top;
        return TRUE;
    }

    slope = (double)(lptEnd->y - lptStart->y) / (double)(lptEnd->x - lptStart->x);

    while (c1 | c2)
    {
        if (c1)
            c = c1;
        else
            c = c2;

        if (c & LEFT)
        {
            x = lpRect->left;
            y = (int)(lptStart->y + slope * (lpRect->left - lptStart->x));
        }
        else if (c & TOP)
        {
            y = lpRect->top;
            x = (int)(lptStart->x + (lpRect->top - lptStart->y) / slope);
        }
        else if (c & RIGHT)
        {
            x = lpRect->right;
            y = (int)(lptStart->y + slope * (lpRect->right - lptStart->x));
        }
        else if (c & BOTTOM)
        {
            y = lpRect->bottom;
            x = (int)(lptStart->x + (lpRect->bottom - lptStart->y) / slope);
        }

        if (c == c1)
        {
            lptStart->x = x;
            lptStart->y = y;
            c1 = EncodePoint(lptStart, lpRect);
        }
        else
        {
            lptEnd->x = x;
            lptEnd->y = y;
            c2 = EncodePoint(lptEnd, lpRect);
        }
    }

    return TRUE;
}
Ejemplo n.º 2
0
void ECP::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const
{
	ArraySink sink(encodedPoint, EncodedPointSize(compressed));
	EncodePoint(sink, P, compressed);
	assert(sink.TotalPutLength() == EncodedPointSize(compressed));
}
Ejemplo n.º 3
0
void EC2N::DEREncodePoint(BufferedTransformation &bt, const Point &P, bool compressed) const
{
	SecByteBlock str(EncodedPointSize(compressed));
	EncodePoint(str, P, compressed);
	DEREncodeOctetString(bt, str);
}
Ejemplo n.º 4
0
void EC2N::EncodePoint(byte *encodedPoint, const Point &P, bool compressed) const
{
	ArraySink sink(encodedPoint, EncodedPointSize(compressed));
	EncodePoint(sink, P, compressed);
	CRYPTOPP_ASSERT(sink.TotalPutLength() == EncodedPointSize(compressed));
}