L_CurveToBezier
#include "l_bitmap.h"
L_LTDIS_API L_INT L_CurveToBezier(pCurve, pOutPointCount, pOutPoint)
pCURVE pCurve; |
/* pointer to a structure */ |
L_INT* pOutPointCount; |
/* pointer to a variable */ |
L_POINT *OutPoint; |
/* pointer to an array of structures */ |
Converts a curve (defined by an array of points that the curve passes through) to an array of Bezier points. The resulting array can be used to with the Windows APIs PolyBezier and PolyBezierTo.
Parameter |
Description |
pCurve |
Pointer to a CURVE structure that defines a curve. |
pOutPointCount |
Pointer to a variable to be updated with the number of Bezier control points. |
pOutPoint |
Pointer to an array of POINT structures to be updated with the Bezier control points. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function is used to convert a standard curve to an array of Bezier control points. A LEAD standard curve (CURVE_STANDARD) is defined by the CURVE structure, and one of the fields is an array of POINT structures. The standard curve passes through all of the points in the array, and is continuous at each point. This function can be used to draw this curve by converting it to an array of Bezier points, and using the Windows API PolyBezier (or PolyBezierTo) to draw the equivalent Bezier.
To use this function, declare a variable of type CURVE, and fill in the appropriate fields. For this function, all fields of the CURVE structure are required EXCEPT uFillMode, which is ignored. For more information, refer to the CURVE structure.
The pOutPoint must point to an array of POINT structures that is large enough to hold the Bezier control points. At most, the resulting array must hold (3n + 1) entries, where n is the number of points in the CURVE_STANDARD curve. If this function is called with pOutPoint set to NULL, pOutPointCount will be updated with the required number of entries in the pOutPoint array.
Required DLLs and Libraries
LTDIS For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 2000 / XP/Vista.
See Also
Functions: |
Example
This sample draws a smooth closed curve on hDC that goes through five points
L_INT CurveToBezierExample(HDC hDC) { L_INT nRet; CURVE Curve; POINT points[5]; L_INT nOutPointCount; LPPOINT pOutPoints; HPEN hPen, hPrevPen; L_INT nPrevROP2; //Define the points of the curve points[0].x = 130; points[0].y = 130; points[1].x = 130; points[1].y = 300; points[2].x = 230; points[2].y = 230; points[3].x = 175; points[3].y = 175; points[4].x = 230; points[4].y = 130; Curve.uStructSize = sizeof(CURVE); Curve.nType = CURVE_STANDARD; Curve.nPointCount = 5; Curve.pPoints = points; Curve.uFillMode = L_POLY_WINDING; //This member is ignored Curve.dTension = 0.5; Curve.nClose = CURVE_CLOSE; Curve.nReserved = 0; //Determined the number of required points nRet = L_CurveToBezier(&Curve, &nOutPointCount, NULL); if (nRet != SUCCESS) return nRet; pOutPoints = (LPPOINT)malloc( sizeof(POINT) * nOutPointCount); if (pOutPoints == NULL) return FAILURE; nRet = L_CurveToBezier(&Curve, &nOutPointCount, pOutPoints); if (nRet != SUCCESS) { free(pOutPoints); return nRet; } //Create a pen hPen = CreatePen(PS_SOLID, 1,RGB(255,255,255)); hPrevPen = (HPEN)SelectObject(hDC, hPen); nPrevROP2 = SetROP2(hDC, R2_XORPEN); //Draw the curve that goes through the original five points nRet = PolyBezier(hDC, pOutPoints, nOutPointCount); //Restore the hDC SetROP2(hDC, nPrevROP2); SelectObject(hDC, hPrevPen); DeleteObject(hPen); free(pOutPoints); return SUCCESS; }