Hi.
--- In [email protected], "swzoh" <[EMAIL PROTECTED]> wrote:
> 1 pixel up and 2 pixel down is 2 pixel, not 3
> pixel?

Uhm, yes. Or not?

> Anyway, adding 1 pixel really improves the behavior. So, possibly 
my
> conception of pixel is wrong, I tend to think pixel as a 
mathematical
> point which I always felt may not be quite correct.

It might be close to a mathematical point because it is very small 
but to me it is not a point, because it takes some physical space. 
It has width of 1 pixel and a height of 1 pixel.

OK. I thought this over a bit and here is my approach:
I'd try to avoid any dividing to avoid rounding mistakes and to get 
an exactly enlarged picture.
So starting from the smallest I define a radius of pixels 
surrounding the pixel that the mouse is over:
local nRadius=10
Then I define a zoom factor, e.g.:
local nZoom=5
The width and height of the scanned square is then: nRadius*2+1 (+1 
is the pixel that the mouse is over)
I get the width and height of the zoomed square as:
local nRect=(nRadius*2+1)*nZoom
where every original pixel is 5x5 pixel big.

Now the centered cursor is over the left top pixel of the enlarged 
pixel. Why? I think the problem is that the reference point of the 
scaling of the image is not its center but its left top. So I shift 
the zoomed picture half the zoom-factor up and left (OK, in case of 
a zoom factor of 5, I take 3), to get over the center of the zoomed 
pixel. This is my offset:
local nOff=nZoom/2+1
which I also subtract from the width and height of the window to 
avoid a margin. So basically I get:

hWnd.size(nRect-nOff,nRect-nOff)
for(!mouseleft)
hWnd.move(xmouse-nRadius*nZoom,ymouse-nRadius*nZoom)
dll.call("StretchBlt|ui i i i i ui i i i i ui",;;+
hDC_TT,nOff*-1,nOff*-1,nRect,nRect,;;+
hDC_SC,xmouse-nRadius,ymouse-nRadius,;;+
nRadius*2+1,nRadius*2+1,0xCC0020)
endfor

Maybe still not 100 percent, but looks pretty right to me.

Mockey








Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to