title: Why can't I draw a smaller bitmap into a larger canvas?
body: <p>I have a created a custom view (Display) that accepts non view Icons that create semi static (rarely changing) bitmaps. The idea is to pass a number of Icons to the Display to be printed to its canvas. My problem is that I cannot get the Display to actually draw the Icons bitmap into its canvas. </p>
  
  <p>The code below is a working example of what I have. (by working I mean executes properly, not that it prints what I want it to)</p>
  
  <pre><code>public class AndroidTestoActivity extends Activity {
      @Override public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          FrameLayout fl = new FrameLayout(this);
          Display tv = new Display(this); 
          tv.setLayoutParams(new LayoutParams(200, 200));
          fl.addView(tv);
          setContentView(fl);
      }
  
      public class Display extends View {
          Paint vPaint = new Paint();
          Icon item = new Icon();
  
          public Display(Context context) {
              super(context);
              vPaint.setStyle(Paint.Style.FILL_AND_STROKE);
              vPaint.setColor(0x0ff000000);
              setBackgroundColor(0xffffffff);
          }
  
          @Override public void onDraw(Canvas canvas) {
              canvas.scale(200, 200);
              item.onDraw(canvas);
              canvas.drawLine(0.0f, 0.0f, 1.0f, 1.0f, vPaint);
          }
      }
  
      public class Icon {
          Bitmap myImage;
          Paint mPaint = new Paint();
  
          public Icon() {
              myImage = Bitmap.createBitmap(50, 50, Bitmap.Config.ARGB_8888);
              mPaint.setStyle(Style.FILL);
              mPaint.setColor(0xffff0000);
              Canvas c = new Canvas(myImage);
              c.scale(50, 50);
              c.drawCircle(0.5f, 0.5f, 0.5f, mPaint);
          }
  
          public void onDraw(Canvas canvas) {
              canvas.drawBitmap(myImage, 0, 0, null);
          }
      }
  }
  </code></pre>
  
  <p>This code should be printing out a line from upper-left to lower-right and draw a 50px diameter circle from 0,0 to 50, 50. Instead all I get is the line. However, if I print the bitmap to a file, the file outputs exactly what it should. </p>
  
  <p>Does any one have a clue as to what is happening?</p>
  
  <p><strong>EDIT</strong><br>
  To clarify my question, I am creating a Bitmap that is significantly smaller than the DisplayView. When I attempt to draw the bitmap into the DisplayView, the bitmap is not at all what I drew and never scaled appropriately. Why is the canvas not drawing the Bitmap properly?</p>
  
  <p><strong>UPDATE</strong><br>
  In the Diplay's onDraw method, I moved the line <code>items.onDraw(canvas);</code> to before <code>canvas.scale(200, 200);</code>. Now the test circle draws correctly. What is such a simple change doing to completely ignore drawing the circle the pervious way?</p>