image - C# - Can I use Libtiff to output Tiff encoded JPEG (In YCbCr) -


hi quite new libtiff , image processing, , have question when try use libtiff.net bitmiracle.

i have ojpeg tiff image , want convert them nowadays jpeg tiff. achieved converting source bmp , save tiff (compression: jpeg; photometric: rgb), size of image quite large. thought if can compress them photometric of ycbcr, can reduce size lot.

however, when change photometric rgb ycbcr, program don't work: output 8 bytes (the input 400kb). when open image txt, shows:

"ii* "

the code use is:

byte[] raster1 = getimagerasterbytes(inputbmp[0], pixelformat.format24bpprgb); tif1.setfield(tifftag.imagewidth, inputbmp[0].width); tif1.setfield(tifftag.imagelength, inputbmp[0].height); tif1.setfield(tifftag.compression, compression.jpeg); tif1.setfield(tifftag.photometric, photometric.ycbcr); tif1.setfield(tifftag.rowsperstrip, inputbmp[0].height); //tif1.setfield(tifftag.jpegquality, confidence); tif1.setfield(tifftag.xresolution, 200); tif1.setfield(tifftag.yresolution, 200); tif1.setfield(tifftag.bitspersample,8); tif1.setfield(tifftag.samplesperpixel, 3); int stride = raster1.length / inputbmp[0].height; convertsamples(raster1, inputbmp[0].width, inputbmp[0].height); (int = 0, offset = 0; < inputbmp[0].height; i++) {     tif1.writescanline(raster1, offset, i, 0);     offset += stride; } 

i'm not quite sure if writescanline can handle ycbcr output or not, , if there other ways, it's totally cool too.

thank help!

output images definetely broken. happens when fatal error occurred. library should output warnings , errors console in such case.

please investigate warnings , errors. might give answer.

based on experience, think might have provided incorrect value rowsperstrip tag. value should multiple of 8.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -