title: BoundingBox pixel coordinates for OSM
body: <p>I have the lat/lon for the two BoundingBox corners
  and I need to get the "Projection.toPixels()" for those two
  points for use with OpenStreetMap.</p>
  
  <p>I already have the basic functions, like getting the Tile
  numbers for a lat/lon location, and given a lat/lon in a Tile
  getting the X and Y pixels, but I can't find any code that
  will help solve my BoundingBox problem.</p>
  
  <p>It's a large BoundingBox, and usually, at zoom 8, the Tiles
  with the BoundingBox points, are outside the normal display grid of Tiles
  for the display, so the point on the "left" is something like X: -169 Y: -343
  and the point on the "right" is like X: 841  Y: 849</p>
  
  <p>So I need a formula, given the lat/lon of the BoundingBox corner
  points, and end up with rectangle points like the above pixel offsets.</p>
  
  <p>Currently I'm using Google Maps, and I can get it's version of the
  BoundingBox points with "Projection.toPixels()" basically, but I'm
  converting to use OpenStreetMap.  They are both based on 256 X 256 tiles,
  and use the same Projection, but I don't want to use any Google Maps API calls to do it.</p>
  
  <p>I have seen some Google Maps like source in JavaScript that looks pretty good, but nothing about using BoundingBox.</p>
  
  <p>I already have the display center lat/lon,
  zoom level 8, and other needed data, but not the needed formula(s).</p>
  
  <p>The goal is to call an Android draw() function like:</p>
  
  <pre><code>canvas.drawBitmap(
      imageBitmap,    // bitmap
      null,           // src rect
      BBRect,         // dest rect
      paint);     // paint
  </code></pre>
  
  <p>I'd like to see code that's similar to Java so I can understand it
  enough to convert it if needed.</p>
  
  <p>Thanks!</p>