I'm trying to figure out the best way to get the pixel color value at a given point on a View. There are three ways that I write to the View:
I set a background image with View.setBackgroundDrawable(...).
I write text, draw lines, etc., with Canvas.drawText(...), Canvas.drawLine(...), etc., to a Bitmap-backed Canvas.
I draw child objects (sprites) by having them write to the Canvas passed to the View's onDraw(Canvas canvas) method.
Here is the onDraw() method from my class that extends View:
@Override
public void onDraw(Canvas canvas) {
// 1. Redraw the background image.
super.onDraw(canvas);
// 2. Redraw any text, lines, etc.
canvas.drawBitmap(bitmap, 0, 0, null);
// 3. Redraw the sprites.
for (Sprite sprite : sprites) {
sprite.onDraw(canvas);
}
}
What would be the best way to get a pixel's color value that would take into account all of those sources?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…