AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
November 2004

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2004.11.16 05:40 "regarding tiff to bitmap", by Meenatchi Raja Rajeshwari
2004.11.16 05:48 "Re: regarding tiff to bitmap", by Andrey Kiselev
2004.11.16 05:54 "Re: regarding tiff to bitmap", by Andrey Kiselev

2004.11.16 05:54 "Re: regarding tiff to bitmap", by Andrey Kiselev

On Tue, Nov 16, 2004 at 10:40:29AM +0530, Meenatchi Raja Rajeshwari wrote:
> i want to convert a tiff file in to a bitmap file.
> can anybody help me regarding  that.
> i have some problem with the following  code
> 
> 	TIFF *inpimage=NULL;
> 	inpimage=TIFFOpen("D:\\output_files\\appurgb280multi13x18.tiff",
> "w");
> 	uint32 imwidth=800;
> 	int imheight=800;
> 	
> //	int h=TIFFGetField(inpimage, TIFFTAG_IMAGEWIDTH, &imwidth);
> //	TIFFGetField(inpimage, TIFFTAG_IMAGELENGTH, &imheight);
> 	tsize_t imlinesize_bytes=TIFFScanlineSize(inpimage);
> 	uint8 *read_buff=(uint8 *)malloc(imlinesize_bytes*imheight);
> 	BYTE *bits=read_buff;

Quick follow-up.
Your code is wrong here.

> 	for(int row=1;row<=imheight;row++)
> 	{
> 		if (TIFFReadScanline(inpimage,bits, row, 0)==-1)

row number in TIFFReadScanline() call should start from 0, not 1.

> 			AfxMessageBox("Complete or error",MB_OK,NULL);
> 		bits=read_buff+row*imwidth;

Use imlinesize_bytes to increment the pointer, otherwise you should
remember about SamplesPerPixel and BitsPerSample parameters and take in
account them too.

					Andrey

-- 
Andrey V. Kiselev
Home phone:  +7 812 5970603  ICQ# 26871517