1

Konu: Formda görüntüyü zoom etmek

Merhaba,
Önceden seçilmiş bir görüntüyü gösteren bir formum var. Tabii bu formda neredeyse formun tümünü kaplayan image kontrolüm var.
Sorduğum ya da yardım rica ettiğim konu şu; bu görüntüyü kontrole sığdırmak yanı sıra %20,30,50,75 ya da %100 gibi değerlerde zoom etmek istiyorum. Bunun için butonlar koyup kullanıcının tıklamasıyla görüntünün bu zoom değerlerinde görünmesini sağlamak istiyorum.
Bu arada; görüntülerin hemen hepsi yüksek çözünürlükte (SLR kamerayla çekilmiş tıbbi görüntüler).

Yardımlarınız için teşekkürler...

2

Re: Formda görüntüyü zoom etmek

Kodun yazarını not almamışım.
Ama fikir vermesi açısından işgörebilir.
Resmin istediğin bölümünü mouse ile seçerek ( bir kutucuk çizerek ) zoomlayabiliyorsun
Dilerim işine yarar.

Visual Fox Pro
*!*    PUBLIC code from Foxpro forums. I forgot take note the Author's name

 
PUBLIC goX
goX=NEWOBJECT("pform")
 
DEFINE CLASS pform as form
      left=00
      width=900
      height=600
      ShowWindow=1
      allowoutput=.f.
      ADD OBJECT img as myimage
      PROCEDURE init
            this.img.visible=1
            this.img.picture="D:\DBL0115.JPG"
            this.img.height=thisform.height
            this.img.width=thisform.width
            this.visible=1
            DECLARE integer ValidateRect IN WIN32API integer, integer
ENDDEFINE
 
DEFINE CLASS myimage as Image
      stretch=1
      nState=0
      PROCEDURE mousemove(nBut,nShift,x,y)
            IF this.nState=1
                  IF x > thisform.dr.Left
                        thisform.dr.width=x - thisform.dr.Left
                  ENDIF
                  IF y > thisform.dr.Top
                        thisform.dr.height = y -thisform.dr.Top
                  ENDIF
            ENDIF
      PROCEDURE mousedown(nBut,nShift,x,y)
            IF this.nState>0
                  thisform.dr.visible=0
                  this.picture=this.picture
                  this.nState=0
                  RETURN
            ENDIF
            IF VARTYPE(thisform.dr)='U'
                  thisform.AddObject("dr","myshape")
            ENDIF
            thisform.dr.top=y
            thisform.dr.left = x
            thisform.dr.height=1
            thisform.dr.width=1
            thisform.dr.visible=1
            this.nState=1
      PROCEDURE mouseup(nBut,nShift,x,y)
            IF this.nState#1 
                  RETURN
            ENDIF
            this.nState =2
            thisform.dr.visible=.f.
            thisform.img.picture=thisform.img.picture &&paint over sel rect
            SET CLASSLIB TO HOME()+"ffc\_gdiplus"
            LOCAL oGraphics as gpGraphics OF (HOME()+"ffc\_gdiplus")
            LOCAL oRectDest as gpRectangle OF (HOME()+"ffc\_gdiplus")
            LOCAL oImage as gpImage OF (HOME()+"ffc\_gdiplus")
           oImage=CREATEOBJECT("gpImage",thisform.img.picture)
            oGraphics=CREATEOBJECT("gpgraphics")
            wRatio=oImage.ImageHeight/oImage.ImageWidth     && 1704/2272 .75
            pRatio=thisform.img.Height/thisform.img.Width   && 300/600 .5
            *Must compensate for Stretch=1 (Isometric)
            IF wRatio>pratio
                  wwidth=thisform.img.height/wRatio
                  wleft=thisform.img.left+(thisform.img.width - wwidth)/2
                  wtop=thisform.img.top
                  wheight=thisform.img.height
                  oRectSrc=CREATEOBJECT("gpRectangle",;
                        (thisform.dr.left-wleft)*oImage.ImageWidth/wWidth,;
                        (thisform.dr.top - thisform.img.top) *oImage.ImageHeight/thisform.img.height,;
                        thisform.dr.width*oImage.ImageWidth/wWidth,;
                        thisform.dr.Height * oImage.ImageHeight/thisform.img.height)
            ELSE
                  wwidth=thisform.img.width
                  wleft=thisform.img.left
                  wheight=thisform.img.width*wRatio
                  wTop=thisform.img.top+(thisform.img.height-wheight)/2
                  oRectSrc=CREATEOBJECT("gpRectangle",;
                        thisform.dr.left * oImage.ImageWidth/thisform.img.width,;
                        (thisform.dr.top-wtop) *oImage.ImageHeight/wheight,;
                        thisform.dr.width * oImage.ImageWidth/thisform.img.width,;
                        thisform.dr.Height *oImage.ImageHeight/wheight)
            ENDIF
            oRectDest=CREATEOBJECT("gpRectangle",wleft,wtop,wwidth,wHeight)
            hWnd=SYS(2327, SYS(2325, SYS(2326,THISFORM.hwnd))) && From Craig Boyd
            oGraphics.CreateFromHWND(hWnd)
            oGraphics.DrawImagePortionScaled(oImage,oRectDest,oRectSrc,2)
            ValidateRect(hWnd,0)
ENDDEFINE
DEFINE CLASS myshape as Shape
      bordercolor=65535
      BackStyle=0 && transparent
      BorderStyle=4
ENDDEFINE
Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

3

Re: Formda görüntüyü zoom etmek

Uğur Bey,

Çok teşekkür ederim.

Biraz yavaş çalışıyor gibi ama kod üzerinde çalışırsam bir şeyler yapabilirim sanırım.

4

Re: Formda görüntüyü zoom etmek

Kod bende gayet hızlı. Galiba senin üzerinde işlem yaptığın resimlerin boyutu gerçekten çok büyük...

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

5

Re: Formda görüntüyü zoom etmek

doğru, kabaca 4000x3000 pixellik görüntüler söz konusu.