Thank you, I'll give the new version a try.
If you like the idea of calculating the corner coordinates from pixel positions, and going to implement it, I hope you could spare some time using my simple code I wrote to make my calculations:
int x1;
int y1;
double lon1;
double lat1;
int x2;
int y2;
double lon2;
double lat2;
int w;
int h;
int dx = x2 - x1;
int dy = y2 - y1;
if( dx == 0 || dy == 0 ) return;
double kx = ( lon2 - lon1 ) / dx;
double ky = ( lat2 - lat1 ) / dy;
double lon_right = ( w - x1 ) * kx + lon1;
double lon_left = lon2 - x2 * kx;
double lat_bottom = ( h - y1 ) * ky + lat1;
double lat_top = lat2 - y2 * ky;
