Re: Tiff or Tif with Jpeg Compression problem
- From: aggc <aggc@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 Oct 2006 01:55:02 -0700
your sample doesn't work for me.. i've tried with a multi-page tif and whe
i tried to save raises exception below:
An unhandled exception of type
'System.Runtime.InteropServices.ExternalException' occurred in
system.drawing.dll
Additional information: A generic error occurred in GDI+.
Maybe Tiff's TrueColor only supports jpeg compression or none i don't know.
"Joergen Bech @ post1.tele.dk>" wrote:
.
Saving tiff with compression works fine for me:
I threw the sample below together from the Paint .Net
source and the save code found in this link:
http://www.codeproject.com/cs/media/BitonalImageConverter.asp
I have not tried the other parameters, but CompressionLZW works
fine.
Could be written shorter. Should be stuffed in a class and
accessed by calling static methods.
/JB
---snip---
Option Explicit On
Option Strict On
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim bm As New Bitmap("d:\smscrop.png")
Dim imgOutput As Image = bm
Dim outputFileName As String = "d:\smscrop.tif"
Dim icinfo As ImageCodecInfo =
GetImageCodecInfo(System.Drawing.Imaging.ImageFormat.Tiff)
Dim encParams As EncoderParameters = New EncoderParameters(1)
Dim enc As Encoder =
System.Drawing.Imaging.Encoder.Compression
Dim param As EncoderParameter = New EncoderParameter(enc,
EncoderValue.CompressionLZW)
encParams.Param(0) = param
imgOutput.Save(outputFileName, icinfo, encParams)
End Sub
Private Function GetImageCodecInfo(ByVal format As ImageFormat) As
ImageCodecInfo
For Each icinfo As ImageCodecInfo In
ImageCodecInfo.GetImageEncoders ' encoders
If icinfo.FormatID = format.Guid Then
Return icinfo
End If
Next
Return Nothing
End Function
End Class
---snip---
On Wed, 25 Oct 2006 08:30:02 -0700, aggc
<aggc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thanks for the reply JB.
Why JPEG compression it's used? Because it's what the scanner fujitsu
fi-5120c with vrs generates with true color option on, (the only choise for
color images).
ok, jpeg compression or none.
So i'm working with no compression at the time but there are files with 100
mb!
If i get the file free of compression and try to save it with compression to
resolve that huge :) file space problem, every option you related of encoder
parameters doesn't work raise an exception 'invalid parameter used.'
"Joergen Bech @ post1.tele.dk>" wrote:
On Wed, 25 Oct 2006 16:00:17 +0200, Joergen Bech
<jbech<NOSPAM>@<NOSPAM>post1.tele.dk> wrote:
The error occurs in the System.Drawing.Bitmap(String fileName)
constructor - or more exactly - this constructor's internal call to
Gdip.GdipCreateBitmapFromFile, I suppose.
(when using "New Bitmap("mypicture.tif")" in my test - your
examples take other routes).
/JB
- Follow-Ups:
- Re: Tiff or Tif with Jpeg Compression problem
- From: Joergen Bech
- Re: Tiff or Tif with Jpeg Compression problem
- References:
- Re: Tiff or Tif with Jpeg Compression problem
- From: Joergen Bech
- Re: Tiff or Tif with Jpeg Compression problem
- From: Joergen Bech
- Re: Tiff or Tif with Jpeg Compression problem
- From: Joergen Bech
- Re: Tiff or Tif with Jpeg Compression problem
- Prev by Date: Re: A question about TextureBrush
- Next by Date: Re: Tiff or Tif with Jpeg Compression problem
- Previous by thread: Re: Tiff or Tif with Jpeg Compression problem
- Next by thread: Re: Tiff or Tif with Jpeg Compression problem
- Index(es):
Relevant Pages
|