Canvas / post-process

Problems with Canvas, OpenGL, etc...

Canvas / post-process

Postby gooze55 » Tue Mar 08, 2011 3:09 pm


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.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!
Once Poster
Once Poster
Posts: 1
Joined: Tue Mar 08, 2011 3:01 pm


Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 4 guests