TImage zoom

TImage zoom

Postby Natter » Wed Apr 06, 2016 3:56 pm

There is a TImage object (not xImage). As you can zoom/unzoom it ?
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Postby cnavarro » Wed Apr 06, 2016 6: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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TImage zoom

Postby ukoenig » Wed Apr 06, 2016 7:10 pm

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

Re: TImage zoom

Postby cnavarro » Wed Apr 06, 2016 7:36 pm

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
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TImage zoom

Postby ukoenig » Wed Apr 06, 2016 7: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 :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
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TImage zoom

Postby cnavarro » Wed Apr 06, 2016 7: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, :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
User avatar
cnavarro
 
Posts: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: TImage zoom

Postby Natter » Wed Apr 06, 2016 8:03 pm

I did zoom to TImage using StretchBlt(), but unzoom does not work
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Postby ukoenig » Wed Apr 06, 2016 8: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: TImage zoom

Postby Natter » Thu Apr 07, 2016 9: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
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Postby ukoenig » Thu Apr 07, 2016 1: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 -

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

Re: TImage zoom

Postby Natter » Thu Apr 07, 2016 2: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.
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Postby nageswaragunupudi » Thu Apr 07, 2016 2: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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TImage zoom

Postby Natter » Thu Apr 07, 2016 3: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)
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am

Re: TImage zoom

Postby nageswaragunupudi » Thu Apr 07, 2016 8:55 pm

Please try the idea of brush again but this way.

Code: Select all  Expand view  RUN
  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
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: TImage zoom

Postby Natter » Fri Apr 08, 2016 4: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<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
Natter
 
Posts: 1222
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests