Re: Color problems when converting indexed8 to 24 bit



Hi,

Here's the link to it: http://web.abo.fi/~lsilvand/SEM.tif
It's an uncompressed 6 Mb TIFF file. Dimensions:3072x2304. 8-bit
indexed. Search for white after you've loaded it in, there should be
plenty of it if everythings ok.
The problem is that I've got thousands of files just like this one and
I'ld hope that there's something wrong with the TIFF loader and not
with the program producing these TIFF images.
Could a problem with the TIFF image also explain why I get a black
image while copying it with DrawImage(image,point()). I always have to
use DrawImage(image,rectangle()) to get it to produce and ok image.

Regards,
Linus


On Mar 31, 6:28 pm, "Bob Powell [MVP]" <b...@xxxxxxxxxxxxxxxxxxxxxxx>
wrote:
You seem to have chosen the best mode for a simple copy.

Can you post the image that you want to make a copy of?

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consultinghttp://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Trickshttp://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQhttp://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Linus" <lsilv...@xxxxxxxxxxx> wrote in message

news:6a86a59e-d7bb-4657-95a9-82fe612266ce@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi,

I'm having a problem converting an indexed8 tiff image to a 24bit
image. When I convert it with DrawImage or for example
DrawImageUnscaledAndClipped it drops the RGB with one. For example
(255,255,255) would become (254,254,254). I've tried the victor image
processing library demo version and with it I've no problems.
Photoshop also converts it to 24bit correctly. Now I'm asking, what
Graphics setting do I need to set to get it to convert the image
correctly? I've included part of the code below. Also, is it possible
to export a reference to a bitmap from a function? How do I dispose of
the bitmap in the function? Or shouldn't I do it? Will it be enough if
the caller disposes of it?

Thanks,
Linus

   Function OpenImage(ByVal filename As String) As Bitmap

       Dim image As Bitmap
       Dim image24 As Bitmap
       Dim g As Graphics

       Try
           image = New Bitmap(filename)
           image24 = New Bitmap(image.Width, image.Height,
Imaging.PixelFormat.Format24bppRgb)

           g = Graphics.FromImage(image24)

           '  g.CompositingMode =
Drawing2D.CompositingMode.SourceCopy
           '  g.CompositingQuality =
Drawing2D.CompositingQuality.AssumeLinear
           '  g.InterpolationMode =
Drawing2D.InterpolationMode.NearestNeighbor
           '  g.PixelOffsetMode = Drawing2D.PixelOffsetMode.Half
           '  g.PageUnit = GraphicsUnit.Pixel
           '  g.SmoothingMode = Drawing2D.SmoothingMode.None
           g.DrawImage(image, 0, 0, image.Width, image.Height)
           image24.Save(filename & "2.png")
       Catch
           image24 = Nothing
       End Try

       If Not (IsNothing(g)) Then g.Dispose()
       If Not (IsNothing(image)) Then image.Dispose()
       OpenImage = image24
       'If Not (IsNothing(image24)) Then image24.Dispose()

   End Function

.



Relevant Pages

  • Fax Tiff format
    ... I am trying to create a tiff file for submission to MS Fax Server in a format that the server will accept without re-formatting it. ... Speed is very important for our application, so I need to find a way to create a tiff file that MS Fax server will accept without re-formatting it. ...
    (microsoft.public.windowsxp.print_fax)
  • MS Fax Tiff format
    ... I am trying to create a tiff file for submission to MS Fax Server in a format that the server will accept without re-formatting it. ... Speed is very important for our application, so I need to find a way to create a tiff file that MS Fax server will accept without re-formatting it. ...
    (microsoft.public.windows.vista.print_fax_scan)
  • Re: How to create a TIFF image from a binary raw data
    ... You wish to construct a java.awt.Image from a TIFF file, ... TIFF file. ... binary array known consisting of a valid TIFF file. ... I ran your program and it worked well with TIFF image file! ...
    (comp.lang.java.programmer)
  • Re: Problem to read tiff file
    ... Is it possible that your extraction code has a bug. ... Make sure that the tiff file that you extracting from EPS is a valid ... I have extraced a tiff image embedded in an EPS file. ...
    (microsoft.public.dotnet.csharp.general)
  • Re: How to open and display a TIFF file?
    ... Ramon> way to open and display a TIFF file? ... very simple - one method call to go between BufferedImages and TIFF ...
    (comp.lang.java.gui)

Loading