Adding overlay image at drag position on a final bitmap - Android
<p>Basic description of what I'm trying to do:
Load up a background image, paint some text into a new bitmap layer, position that text over the background image where I want it to show up, then save the background image with the new layer on top of it where I had positioned it.</p>

<p>Problem:
The problem I'm having is that when I paint the text over the background image it ends up in the wrong x/y position.</p>

<p>For example:
1. I load in a 640x480 image with the ScaleType set to Fit_Start (which shrinks it to 1/2 the size).  I'm keeping track of the ratio and using it when painting the text to the final image.</p>

<ol>
<li><p>Then I create a blank overlay bitmap, paint some text onto it, trim the extra transparent space off, and place it into another imageview (ScaleType of Matrix)</p></li>
<li><p>Then I position that new imageview using my mouse and the onTouchEvent method.  I keep track of the X and Y:</p>

<p>float X = event.getX();</p>

<p>float Y = event.getY() - 50; // Title bar, status bar</p>

<p>overlayView.layout((int)X, (int)Y, overlay.getWidth() + (int)X, overlay.getHeight() + (int)Y);</p></li>
<li><p>Then I attempt to write the text to the final image (background image) using the X &amp; Y except that I double the X &amp; Y since I know that the image was shrunk in half to fit the screen.</p></li>
<li><p>Final result is the text being written to the wrong location.  It ends up being slightly too much X and not enough Y (like 25+ depending on the background image scale -- this varies).</p></li>
</ol>

<p>Somewhere my math is wrong or I'm forgetting to add something into the formula for calculating the correct position on the background where the text should be painted to.  I've been working on this for quite a few hours and haven't been able to pin-pointed the problem.</p>

<p>The last thing I tried was to take into account the title bar and status bar, which on the simulator takes up like 50 pixels.  So, I'm subtracting that from Y, which is done when dragging.  But that still doesn't correct Y being off different amounts depending on the background image dimensions.</p>

<p>Anyone have any ideas on what I'm doing wrong?</p>
