Page 1 of 1
Magnifyer
Posted: Thu Aug 30, 2007 9:25 pm
by Marc Vanzegbroeck
Hi,
Is there a 'Magnifyer' class available?
My program is generating drawings. Sometimes here al lot of lines on it and now I use the metafile-class, and with the zoom function I zoom in. But then I have to scroll with the scroll-bars. It would be nicer to have a magnifyer, that only magnify a piece of the screen and can be moved by the mouse. I know that there are seperate programs to do that , but I want to have it integrated inmy program.
Thanks,
Marc
Posted: Thu Aug 30, 2007 10:15 pm
by Antonio Linares
Marc,
Its not very complicated to implement a magnifier for a bitmap, but it is complicated to do it for a metafile, as a metafile is not a bitmap: It is "vectorial" drawings (like freehand, CorelDraw, etc. drawings) and in this case the contents of the metafile have to be interpreted
Posted: Fri Aug 31, 2007 6:22 am
by Marc Vanzegbroeck
Antonio,
Is it to possible to write some kind of function that 'read' the status of the pixels displayed on the screen.
Then it's possible to display it bigger.
Marc
Posted: Fri Aug 31, 2007 6:24 am
by Antonio Linares
Marc,
Yes, it is possible, but that won't help to see a clearer metafile, because the metafile contents are "drawing instructions", not pixels.
Posted: Fri Aug 31, 2007 6:34 am
by Marc Vanzegbroeck
Antonio,
Now I first check the resolution of the screen and then make the lines that they are just 1 pixel. If we could 'read' the screen and then display it that the screen is 2 times bigger and the lines have a thickness of 2 pixels, would be nice.
Marc
Posted: Fri Aug 31, 2007 7:01 am
by Antonio Linares
Marc,
To build a magnifier simply use GetPixel( hDC, nXPos, nYPos ) --> nRGBColor to read the pixels and SetPixel( hDC, nXPos, nYPos, nRGBColor ) to paint them.
If you read 1 pixel, then you could write four pixels for it. This way you magnify the image.
There is a way to speed up this process, using BitBlt(), so you don't have to process pixel by pixel, instead you manage all of them at one time.
Keep in mind that this will only work on bitmaps. Metafiles won't benefit.
Re: Magnifyer
Posted: Fri Aug 31, 2007 9:44 am
by NK
Marc Vanzegbroeck wrote:Hi,
Is there a 'Magnifyer' class available?
My program is generating drawings. Sometimes here al lot of lines on it and now I use the metafile-class, and with the zoom function I zoom in. But then I have to scroll with the scroll-bars. It would be nicer to have a magnifyer, that only magnify a piece of the screen and can be moved by the mouse. I know that there are seperate programs to do that , but I want to have it integrated inmy program.
Thanks,
Marc
look this:
http://www.canalfive.com/modules.php?na ... etit&lid=7
Posted: Fri Aug 31, 2007 11:12 am
by Antonio Linares
Norberto,
Very good! Thanks
yes, it was StretchBlt() instead of BitBlt() to magnify it
Posted: Fri Aug 31, 2007 12:25 pm
by Marc Vanzegbroeck
Thanks Norberto,
I will try it.
Marc
Posted: Fri Aug 31, 2007 3:08 pm
by James Bott
Windows comes with a magnifier program (at least XP does).
Start-Accessories-Accessability-Magnifier
James
Posted: Thu Sep 06, 2007 10:10 am
by Marc Vanzegbroeck
Hi,
Can anyone tell me why this is not working?
Code: Select all
#include "fivewin.ch"
FUNCTION test()
local oMWnd
DEFINE WINDOW oMWnd TITLE "test"
oMWnd:blClicked := {|nRow, nCol, nKeyFlags| ;
mzoom()}
ACTIVATE WINDOW oMWnd
RETURN nil
FUNCTION mzoom()
local oTimer
local oWnd
local nZoom := 2
DEFINE WINDOW oWnd TITLE "Zoom" FROM 0,0 TO 233,207 PIXEL NOMINIMIZE NOMAXIMIZE
DEFINE TIMER oTimer OF oWnd INTERVAL 50 ACTION GetColor(oWnd,nZoom)
oTimer:Activate()
ACTIVATE WINDOW oWnd
oTimer:DeActivate()
RETURN nil
FUNCTION getcolor(ownd,nzoom)
local hDeskTop := GetDC(0)
local a := GetCursorPos()
local nColor := GetPixel( hDeskTop, a[2], a[1] )
local hDC := oWnd:GetDC()
local nTop := 0
local nLeft := 0
local nWidth := 200
local nHeight := 200
StretchBlt( hDC, nLeft, nTop, nWidth, nHeight, hDeskTop, a[2]-(nWidth/(nZoom*2)), a[1]-(nHeight/(2*nZoom)), nWidth/nZoom, nHeight/nZoom, 13369376 )
oWnd:ReleaseDC()
ReleaseDC( 0, hDeskTop )
RETURN nil
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( STRETCHBLT )
{
hb_retl( StretchBlt( (HDC) hb_parnl( 1 ) ,
hb_parni( 2 ) ,
hb_parni( 3 ) ,
hb_parni( 4 ) ,
hb_parni( 5 ) ,
(HDC) hb_parnl( 6 ) ,
hb_parni( 7 ) ,
hb_parni( 8 ) ,
hb_parni( 9 ) ,
hb_parni( 10 ) ,
(DWORD) hb_parnl( 11 )
) ) ;
}
#pragma ENDDUMP
If I change the test() to
Code: Select all
FUNCTION test()
mzoom()
RETURN nil
Then it's working.
I want to call it from another window.
Thanks,
Marc
Posted: Thu Sep 06, 2007 11:32 am
by NK
Change your function mzoom and it works. the problem was the timer-deactivate.
regards, Norbert
Code: Select all
FUNCTION mzoom(oMWnd)
local oTimer
local oWnd
local nZoom := 2
DEFINE WINDOW oWnd TITLE "Zoom" FROM 0,0 TO 233,207 PIXEL NOMINIMIZE NOMAXIMIZE
DEFINE TIMER oTimer OF oWnd INTERVAL 50 ACTION GetColor(oWnd,nZoom)
oTimer:Activate()
ACTIVATE WINDOW oWnd valid (oTimer:DeActivate(), .t.)
RETURN nil
Posted: Thu Sep 06, 2007 1:21 pm
by Marc Vanzegbroeck
Thanks Norbert, It's working fine now.
Regards,
Marc