Quantcast
Viewing all articles
Browse latest Browse all 12583

zoom code problem

I have the following code that works well to zoom a picture in a picture box but only on the second and following clicks I know I am missing something to explain why can anyone help.

SubButton6_Click(senderAsSystem.Object, e AsSystem.EventArgs)HandlesButton6.Click

 

       

DimWidth = PictureBox1.Image.Width

       

DimHeight = PictureBox1.Image.Height

        PictureBox1.Size = PictureBox1.Image.Size

       

IfPicBoxWidth >= 4500Then


           

MessageBox.Show("You are at maximum zoom level")

           

Exit Sub


       

EndIf


       

DimsourceImageAsBitmap= PictureBox1.Image

        zoomwidth = Width * 1.5

        zoomheight = Height * 1.5

       

DimnewImageAsNewBitmap(zoomwidth, zoomheight)

       

DimrendererAsGraphics=Graphics.FromImage(newImage)

        renderer.DrawImage(sourceImage, 0, 0, newImage.Width, newImage.Height)

        renderer.CompositingQuality =

CompositingQuality.HighQuality

        renderer.InterpolationMode =

InterpolationMode.HighQualityBicubic

        renderer.SmoothingMode =

SmoothingMode.HighQuality

        PictureBox1.Size = PictureBox1.Image.Size

        PictureBox1.SizeMode =

PictureBoxSizeMode.Zoom

        PictureBox1.Image.Dispose()

        PictureBox1.Image = newImage

        PicBoxWidth = PictureBox1.Size.Width

        zoomnumber = zoomnumber + 1

       

Ifzoomtimesclick = 0Then


            zoomnumber = 0

            zoomtimesclick = 1

       

EndIf


        Label9.Text = zoomnumber

   

EndSub


Viewing all articles
Browse latest Browse all 12583

Trending Articles