Stripes?

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

Moderators: XnTriq, xnview

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

Stripes?

Post by tailormade » Fri Oct 23, 2009 12:00 am

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: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview » Fri Oct 23, 2009 3:45 pm

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: 13
Joined: Fri Jun 24, 2005 6:08 pm

Re: Stripes?

Post by tailormade » Fri Oct 23, 2009 9:52 pm

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: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview » Sat Oct 24, 2009 12:25 pm

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: 13
Joined: Fri Jun 24, 2005 6:08 pm

Re: Stripes?

Post by tailormade » Wed Oct 28, 2009 10:53 pm

What parameter do you use to go from 1-bit to 8-bit greyscale?

User avatar
xnview
Author of XnView
Posts: 31607
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Stripes?

Post by xnview » Thu Oct 29, 2009 8:12 am

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

Post Reply