Re: Tiff or Tif with Jpeg Compression problem

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




The error occurs in the System.Drawing.Bitmap(String fileName)
constructor - or more exactly - this constructor's internal call to
Gdip.GdipCreateBitmapFromFile, I suppose.

Take a look at the System.Drawing.Imaging.EncoderValue
enumeration where - among others - you will find the following
values:

- CompressionCCITT3 = 3
- CompressionCCITT4 = 4
- CompressionLZW = 2
- CompressionNone = 6
- CompressionRle = 5

No jpeg. It is fair to assume that if the framework does not
support saving to a specific format, you should not expect it
to read it either.

You probably need to get an image library.

Though I cannot fathom why anyone would want to use
jpeg-compressed tiff files in the first place, but that is besides
the point.

/JB



On Wed, 25 Oct 2006 03:13:02 -0700, aggc
<aggc@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Hi everyone,

I'm using .net framework 1.1 and i'm doing an application that manipulate
tiff images.
Almost everything works fine.. But when Tiff images with jpeg or ojpeg
compression appears, System.Drawing.Image raises an exception.

I've tried many ways to work around the problem.. but it wasn't possible.

Dim objImage As System.Drawing.Image

' FileStream
Dim fs1 As New FileStream("c:\newtest.tif", FileMode.Open, FileAccess.Read)
System.Drawing.Image.FromStream(fs1, True, False)

'Exception -> misses ojpeg tags compression

'MemoryStream
Dim fs1 As New FileStream("c:\test.jpg", FileMode.Open)
Dim r1 As New IO.BinaryReader(fs1)
Dim buffer(fs1.Length) As Byte
r1.Read(buffer, 0, fs1.Length)
r1.Close()
fs1.Close()
Dim ms As New MemoryStream(buffer)
ms.Flush()
objImage = System.Drawing.Image.FromStream(ms)

'Exception -> misses ojpeg tags compression

'FromFile
objImage = System.Drawing.Image.FromFile("c:\newtest.tif")

'Exception -> out of memory

System.Drawing.Bitmap doesn't work either.

So, is there another way to solve that problem or it is some .net framework
limitation?

Thanks in advance,
André


.



Relevant Pages

  • Re: Tiff or Tif with Jpeg Compression problem
    ... An unhandled exception of type ... Maybe Tiff's TrueColor only supports jpeg compression or none i don't know. ... Dim bm As New Bitmap ... resolve that huge:) file space problem, every option you related of encoder ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Tiff or Tif with Jpeg Compression problem
    ... Answer those GDI+ questions with the GDI+ FAQ ... 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: DropDownList has SelectedValue which in invalid
    ... resulting in the invalid SelectedValue error. ... Dim ddl1 As DropDownList = CType, ... From your description you want to avoid getting the exception: ... Microsoft Online Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • 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)
  • Re: How is it possible ...
    ... Dim myExportFile As String = CType, ... Catch ex As Exception ... 'Throw exc ... Private Sub Page_Init(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)