I am creating a mind game based upon pictures . So i have to add a Matrices of images . I m using the surface view to run my thread so as to draw the content on to the screen by locking the screen to the canvas and bitmaps will be drawn inside the canvas . Here is my code . There is no error but a blank screen is displayed . What should i do ? Get me a solution
public class InsideSurface extends SurfaceView implements Runnable {
SurfaceHolder ourHolder;
int start;//starting position to draw
int im_wd;//width of the bitmap
int im_ht;//height of the bitmap
int i = 0;
public InsideSurface(Context context) {
super(context);
// TODO Auto-generated constructor stub
getStart();
ourHolder = getHolder();
}
private void getStart() {
// TODO Auto-generated method stub
start = (width % 100) / 2;
im_wd = (width - (width % 100)) / 4;
im_ht = (width - (width % 100)) / 4;
}
@Override
public void run() {
// TODO Auto-generated method stub
Bitmap bmp;
if (!ourHolder.getSurface().isValid()) {
Canvas canvas = ourHolder.lockCanvas();
canvas.drawARGB(20, 50, 60, 120);
for (int x = 0, tempy = start; x < 4; x++, tempy += im_ht) {
for (int y = 0, tempx = start; y < 4; y++, tempx += im_wd) {
bmp = BitmapFactory.decodeResource(getResources(),
image[i++]);
canvas.drawBitmap(bmp, tempx, tempy, null);
}
}
ourHolder.unlockCanvasAndPost(canvas);
}
}
}