Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi sir,

i developing one windows application in that application i load the image into picturebox and after that i resize the image image and next save the resized image.

i write a code for resize image is

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim image As Image = New Bitmap(ofd_Image.FileName)
        Dim [Delegate] As New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
        pb_image.Image = image.GetThumbnailImage(200, 150, [Delegate], IntPtr.Zero)
    End Sub

    Private Function ThumbnailCallback() As Boolean
        Return False
    End Function


and i write a code for save image is:

VB
Dim fs As FileStream
    Dim br As BinaryReader
    Dim bw As BinaryWriter
    Dim photo() As Byte
    Dim save_ThumbimgPath As String = "D:\test.jpg"
fs = New FileStream(pb_image.ImageLocation, FileMode.Open, FileAccess.Read)
       br = New BinaryReader(fs)
       ReDim photo(fs.Length)
       photo = br.ReadBytes(fs.Length)
       br.Close()

       fs = New FileStream(save_ThumbimgPath, FileMode.Create, FileAccess.Write)
       bw = New BinaryWriter(fs)
       bw.Write(photo)
       fs.Close()
       bw.Close()
 MessageBox.Show("image saved successfully")



my problem is how to link with these 2 block of code. means
pb_image.ImageLocation is take original image location, so it save the original image dimensions. not to save 200 X 150 dimensions of image.

Please give me a solution

Thanks.
Posted

1 solution

You could try something like this;

VB
Dim bitmap as Bitmap
bitmap = New Bitmap(pb_image.Image)
bitmap.Save("D:\Test.jpg", ImageFormat.Jpeg)


Hope this helps,
Fredrik
 
Share this answer
 
Comments
ajay.raju531 13-Oct-10 10:32am    
Thank you Fredrik Bornander. your code is works fine.
Fredrik Bornander 13-Oct-10 10:58am    
You should accept and vote for the answers you get if you like them.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900