title: Component sizes in Delphi Android
body: <p>I am creating an Android app in Delphi XE5 using Firemonkey, and for one of my forms I need a TImage that will fill the entire form where I can draw on it's Bitmap. </p>
  
  <p>What I did was this:</p>
  
  <ol>
  <li><p>I added a TImage component to my form and set it's Align := alClient. In the designer it fills the entire form.</p></li>
  <li><p>In my FormCreate procedure I initialized the Bitmap of the TImage by setting it's size to the size of the TImage</p>
  
  <pre><code>procedure TDrawForm.FormCreate(Sender: TObject);
  begin
      Image1.Bitmap.SetSize(Trunc(Image1.Width), Trunc(Image1.Height));
      DrawFromList(Image1);
  end;
  </code></pre></li>
  <li><p>Then I draw on the TImage's Bitmap.Canvas</p>
  
  <pre><code>procedure TDrawForm.DrawFromList(image: TImage);
  var draw: TDraw;
  begin
     image.Bitmap.Canvas.BeginScene;
     image.Bitmap.Canvas.Clear(claBlue);
     image.Bitmap.Canvas.Stroke.Color := claBlack;
     image.Bitmap.Canvas.Fill.Color := claYellow;
     for draw in DrawList do
     begin
        image.Bitmap.Canvas.FillPath(draw.fpath, 1);
        image.Bitmap.Canvas.DrawPath(draw.fpath, 1);
     end;
     image.Bitmap.Canvas.EndScene;
  end;
  </code></pre></li>
  </ol>
  
  <p>This code draws just fine on my Nexus 7 tablet, but it does not fill the entire screen:</p>
  
  <p><img src="https://i.stack.imgur.com/P83B5.png" alt="enter image description here"></p>
  
  <p>In the second picture I used</p>
  
  <pre><code>Image1.Bitmap.SetSize(Trunc(Image1.Width * 1.34), Trunc(Image1.Height * 1.34));
  </code></pre>
  
  <p>where 1.34 was found by trial and error, to make it fill the entire screen.</p>
  
  <p>I then tried to print out the size of the image and the screen. For my Nexus 7 (which is 1280 x 800 pixels) the TImage component which fills the entire screen, has a width of 601 and a height of 880. Thus, when I set the size of the Bitmap to be the size of my TImage, the Bitmap is also 601 x 880, which explains why I needed to scale the Bitmap to make it fill the entire screen. The screen size is reported as 600 x 905 (using Screen.Size).</p>
  
  <p><strong>My question is</strong> why is the size of the TImage component only 601 x 880 (and the screen only 600 x 905) when the actual resolution of my device is 800 x 1280? If these sizes are not pixels, then what are they? And more importantly, how do I convert from these numbers to actual screen pixels (bear in mind, 1.34 only works for Nexus 7 - on my HTC Sensation it needed to be even bigger)? </p>
  
  <p>One of my co-workers suggested that it might have to do with the DPI of the screen, but I couldn't find any method that will give me the DPI of the current device.</p>
  
  <p>I have also tried updating the size of the bitmap in the FormResize procedure, but that doesn't make a difference.</p>