Here is what I'd like to achieve:
- draw something in a canvas using the API functions, let's say a line
- retrieve the pixel data I just drew
- post process by iterating the pixels
- draw the new pixels back in the canvas
I was thinking about doing:
- Code: Select all
pixels = new int[mWidth * mHeight];
mBitmap = Bitmap.createBitmap(mWidth , mHeight, Bitmap.Config.ARGB_8888);
mBitmapPaint = new Paint(Paint.DITHER_FLAG);
then in my draw function:
- Code: Select all
c.setBitmap(mBitmap);
c.drawLine(start.x, start.y, end.x, end.y, mPaint);
mBitmap.getPixels(pixels, 0, mWidth, 0, 0, mWidth, mHeight);
for(int i = 0; i < mWidth * mHeight; i++)
{
pixels[i] = ...;
}
c.drawBitmap(pixels, 0, mWidth, 0, 0, mWidth, mHeight, false, mBitmapPaint);
But there is nothing in my bitmap after the drawLine...
If I just fill the bitmap with a color in my for loop and then draw it, no problem. The problem is to retireve a bitmap containing the line I drew.
Any idea how to do it?
Thanks a lot!


