VB.net如何将多张图片保存为一个多页的tiff文件 100
VB.net里面有一个Img.SaveAdd函数,可以将图片以帧的形式保存到一个多页的tiff格式图片中,但这个函数需要一个EncoderParameter参数,这个参数...
VB.net里面有一个Img.SaveAdd函数,可以将图片以帧的形式保存到一个多页的tiff格式图片中,但这个函数需要一个EncoderParameter参数,这个参数不知道如何设置。哪位能提供个实例呢?谢谢
展开
1个回答
展开全部
自己上msdn找mode。
这里有个C的。
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
private void VaryQualityLevel()
{
// Get a bitmap.
Bitmap bmp1 = new Bitmap(@"c:\TestPhoto.jpg");
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
EncoderParameters myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 0L);
myEncoderParameters.Param[0] = myEncoderParameter;
Bitmap b = new Bitmap(100, 200);
Graphics g = Graphics.FromImage(b);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(bmp1, new Rectangle(0, 0, 100, 100), new Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel);
g.Dispose();
b.Save(@"c:\TestPhotoQualityZero.jpg", jgpEncoder, myEncoderParameters);
}
这里有个C的。
private ImageCodecInfo GetEncoder(ImageFormat format)
{
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
foreach (ImageCodecInfo codec in codecs)
{
if (codec.FormatID == format.Guid)
{
return codec;
}
}
return null;
}
private void VaryQualityLevel()
{
// Get a bitmap.
Bitmap bmp1 = new Bitmap(@"c:\TestPhoto.jpg");
ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
// Create an Encoder object based on the GUID
// for the Quality parameter category.
System.Drawing.Imaging.Encoder myEncoder =
System.Drawing.Imaging.Encoder.Quality;
EncoderParameters myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 0L);
myEncoderParameters.Param[0] = myEncoderParameter;
Bitmap b = new Bitmap(100, 200);
Graphics g = Graphics.FromImage(b);
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(bmp1, new Rectangle(0, 0, 100, 100), new Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel);
g.Dispose();
b.Save(@"c:\TestPhotoQualityZero.jpg", jgpEncoder, myEncoderParameters);
}
追问
vc.net的是能用。但没有找到vb.net的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询