Saving the real image Picturebox

Asked

Viewed 210 times

0

I’m trying to save the contents of a picturebox, but it always saves the original image and not the one being presented. Can someone help me?

Exemplo

Dim myEncoder As Encoder
    Dim myImageCodecInfo As ImageCodecInfo
    Dim myEncoderParameter As EncoderParameter
    Dim myEncoderParameters As EncoderParameters
    Dim bmp As Bitmap = CType(imgJpgPng.Image, Bitmap)
    Dim bmpt As New Bitmap(640, 640)
    Using g As Graphics = Graphics.FromImage(bmpt)
        g.DrawImage(bmp, 0, 0, bmpt.Width, bmpt.Height)
    End Using
    myImageCodecInfo = GetEncoderInfo(ImageFormat.Jpeg)
    myEncoder = Encoder.Quality
    myEncoderParameters = New EncoderParameters(1)
    myEncoderParameter = New EncoderParameter(myEncoder, CType(75L, Int32))
    myEncoderParameters.Param(0) = myEncoderParameter
    bmpt.Save("d:\TempImg\0000.JPG", myImageCodecInfo, myEncoderParameters)
  • You will need to create the image via programming, because what appears in the control is only a crop-out view of the image, and not a new image that can be saved. For example, if the person chooses "center" you need to apply this code when saving http://stackoverflow.com/questions/18014365/c-sharp-crop-image-from-center and so on. Personally I would prefer to use imagemagick to do this

  • See if this can help you: http://www.vb-helper.com/howto_resize_picture_save.html

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.