TImage zoom

Post Reply
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

TImage zoom

Post by Natter »

There is a TImage object (not xImage). As you can zoom/unzoom it ?
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: TImage zoom

Post by cnavarro »

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
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TImage zoom

Post by ukoenig »

Cristobal,

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

Image

best regards
Uwe :D
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.
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: TImage zoom

Post by cnavarro »

Uwe, sorry, XImage01.prg, not?

Image
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
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TImage zoom

Post by ukoenig »

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 :D
Last edited by ukoenig on Wed Apr 06, 2016 7:59 pm, edited 6 times in total.
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.
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: TImage zoom

Post by cnavarro »

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, :D :D :D

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
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Post by Natter »

I did zoom to TImage using StretchBlt(), but unzoom does not work
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TImage zoom

Post by ukoenig »

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.
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Post by Natter »

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
User avatar
ukoenig
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: TImage zoom

Post by ukoenig »

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 -

Image

Image

Image

Image

best regards
Uwe :D
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.
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Post by Natter »

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.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: TImage zoom

Post by nageswaragunupudi »

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
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Post by Natter »

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)
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: TImage zoom

Post by nageswaragunupudi »

Please try the idea of brush again but this way.

Code: Select all | Expand

  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
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Post by Natter »

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<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
Post Reply