That worked!

Could you explain why that worked, but the original code didn't?

I had extended Drawable (not a View) and overridden its draw method.
Here is the code that works:

        public void draw(Canvas canvas) {
                if (bitmap != null) {
                        canvas.drawBitmap(bitmap, m, null);
                        return;
                }

                Canvas singleUseCanvas = new Canvas();
                bitmap = Bitmap.createBitmap(canvas.getWidth(), 
canvas.getHeight(),
Bitmap.Config.ARGB_8888);
                singleUseCanvas.setBitmap(bitmap);
                for (int y = 0, maxY = canvas.getHeight(); y < maxY; 
y+=cellSize) {
                        for (int x = 0, maxX = canvas.getWidth(); x < maxX; 
x+=cellSize) {
                                int color = r.nextInt(0xffffff) + 0xff000000;
                                cr.draw(singleUseCanvas, color, x, y);
                        }
                }
                canvas.drawBitmap(bitmap, m, null);
        }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to