Is this right or wrong?
-
I have an offscreen image, I have inverted the coordinates in the vertical axis so 0,0 is bottom left. I have a visible area that uses the normal coordinate system.
I have a slider that enables me to change the section of the image to transfer from offscreen to the visible area and min and max spinners to set the maximum and minimum areas to captured from the offscreen. The offscreen image is 81 pixels wide and 2000 pixels high. The visible area is 81 wide and 492 high.
The image from is transferred from offscreen to visible with:
QPainter objVisible(this); QRect rctSection(0, intOnViewMin, rctOffscreen.width(), intSpanOnView); QSize szSource(rctWorking.width(), rctWorking.height()); QImage imgStrip(mpOffscreen->toImage()), imgSection(imgStrip.copy(rctSection).scaled(szSource)); objVisible.drawImage(QPoint(0, 0), imgSection);
As far as I can see the image is initially perfect and scaled correctly, if I change the maximum spinner taking 10 off it, it seems that the image transferred is not from the bottom but from the top. I've tried inverting rctSection this doesn't work.
As an example, when I start before changing anything:
The max spinner is set to 2000 and the min spinner is set to 0.
rctSection is x: 0, y: 0, width: 86, height: 2000
szSource width: 86, height: 492
At this stage the image transferred is perfect.If I change the max spinner to 1990.
rctSection is x: 0, y: 0, width: 86, height: 1990
szSource width: 86, height: 492
But now the image is copied not from the bottom up but from the top down.I can see where the problem is, its because the coordinate system of the original image is inverted and when I'm copying the image its copying from top down with 0,0 at top left instead of at the bottom. Now I have to figure out what to do.
I have to offset rctSection by the delta which will be the difference between the height of the offscreen image and the maximum value in the spinner.