Stripes?

Discussions on GFL SDK, the graphic library for reading and writing graphic files

Moderators: XnTriq, helmut, xnview

Post Reply
tailormade
Posts: 15
Joined: Fri Jun 24, 2005 6:08 pm

Stripes?

Post by tailormade »

I have a 1-bit TIFF file that I need to save as an 8-bit greyscale TIFF. I have tried two ways:

1) Define a second greyscale bitmap and use gflBitblt to copy of one to another. Causes an Unknown format error
2) Define a second greyscale bitmap and go through pixel by pixel and use gflGetColorAt/gflSetColorAt to copy the pixels one by one.

Unfortunately the second one ends up creating a bitmap with 8 vertical strips. Each vertical strip appears to be a squished version of the original page

Here is the code I used:

Code: Select all

tBitmap = gflAllockBitmap(GFL_GREY, wid, hgt, 4, NULL);
for (ix = 0; ix < wid; ix++)
	for (iy = 0; iy < hgt; iy++)
		{
		GFL_COLOR color;
		error = gflGetColorAt(bitmap, ix, iy, &color);
		if (error)
			DisplayGflError("", error);
		error = gflSetColorAt(tBitmap, ix, iy, &color);
		if (error)
			DisplayGflError("", error);
		}
User avatar
xnview
Author of XnView
Posts: 43357
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview »

tailormade wrote: 2) Define a second greyscale bitmap and go through pixel by pixel and use gflGetColorAt/gflSetColorAt to copy the pixels one by one.
Ok, right there is a little bug.
Why you don't use gflChangeColorDepth?
Pierre.
tailormade
Posts: 15
Joined: Fri Jun 24, 2005 6:08 pm

Re: Stripes?

Post by tailormade »

Because I need to go from 1-bit to 8-bit grey. At least according to the documentation gflChangeColorDepth only allows you to reduce the number of colors, not increase it.
User avatar
xnview
Author of XnView
Posts: 43357
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview »

tailormade wrote:Because I need to go from 1-bit to 8-bit grey. At least according to the documentation gflChangeColorDepth only allows you to reduce the number of colors, not increase it.
No, you can increase too
Pierre.
tailormade
Posts: 15
Joined: Fri Jun 24, 2005 6:08 pm

Re: Stripes?

Post by tailormade »

What parameter do you use to go from 1-bit to 8-bit greyscale?
User avatar
xnview
Author of XnView
Posts: 43357
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview »

tailormade wrote:What parameter do you use to go from 1-bit to 8-bit greyscale?
GFL_MODE_TO_RGB
Pierre.
Post Reply