Magnifyer

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Magnifyer

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
NK
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany
Contact:

Re: Magnifyer

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Norberto,

Very good! Thanks :-)

yes, it was StretchBlt() instead of BitBlt() to magnify it
regards, saludos

Antonio Linares
www.fivetechsoft.com
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post by Marc Vanzegbroeck »

Thanks Norberto,

I will try it.

Marc
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Windows comes with a magnifier program (at least XP does).

Start-Accessories-Accessability-Magnifier


James
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post 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
User avatar
NK
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany
Contact:

Post 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 
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Post by Marc Vanzegbroeck »

Thanks Norbert, It's working fine now.

Regards,
Marc
Post Reply