Re: Tiff or Tif with Jpeg Compression problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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






.



Relevant Pages

  • Re: Tiff or Tif with Jpeg Compression problem
    ... compression appears, System.Drawing.Image raises an exception. ... Dim objImage As System.Drawing.Image ... 'Exception -> misses ojpeg tags compression ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Tiff or Tif with Jpeg Compression problem
    ... There are some other encoder parameters that might ... Maybe Tiff's TrueColor only supports jpeg compression or none i don't know. ... Dim bm As New Bitmap ... imgOutput.Save(outputFileName, icinfo, encParams) ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Tiff or Tif with Jpeg Compression problem
    ... Saving tiff with compression works fine for me: ... Dim bm As New Bitmap ... imgOutput.Save(outputFileName, icinfo, encParams) ... resolve that huge:) file space problem, every option you related of encoder ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Convert to 1 bit black / white
    ... When you open the bitmap and stamp your text on it you must be converting it ... Once you've got the 1 bit tiff back the compression will work fine. ... When I don't use the encoder ... > Dim ice As ImageCodecInfo ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Populating picture box via byte array.
    ... > achieves such good compression on photographic images but if you've ever ... > ByVal nStartScan As Long, ByVal nNumScans As Long, ByRef lpBits As ... > ByRef lpBI As BitmapInfo8, ByVal wUsage As Long) As Long ... > Dim BMHead As BitmapInfo8 ...
    (microsoft.public.vb.general.discussion)