Magnifyer

Magnifyer

Postby Marc Vanzegbroeck » Thu Aug 30, 2007 9:25 pm

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

Postby Antonio Linares » Thu Aug 30, 2007 10:15 pm

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

Postby Marc Vanzegbroeck » Fri Aug 31, 2007 6:22 am

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

Postby Antonio Linares » Fri Aug 31, 2007 6:24 am

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

Postby Marc Vanzegbroeck » Fri Aug 31, 2007 6:34 am

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

Postby Antonio Linares » Fri Aug 31, 2007 7:01 am

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

Re: Magnifyer

Postby NK » Fri Aug 31, 2007 9:44 am

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

Postby Antonio Linares » Fri Aug 31, 2007 11:12 am

Norberto,

Very good! Thanks :-)

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42103
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Marc Vanzegbroeck » Fri Aug 31, 2007 12:25 pm

Thanks Norberto,

I will try it.

Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby James Bott » Fri Aug 31, 2007 3:08 pm

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

Start-Accessories-Accessability-Magnifier


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

Postby Marc Vanzegbroeck » Thu Sep 06, 2007 10:10 am

Hi,

Can anyone tell me why this is not working?

Code: Select all  Expand view  RUN
#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  Expand view  RUN
FUNCTION test()
   mzoom()
RETURN nil

Then it's working.

I want to call it from another window.
Thanks,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Postby NK » Thu Sep 06, 2007 11:32 am

Change your function mzoom and it works. the problem was the timer-deactivate.

regards, Norbert

Code: Select all  Expand view  RUN
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
User avatar
NK
 
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany

Postby Marc Vanzegbroeck » Thu Sep 06, 2007 1:21 pm

Thanks Norbert, It's working fine now.

Regards,
Marc
Marc Vanzegbroeck
 
Posts: 1159
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 43 guests