FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TImage zoom
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
TImage zoom
Posted: Wed Apr 06, 2016 03:56 PM

There is a TImage object (not xImage). As you can zoom/unzoom it ?

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 06:49 PM

look samples\ximage01.prg

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 07:10 PM
Cristobal,

it is \samples\BMPALPHA.prg testing ZOOM and ALPHALEVEL.



best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 07:36 PM
Uwe, sorry, XImage01.prg, not?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 07:42 PM
Cristobal YES as well the same functions but the question was :

His question :
There is a TImage object (not xImage). As you can zoom/unzoom it ?

I think the solution he is looking for ( from : BMPALPHA.prg ) :

@ 0,0 BITMAP oBmp FILENAME cFile OF oWnd ;
PIXEL SCROLL
oBmp:nAlphaLevel := 100
oBmp:bAlphaLevel := {| oBmp | if( oBmp:nZoom > 2, oBmp:nAlphaLevel := 255, oBmp:nAlphaLevel:= oBmp:hAlphaLevel ) }
oBmp:bLDblClick = {|| SAVE2PNGFILE( oBmp:hBitmap, "prueba.png" ), MsgInfo( "saved to prueba.png") }

// ------------ or

#include "Image.ch"

@ 0,0 IMAGE oImg FILENAME cFile OF oWnd ;

// -------------

best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 07:43 PM
Uwe, Sorry, I have not understood your message
With Scroll mouse

Natter wrote:There is a TImage object (not xImage). As you can zoom/unzoom it ?


Uwe, YES, you are right, :-) :-) :-)

Regards
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: TImage zoom
Posted: Wed Apr 06, 2016 08:03 PM

I did zoom to TImage using StretchBlt(), but unzoom does not work

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: TImage zoom
Posted: Wed Apr 06, 2016 08:19 PM
Not possible using :

define button prompt "+ zoom" of oBar action( oImg:nZoom++, oImg:refresh() ) CENTER
define button prompt "- zoom" of oBar action( oImg:nZoom--, oImg:refresh() ) CENTER

OR :

local oImage, oBrush, aRect := oDlg:GetRect()
DEFINE IMAGE oImage FILENAME "..\bitmaps\pngs\chart.png"
oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) ) // 1 = stretch, 2 : fitoutside, 3:fitinside
oImage:End()
oDlg:SetBrush( oBrush )
oBrush:End()

define a new size and
REDO using the original aRect

best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: TImage zoom
Posted: Thu Apr 07, 2016 09:10 AM

oImg:nZoom++/oImg:nZoom++, oImg:refresh() - for TImage not work

Use a brush good idea, but I was not able to interactively change its size.

Probably for zoom/unzoom you can use SaveWindow. Save need rectangl context in BMP, and then load in TImage

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: TImage zoom
Posted: Thu Apr 07, 2016 01:09 PM
I remember some month ago,
I created a tool to zoom a image on top of another image
It works fine with TImage
ZOOM and RESET on buttonaction

The complete download :
http://www.pflegeplus.com/DOWNLOADS/Imgzoom3.zip

My tests RESET, ZOOM + and ZOOM -









best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: TImage zoom
Posted: Thu Apr 07, 2016 02:20 PM

Beautiful, but not exactly what I wanted. My TImage stretch to fit the dialog. I would like to cut, more or less, TImage rectangle and stretch it to fit the dialog.

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TImage zoom
Posted: Thu Apr 07, 2016 02:52 PM
There is a TImage object (not xImage). As you can zoom/unzoom it ?

Yes, TImage has a Method Zoom( nZoom )
not exactly what I wanted. My TImage stretch to fit the dialog. I would like to cut, more or less, TImage rectangle and stretch it to fit the dialog.

Keep aside classes like TImage or TXImage. Please explain what exactly you want to do. May be there is totally a different and simpler way to achieve what you want.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: TImage zoom
Posted: Thu Apr 07, 2016 03:27 PM

There is a picture. It is larger than the screen (so I show it in TImage stretch to full screen) . I would like to cut a larger or smaller rectangle of the picture and stretch it to fit the window (something similar is done in the example zoom2.prg)

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: TImage zoom
Posted: Thu Apr 07, 2016 08:55 PM
Please try the idea of brush again but this way.

Code (fw): Select all Collapse
   DEFINE BRUSH oBrush FILE "olga1.jpg" RESIZE  // use your image file
   DEFINE WINDOW oWnd BRUSH oBrush  // window or dialog of your specified size
   ACTIVATE WINDOW oWnd CENTERED
   RELEASE BRUSH oBrush


1) The image is zoomed/unzoomed just enough to cover the entire area of the window or dialog without distorting the proportion and crops the image to the extent required.

2) When used on window, the image is also resized automatically when the window is resized.

Please try the code first and decide if this serves your purpose.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: TImage zoom
Posted: Fri Apr 08, 2016 04:57 PM

Thanks for the help. This program is quite normal increases/decreases the image

oImg:=TImage():New(...)
oImg:Progress(.F.)
oImg:Cargo:=0
oImg:bMouseWheel = {| nKey, nDelta, nXPos, nYPos | Test()}

procedure Test(nDelta)
local cnt
local nWidth, nHeight // The sizes TImage on dialog
local hDC

if (nDelta<0.and.oImg:Cargo-1>=0).or. (nDelta>0.and.oImg:Cargo+1<=14)
if oImg:Cargo!=0.and.nDelta<0
oImg:Refresh()
Vrt_Dlg()
endif
hDC:=GetDC(oImg:hWnd)

cnt:=oImg:Cargo+=iif(nDelta&lt;0, -1, 1)

StretchBlt( hDC, 0, 0, nWidth, nHeight, ;
                                   hDC, ;
                          30*cnt, 30*cnt, ;
                      nWidth-(30*cnt*2), ;
           nHeight-(30*cnt*2), 13369376 )

oImg:ReleaseDC()

endif
RETURN

procedure Vrt_Dlg
local oVrt

DEFINE DIALOG oVrt FROM 0,0 TO 0,0 PIXEL
ACTIVATE DIALOG oVrt ON INIT oVrt:End()
return

Continue the discussion