Using below code for scrolling I have a Surfaceview stream and a canvas bitmap that is generated (changed), the first line (line), each frame, and then one position (line) is copied down to a regular bitmap to view the scroll, and then I continue to draw other things on top of this. Well, that’s what I really want, however I cannot get it to work, although I am creating a separate canvas for a bitmap without a screen. It just isn't scrolling.
In other words, I have a memory bitmap that is the same size as the Surfaceview canvas, which I need to scroll (shift) one line in each frame, and then replace the top line with a new random texture, and then draw it on a regular Surfaceview canvas.
Here is what I thought would work;
My surfaceChanged, where I point the bitmap and the canvas and start the stream:
@Override
public void surfaceCreated(SurfaceHolder holder) {
intSurfaceWidth = mSurfaceView.getWidth();
intSurfaceHeight = mSurfaceView.getHeight();
memBitmap = Bitmap.createBitmap(intSurfaceWidth, intSurfaceHeight,
Bitmap.Config.ARGB_8888);
memCanvas = new Canvas(memCanvas);
myThread = new MyThread(holder, this);
myThread.setRunning(true);
blnPause = false;
myThread.start();
}
My thread showing only the middle part:
@Override
public void run() {
while (running) {
c = null;
try {
c = myHolder.lockCanvas(null);
synchronized (mSurfaceHolder) {
Rect src = new Rect(0, 0, intSurfaceWidth, intSurfaceHeight - 1);
Rect dst = new Rect(0, 1, intSurfaceWidth, intSurfaceHeight);
memCanvas.drawBitmap(memBitmap, src, dst, null);
textureBitmap = Bitmap.createBitmap(imgTexture, 0, rnd.nextInt(intTextureImageHeight), intSurfaceWidth, 1);
memCanvas.drawBitmap(textureBitmap,
intSurfaceWidth, 0, null);
c.drawBitmap(memBitmap, 0, 0, null);
} finally {
if (c != null) {
myHolder.unlockCanvasAndPost(c);
}
}
}
}
Tunnel Run, https://market.android.com/details?id=com.zubima.TunnelRun, , , , , . 50 , , , .