Exemplo n.º 1
0
		virtual void load( ImageTargetRef target )
		{
			ImageSource::RowFunc func = setupRowFunc( target );

			for( int32_t row = 0; row < mHeight; ++row )
				((*this).*func)( target, row, mData + row * mWidth );
		}
void ImageSourceFileRadiance::load( ImageTargetRef target )
{
	// get a pointer to the ImageSource function appropriate for handling our data configuration
	ImageSource::RowFunc func = setupRowFunc( target );
	//int number_passes = png_set_interlace_handling( mPngPtr );
	for( int32_t row = 0; row < mHeight; ++row ) {
		((*this).*func)( target, row, mRgbData.get() + ( row * mWidth * 3 ) );
	}
}
Exemplo n.º 3
0
	void load( ImageTargetRef target ) {
		// get a pointer to the ImageSource function appropriate for handling our data configuration
		ImageSource::RowFunc func = setupRowFunc( target );
		
		const uint8_t *data = mData;
		for( int32_t row = 0; row < mHeight; ++row ) {
			((*this).*func)( target, row, data );
			data += mRowBytes;
		}
	}
Exemplo n.º 4
0
void ImageSourceFileTinyExr::load( ImageTargetRef target )
{
	ImageSource::RowFunc rowFunc = setupRowFunc( target );

	const size_t numChannels = mExrImage->num_channels;
	const void *red = nullptr, *green = nullptr, *blue = nullptr, *alpha = nullptr;
	
	for( size_t c = 0; c < numChannels; ++c ) {
		if( strcmp( mExrImage->channel_names[c], "R" ) == 0 )
			red = mExrImage->images[c];
		else if( strcmp( mExrImage->channel_names[c], "G" ) == 0 )
			green = mExrImage->images[c];
		else if( strcmp( mExrImage->channel_names[c], "B" ) == 0 )
			blue = mExrImage->images[c];
		else if( strcmp( mExrImage->channel_names[c], "A" ) == 0 )
			alpha = mExrImage->images[c];
	}

	if( ( ! red ) || ( ! green ) || ( ! blue ) )
		throw ImageIoExceptionFailedLoadTinyExr( "Unable to locate channels for RGB" );
	
	// load one interleaved row at a time
	if( getDataType() == ImageIo::FLOAT32 ) {
		vector<float> rowData( mWidth * mExrImage->num_channels, 0 );
		for( int32_t row = 0; row < mHeight; row++ ) {
			for( int32_t col = 0; col < mWidth; col++ ) {
				rowData.at( col * numChannels + 0 ) = ((float*)red)[row * mWidth + col];
				rowData.at( col * numChannels + 1 ) = ((float*)green)[row * mWidth + col];
				rowData.at( col * numChannels + 2 ) = ((float*)blue)[row * mWidth + col];
				if( alpha )
					rowData.at( col * numChannels + 3 ) = ((float*)alpha)[row * mWidth + col];
			}

			((*this).*rowFunc)( target, row, rowData.data() );
		}
	}
	else { // float16
		vector<uint16_t> rowData( mWidth * mExrImage->num_channels, 0 );
		for( int32_t row = 0; row < mHeight; row++ ) {
			for( int32_t col = 0; col < mWidth; col++ ) {
				rowData.at( col * numChannels + 0 ) = ((uint16_t*)red)[row * mWidth + col];
				rowData.at( col * numChannels + 1 ) = ((uint16_t*)green)[row * mWidth + col];
				rowData.at( col * numChannels + 2 ) = ((uint16_t*)blue)[row * mWidth + col];
				if( alpha )
					rowData.at( col * numChannels + 3 ) = ((uint16_t*)alpha)[row * mWidth + col];
			}

			((*this).*rowFunc)( target, row, rowData.data() );
		}
	}
	
	FreeEXRImage( mExrImage.get() );
}
Exemplo n.º 5
0
void ImageSourcePng::load( ImageTargetRef target )
{
	bool success = true;
	if( setjmp( png_jmpbuf(mPngPtr) ) ) {
		png_destroy_read_struct( &mPngPtr, &mInfoPtr, (png_infopp)NULL );
		mPngPtr = 0;
		success = false;
	}
	else {
		// get a pointer to the ImageSource function appropriate for handling our data configuration
		ImageSource::RowFunc func = setupRowFunc( target );
		//int number_passes = png_set_interlace_handling( mPngPtr );
		shared_ptr<png_byte> row_pointer( new png_byte[png_get_rowbytes( mPngPtr, mInfoPtr )], checked_array_deleter<png_byte>() );
		for( int32_t row = 0; row < mHeight; ++row ) {
			png_read_row( mPngPtr, row_pointer.get(), NULL );
			((*this).*func)( target, row, row_pointer.get() );
		}
	}
	
	if( ! success )
		throw ImageSourcePngException( "Failure during load." );
}