Yes. But if it's 'a problem', it's one entirely of your own making. It seems extremely unlikely that the user of your application will not be familiar with the restrictions of background imaging or that, in this knowledge, they will be choosing an image which is hopelessly unsuitable for the dimensions of the window. The last thing they will expect is to have your arbitrary slicing imposed on them. Apart from anything else, why do you assume that the interest in every image is focused on the centre? In fact it's very poor composition to have the focus slap bang in the middle as any half decent photographer will tell you.Hope I'm clear defining my problem.
As a user, I am deeply annoyed by anything that purports to be a choice but turns out not to be. Instead of dictating format, how about you let the user decide for themselves what is the most pleasing way to display their image? The truth is that, unless the form is entirely bereft of controls (in which case what's the point of it?) the vast majority of users elect to have no background image when given the choice. Unless the image is specifically adapted to be 'interesting' in all the places where controls do not obscure it it's little more than distraction!
There really isn't any difficulty in determining the largest rectangle possible as one of it's dimension will be equal to either the length or width of the original bitmap. Simply test the aspect ratio against the length and width and choose the one that fits. Centring the cropped dimension is equally easy. Divide the difference between the rectangle dimension and the bitmap dimension, divide by 2 and move the rectangle toward the centre by that distance. But just because you can, doesn't mean you should!




Reply With Quote