Not getting expected output while converting JPEG to TIFF image C# using BitMiracle.LibTiff.Net library

403 views Asked by At

We are not getting expected output after converting JPEG file to TIFF using below property values.I am using BitMiracle LibTiff.Net library for this.

Output was visible 50% of actual image with blur lines.

We are below properties for converting jpeg to tiff image.Please suggest if anything wrong on this properties and help to improve it.

using (Bitmap bmp = new Bitmap(stream))
   {
     using (Tiff tif = Tiff.Open(tiffOutImgPath, "w"))
       {
         tif.SetField(TiffTag.SUBFILETYPE, 0);      
         tif.SetField(TiffTag.IMAGEWIDTH, bmp.Width);
         tif.SetField(TiffTag.IMAGELENGTH, bmp.Height);
         tif.SetField(TiffTag.BITSPERSAMPLE, 8);
         tif.SetField(TiffTag.COMPRESSION, Compression.JPEG);
         tif.SetField(TiffTag.PHOTOMETRIC, Photometric.MINISBLACK);

         tif.SetField(TiffTag.STRIPOFFSETS, BitConverter.ToInt32(stripOffset, 0));
         tif.SetField(TiffTag.ORIENTATION, Orientation.TOPLEFT);
         tif.SetField(TiffTag.SAMPLESPERPIXEL, 1);

         tif.SetField(TiffTag.ROWSPERSTRIP, BitConverter.ToInt32(rowStripArr, 0));
         tif.SetField(TiffTag.STRIPBYTECOUNTS, BitConverter.ToInt32(stripByCount, 0));                     
         tif.SetField(TiffTag.XRESOLUTION, dpiVal);
         tif.SetField(TiffTag.YRESOLUTION, dpiVal);
         tif.SetField(TiffTag.RESOLUTIONUNIT, ResUnit.INCH);
         tif.SetField(TiffTag.PLANARCONFIG, PlanarConfig.CONTIG);
      }
  }

Please help me on the above property values, anything missing or require to change for getting expected output.

0

There are 0 answers