求GDI+中DrawCurve函数使用方法(POINT和Point)

howard 2006-04-03 08:26:20
POINT *curPoints = new POINT[i_Points];
for(int j=0;j<i_Points;j++)
{
curPoints[j].x=curx;
curPoints[j].y=cury;
}
Point* pcurvePoints = curPoints;

graphics.DrawCurve(&pen,pcurvePoints,i_Points);


=====================
我还不会如何动态创建Point类型的数组,有什么方法可以把POINT转换成Point类型么?
GDI中Point好象只能这样声明(MSDN中看到的)
=====================

Point point1(100, 100);
Point point2(200, 50);
Point point3(400, 10);
Point point4(500, 100);

Point curvePoints[4] = {
point1,
point2,
point3,
point4};

Point* pcurvePoints = curvePoints;

graphics.DrawCurve(&greenPen, curvePoints, 4, 1.0);

...全文
965 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tan18 2006-04-06
  • 打赏
  • 举报
回复
应该可以吧,我用过
PointF* pts = new PointF(nPointCount);
gs->DrawLines();
没有问题
wlwlxj 2006-04-06
  • 打赏
  • 举报
回复
ding
howard 2006-04-05
  • 打赏
  • 举报
回复
自己 up
昊叔 2006-04-04
  • 打赏
  • 举报
回复
Point* pcurvePoints = new Point[i_Points];
for(int j=0;j<i_Points;j++)
{
pcurvePoints [j].X=curx;
pcurvePoints [j].Y=cury;
}

graphics.DrawCurve(&pen,pcurvePoints,i_Points);
howard 2006-04-04
  • 打赏
  • 举报
回复
error C2664: 'enum Gdiplus::Status __thiscall Gdiplus::Graphics::DrawCurve(const class Gdiplus::Pen *,const class Gdiplus::PointF *,int)' : cannot convert parameter 2 from 'struct tagPOINT *' to 'const cla
ss Gdiplus::PointF *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
howard 2006-04-04
  • 打赏
  • 举报
回复
对呀,可是POINT类型的不能使用在DrawCurve里啊,DrawCurve需要使用Point类型的。如何转换呢?
dch4890164 2006-04-04
  • 打赏
  • 举报
回复
POINT *curPoints = new POINT[i_Points];
这个不就是动态创建嘛!
howard 2006-04-04
  • 打赏
  • 举报
回复
谁能帮帮我啊,着急啊
iori_wen 2006-04-04
  • 打赏
  • 举报
回复
up
howard 2006-04-04
  • 打赏
  • 举报
回复
最后顶一次,我舍了一个断点,运行看了一下,如果手动创建的话,那么就没问题,
如果是Point *curPoints = new Point [i_Points];这样创建出来的,好象数组里只有1个值。但是我FOR循环的时候还是可以取去里面的XY的。真奇怪
howard 2006-04-04
  • 打赏
  • 举报
回复
CDC *dc;
dc=this->GetDC();
Graphics graphics(dc->m_hDC);
//Pen pen(penColor,i_penWidth);
Pen pen(Color::Green,5);

Point pt1(320,380);
Point pt2(420,540);
Point pt3(620,440);
Point pt4(580,220);
Point pt5(380,300);
Point pt6(400,360);
Point pt7(320,380);
Point curPoints[7]=
{
pt1,pt2,pt3,pt4,pt5,pt6,pt7
};

graphics.DrawClosedCurve(&pen,curPoints,7);

这样就能画出图样来,可是下面的代码就画不出来,curPoints数值都是一样的呀
Point *curPoints = new Point [i_Points];
for(int j=0;j<i_Points;j++)
{//
x=...;
y=...;
//
curPoints[j].X=x;
curPoints[j].Y=y;
}

graphics.DrawClosedCurve(&pen,curPoints,i_Points);
还是说Point *curPoints = new Point [i_Points];这样创建Point数组行不通?
howard 2006-04-04
  • 打赏
  • 举报
回复
。。。。。。。。天啊,居然是大写的X和Y。哎~~~~~~~~~

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧