1

We are using BitMiracle ReadRGBATile to get a tile of a multi page tiff file to bitmap. We have the following problems 1. The image quality is not good (comparing to the same image opened in Autocad). 2. Black pixels added to fill at the right and bottom of the image (looks like TILEWIDTH - IMAGEWIDTH and IMAGELENGTH - TILELENGTH). Appreciate your help

enter image description here

enter image description here

Razack
  • 1,826
  • 2
  • 16
  • 37
  • Could you share the file? Or at least a comparison screenshot? As for black pixels - most probably it's the expected behavior. – Bobrovsky Oct 29 '13 at 18:14
  • Bobrovsky: Thank you very much for your quick response; Screenshots of the image from Tiff the image from AutoCad attached. What is meant by expected behavior? How to remove or crop these black pixels? – Razack Oct 30 '13 at 04:22
  • It looks like two _different_ images to me. Are you sure there is only one image (page, directory) in the TIFF? – Bobrovsky Oct 30 '13 at 04:42
  • It is multipage and we are opening the first page and autocad is also opening one page. – Razack Oct 30 '13 at 06:27
  • In case the file is a pyramid TIFF there might be different versions of the same image in the file. Are you sure this is not the case? Given the visual difference of two images I am almost sure it is. There is also a possibility that you have found a bug in the LibTiff.Net but it is very unlikely unless your TIFF uses some rare combination of encoding parameters. Anyway, without some code _and_ test image there is not much else could be done here. – Bobrovsky Oct 30 '13 at 06:57

1 Answers1

1

The following has solved our problem

int iWidth = tiffInput.GetField(TiffTag.IMAGEWIDTH)[0].ToInt();
int iHeight = tiffInput.GetField(TiffTag.IMAGELENGTH)[0].ToInt();

int iTile_Width = inImage.GetField(TiffTag.TILEWIDTH)[0].ToInt();
int iTile_Height = inImage.GetField(TiffTag.TILELENGTH)[0].ToInt();

for (int row = 0; row < iHeight; row += iTile_Height)
{
      for (int col = 0; col < iWidth; col += iTile_Width)
      {
          // Read the tile into an RGBA array
          if (inImage.ReadRGBATile(col, row, raster))
          {
              Bitmap bmp = TiffDataToImage(raster, iTile_Width, iTile_Height);
              //Collect all these images

          }
      }
}

Combine the image to make one image.

Nagaraj S
  • 13,316
  • 6
  • 32
  • 53
Razack
  • 1,826
  • 2
  • 16
  • 37