我在做像window画板中的颜色填充工具,我用的是这个算法:
public void Boundary(float x,float y,int boundaryvalue,int newvalue){
if(GetPixel(x,y)!=boundaryvalue&&GetPixel(x,y)!=newvalue){
SetPixel(x,y,newvalue);
Boundary(x, y-1, boundaryvalue, newvalue);
Boundary(x, y+1, boundaryvalue, newvalue);
Boundary(x-1, y, boundaryvalue, newvalue);
Boundary(x+1, y, boundaryvalue, newvalue);
}
}
但Canvas中没有GetPixel和SetPixel这两个函数。我想问的是,怎么样才能获得Canvas中的一个点的颜色值。
public void Boundary(float x,float y,int boundaryvalue,int newvalue){
if(GetPixel(x,y)!=boundaryvalue&&GetPixel(x,y)!=newvalue){
SetPixel(x,y,newvalue);
Boundary(x, y-1, boundaryvalue, newvalue);
Boundary(x, y+1, boundaryvalue, newvalue);
Boundary(x-1, y, boundaryvalue, newvalue);
Boundary(x+1, y, boundaryvalue, newvalue);
}
}
但Canvas中没有GetPixel和SetPixel这两个函数。我想问的是,怎么样才能获得Canvas中的一个点的颜色值。
解决方案 »
- app 自动关闭,求解
- android 2.2如何完全退出程序??
- Android WebView如何打开Doc、Excel、PDF类似的文件???
- 亲们!android应用层开发与应用程序开发的区别?
- android手机无法调用pc机上的webservice
- TextView 中text 字符串换行问题
- Android手机通过Wifi与PC机之间进行通信问题 (有代码)
- 使用Javacv和Javacpp混淆打包出现报错
- 点击button后如何变换背景?再点击一次后,就变换回来??(求源码)
- 用c++写安卓程序,怎么进行编码转换,GBK和UTF-8互相转换
- SQLite中怎么写有条件的查询啊?
- 怎么给tabhost放初始值
The Canvas class holds the "draw" calls. To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a paint (to describe the colors and styles for the drawing). Canvas提供的画图的方法本身不存储像素内容,存储像素内容的是和他绑定的Bitmap对象,Bitmap才保存像素有getPixel方法楼主的结贴率也是个问题!