Page 1 of 1

TImage zoom

PostPosted: Wed Apr 06, 2016 3:56 pm
by Natter
There is a TImage object (not xImage). As you can zoom/unzoom it ?

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 6:49 pm
by cnavarro
look samples\ximage01.prg

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 7:10 pm
by ukoenig
Cristobal,

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

Image

best regards
Uwe :D

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 7:36 pm
by cnavarro
Uwe, sorry, XImage01.prg, not?

Image

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 7:42 pm
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

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 7:43 pm
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

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 8:03 pm
by Natter
I did zoom to TImage using StretchBlt(), but unzoom does not work

Re: TImage zoom

PostPosted: Wed Apr 06, 2016 8:19 pm
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 :?:

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 9:10 am
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

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 1:09 pm
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

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 2:20 pm
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.

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 2:52 pm
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.

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 3:27 pm
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)

Re: TImage zoom

PostPosted: Thu Apr 07, 2016 8:55 pm
by nageswaragunupudi
Please try the idea of brush again but this way.

Code: Select all  Expand view
  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.

Re: TImage zoom

PostPosted: Fri Apr 08, 2016 4:57 pm
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