Magnifyer
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Magnifyer
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
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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
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.
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
look this: http://www.canalfive.com/modules.php?na ... etit&lid=7Marc 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
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact:
Hi,
Can anyone tell me why this is not working?
If I change the test() to
Then it's working.
I want to call it from another window.
Thanks,
Marc
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
Code: Select all
FUNCTION test()
mzoom()
RETURN nil
I want to call it from another window.
Thanks,
Marc
Change your function mzoom and it works. the problem was the timer-deactivate.
regards, Norbert
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
-
- Posts: 1102
- Joined: Mon Oct 17, 2005 5:41 am
- Location: Belgium
- Contact: