我有我画线画布:
//see code upd
我需要做的吸管工具,将颜色从我的画布。 我怎么可能做到吗?
代码UPD:
private static class DrawView extends View
{
...
public DrawView(Context context) {
super(context);
setFocusable(true);
mBitmap = Bitmap.createBitmap(640, 860, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
mPath = new Path();
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
this.setDrawingCacheEnabled(true);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0xFFAAAAAA);
canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
canvas.drawPath(mPath, mPaint);
}
private void touch_up()
{
if(!drBool) //is true when I click pipette button
{
...
mCanvas.drawPath(mPath, mPaint); // lines draw
mPath.reset();
}else{
this.buildDrawingCache();
cBitmap = this.getDrawingCache(true);
if(cBitmap != null)
{
int clr = cBitmap.getPixel((int)x, (int)y);
Log.v("pixel", Integer.toHexString(clr));
mPaint.setColor(clr);
}else{
Log.v("pixel", "null");
}
}
drBool = false;
}
}
我只看到“像素” - “ffaaaaaa”,或者如果我使用mCanvas.drawColor(Color.GRAY)“像素” - “ff888888”