1 回答
TA贡献1839条经验 获得超15个赞
您可以使用旧的 System.Drawing 方式而不是 System.Windows.Media 方式。
仅从Encoder.Compression Field的文档中略微改编:
Imports System.Drawing.Imaging
'' .....
Private Shared Function GetEncoderInfo(ByVal mimeType As String) As ImageCodecInfo
Dim j As Integer
Dim encoders() As ImageCodecInfo
encoders = ImageCodecInfo.GetImageEncoders()
j = 0
While j < encoders.Length
If encoders(j).MimeType = mimeType Then
Return encoders(j)
End If
j += 1
End While
Return Nothing
End Function
Sub SaveAsTiff()
Dim sampleFile = "C:\temp\ToTiff.png"
Using bmp = Image.FromFile(sampleFile)
Dim myImageCodecInfo = GetEncoderInfo("image/tiff")
Dim myEncoder As Imaging.Encoder = Imaging.Encoder.Compression
Dim myEncoderParameters = New EncoderParameters(1)
Dim myEncoderParameter = New EncoderParameter(myEncoder, EncoderValue.CompressionNone)
myEncoderParameters.Param(0) = myEncoderParameter
bmp.Save("C:\temp\ToTiff.tif", myImageCodecInfo, myEncoderParameters)
End Using
End Sub
但是,它不允许 ZIP 压缩。但这对您来说可能无关紧要:哪种 TIFF 图像压缩更好,LZW 还是 ZIP?
此外,对于屏幕截图,您可能需要考虑使用 PNG 格式,尤其是当图像将在网络上使用时。
- 1 回答
- 0 关注
- 211 浏览
添加回答
举报