G
gw7rib
I want to show an image in a window, and for this particular option, I
want to keep the aspect ratio the same but otherwise make it as big as
possible. The code I have is as follows:
myGetImageSize(image_file_name, imagewidth, imageheight);
xrat = (double) w / imagewidth;
yrat = (double) h / imageheight;
if (xrat > yrat) xrat = yrat;
myDrawImage(hdc, image_file_name, xrat * imagewidth, xrat *
imageheight);
where imagewidth, imageheight, w, h and the last two parameters to
myDrawImage are ints and xrat and yrat are doubles. This works, but on
compiling I get warnings about converting doubles to ints. Clearly
there are various ways round this, but I was wondering if there was a
particularly neat way of doing it or, if not, what you would
recommend?
Thanks for any suggestions.
Paul.
want to keep the aspect ratio the same but otherwise make it as big as
possible. The code I have is as follows:
myGetImageSize(image_file_name, imagewidth, imageheight);
xrat = (double) w / imagewidth;
yrat = (double) h / imageheight;
if (xrat > yrat) xrat = yrat;
myDrawImage(hdc, image_file_name, xrat * imagewidth, xrat *
imageheight);
where imagewidth, imageheight, w, h and the last two parameters to
myDrawImage are ints and xrat and yrat are doubles. This works, but on
compiling I get warnings about converting doubles to ints. Clearly
there are various ways round this, but I was wondering if there was a
particularly neat way of doing it or, if not, what you would
recommend?
Thanks for any suggestions.
Paul.