如何在Windows应用程序中保存调整大小的图像? [英] how to save resized image in windows application?
问题描述
先生,
我在该应用程序中开发了一个Windows应用程序,将图像加载到图片框,然后调整图像图像的大小,然后保存调整后的图像.
我写了一个调整图像大小的代码是
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
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:
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")
我的问题是如何与这2个代码块链接.表示
pb_image.ImageLocation是原始图像的位置,因此可以保存原始图像的尺寸.不保存200 X 150尺寸的图像.
请给我一个解决办法
谢谢.
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.
推荐答案
您可以尝试这样的事情;
You could try something like this;
Dim bitmap as Bitmap
bitmap = New Bitmap(pb_image.Image)
bitmap.Save("D:\Test.jpg", ImageFormat.Jpeg)
希望这会有所帮助,
弗雷德里克(Fredrik)
Hope this helps,
Fredrik
这篇关于如何在Windows应用程序中保存调整大小的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!