在android中,对于file中存储的point(x,y),如何把point (x,y)提取到画布上,,并使各坐标点用线连接起来?
求大神指点一下,谢谢file中的坐标点集合point(x,y)是原来由画布上的手绘的图像生成,请问如何用datainputstream将file中的point(x,y)从...
求大神指点一下,谢谢
file中的坐标点集合point(x,y)是原来由画布上的手绘的图像生成,请问如何用datainputstream将file中的point(x,y)从新输入到画布上,使原来的图像复原? 展开
file中的坐标点集合point(x,y)是原来由画布上的手绘的图像生成,请问如何用datainputstream将file中的point(x,y)从新输入到画布上,使原来的图像复原? 展开
1个回答
展开全部
public void onDraw() {
Canvas canvas = mSurfaceHolder.lockCanvas();
canvas.drawColor(Color.WHITE);
if (mSurfaceHolder == null || canvas == null) {
return;
}
/*Paint xPaint = new Paint();
xPaint.setAntiAlias(true);
xPaint.setColor(Color.BLACK);
canvas.drawLine((screenWidth/2) ,0 , (screenWidth/2) , screenHeight , xPaint);
canvas.drawLine(0 ,(screenHeight/2) , screenWidth , (screenHeight/2) , xPaint);*/
Paint mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(Color.BLUE);
for(int i = 0;i < path1.size() ;i++)
{
Node p = (Node) path1.get(i);
if(0 == i)
canvas.drawCircle(p.getx()*10, p.gety()*10, 2, mPaint);
else
{
Node p2 = (Node) path1.get(i-1);
canvas.drawCircle((screenWidth/2)-p.getx(), (screenHeight/2)-p.gety(), 2, mPaint);
//canvas.drawLine((screenWidth/2)-p2.getx(), (screenHeight/2)-p2.gety(), (screenWidth/2)-p.getx(), (screenHeight/2)-p.gety() ,mPaint);
}
}
}
首先是声明一个Canvas 画布,然后调用DrawLine()函数就可以了。DrawLine()函数三个参数,第一个参数是起点,第二个是终点,第三个是颜色值。。。网上demo,自己可以去找找。
Canvas canvas = mSurfaceHolder.lockCanvas();
canvas.drawColor(Color.WHITE);
if (mSurfaceHolder == null || canvas == null) {
return;
}
/*Paint xPaint = new Paint();
xPaint.setAntiAlias(true);
xPaint.setColor(Color.BLACK);
canvas.drawLine((screenWidth/2) ,0 , (screenWidth/2) , screenHeight , xPaint);
canvas.drawLine(0 ,(screenHeight/2) , screenWidth , (screenHeight/2) , xPaint);*/
Paint mPaint = new Paint();
mPaint.setAntiAlias(true);
mPaint.setColor(Color.BLUE);
for(int i = 0;i < path1.size() ;i++)
{
Node p = (Node) path1.get(i);
if(0 == i)
canvas.drawCircle(p.getx()*10, p.gety()*10, 2, mPaint);
else
{
Node p2 = (Node) path1.get(i-1);
canvas.drawCircle((screenWidth/2)-p.getx(), (screenHeight/2)-p.gety(), 2, mPaint);
//canvas.drawLine((screenWidth/2)-p2.getx(), (screenHeight/2)-p2.gety(), (screenWidth/2)-p.getx(), (screenHeight/2)-p.gety() ,mPaint);
}
}
}
首先是声明一个Canvas 画布,然后调用DrawLine()函数就可以了。DrawLine()函数三个参数,第一个参数是起点,第二个是终点,第三个是颜色值。。。网上demo,自己可以去找找。
更多追问追答
追问
恩,谢谢!file中的坐标点集合point(x,y)是原来由画布上的手绘的图像生成,请问如何用datainputstream将file中的point(x,y)从新输入到画布上,使原来的图像复原?
追答
Java文件读写,然后类型转换
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询