Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot write RGB images. #32

Open
sidy3d opened this issue Jun 26, 2024 · 0 comments
Open

Cannot write RGB images. #32

sidy3d opened this issue Jun 26, 2024 · 0 comments

Comments

@sidy3d
Copy link

sidy3d commented Jun 26, 2024

Hi,

Thanks for the great library.
There seems to be a bug when writing RGB images. The following code does not produce a red image. Not sure if I'm doing something wrong.

Thanks,

#include <tinytiffwriter.h>

int main()
{
	int height = 32;
	int width = 32;
	int numPixels = width * height * 3;
	char* imagePixels = new char[numPixels];

	for (size_t i = 0; i < numPixels; i += 3)
	{
		imagePixels[i] = 255; 
		imagePixels[i + 1] = 0;
		imagePixels[i + 2] = 0;
	}

	TinyTIFFWriterFile* tiff = TinyTIFFWriter_open("test.tif", 24,
		TinyTIFFWriterSampleFormat::TinyTIFFWriter_UInt, 0, width, height, TinyTIFFWriterSampleInterpretation::TinyTIFFWriter_RGB);

	if (tiff)
	{
		int success = TinyTIFFWriter_writeImageMultiSample(tiff, imagePixels, TinyTIFFSampleLayout::TinyTIFF_Interleaved, TinyTIFFSampleLayout::TinyTIFF_Planar);
		TinyTIFFWriter_close(tiff);

	}

	return 0;
}

Screenshot 2024-06-26 004142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant