In my Visual C++ application I call imaqWritePNGFile() to save image to disk acquired from another source.  The image is 16 bit unsigned data that I have to first convert to a signed value by subtracting 32768 from each unsigned short in the data buffer.  I have verified that the resulting value is correct.  It appears that when the image has very little dynamic range, lets say 8k right around 75% gray, the resulting image appears very dark.  If I take that same image and add a single full white and full black pixel the image it turns out correct after saving it.  Below is the code I am using with the hack that makes the image look correct.
I have attached 2 PNG files that show the problem I am seeing.
Thanks,
 Ala
n Spurgeon
 Synapse
 206-919-3585
void VisionClass::WritePNGImage( unsigned short *pBuffer, int width, int height, const char *pFileName )
{
	unsigned short *tempDataPtr = pBuffer;
	long counter = width * height;
	// If we don't have a cached Image create one.
	if( NULL == m_pWriteImage )
		if( NULL == (m_pWriteImage = imaqCreateImage( IMAQ_IMAGE_I16, 0 )) )
		{
			// Something went wrong.  Figure it out.
			assert( false );
		}
	// Hack to make image appear correct when saved out.
	pBuffer[0] = 0xffff;
	pBuffer[1] = 0;
	// IMAQ requires that the image data be signed so we have to shift the
	// values down by 32768.  That makes zero the equivelent to 50% gray.
	while( counter-- )
		*tempDataPtr++ = stemp;
	// Let IMAQ fill out the image structure for the source.
	if( imaqArrayToImage( m_pWriteImage, pBuffer, width, height ) == 0 )
	{
		// Something went wrong.  Figure it out.
		assert( false );
	}
	// Write image out in PNG format with stand
ard compression.
	if( imaqWritePNGFile( m_pWriteImage, pFileName, 750, NULL ) == 0 )
	{
		// Something went wrong.  Figure it out.
		assert( false );
	}
}