Example #1
0
File: image.cpp Project: ICRAR/void
vd::status
ImageInput::ReadTile(
	vd::i32 x, vd::i32 y, vd::i32 z,
	PixelBuffer32f& pixels)
{
	OiioImageInput* input = reinterpret_cast<OiioImageInput*>(m_Handle);
	vdAssert(input != NULL);

	if(m_Format.Tiles.Width <= 0 || m_Format.Tiles.Height <= 0)
	{
		vdLogWarning("Failed to read tile from image -- invalid tile size used in image format!");
		return Status::Code::ReadError;
	}
	
	pixels.Setup(m_Format.Channels, m_Format.Tiles.Width * m_Format.Tiles.Height);
	
	if(!input->read_tile (x, y, z, OiioTypeDesc::FLOAT, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded tile [%d,%d,%d] %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		x,y,z, m_Format.Tiles.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Example #2
0
File: image.cpp Project: ICRAR/void
vd::status
ImageOutput::WriteTile(
	vd::i32 x, vd::i32 y, vd::i32 z,
	const PixelBuffer32f& pixels, size_t offset,
	size_t xstride, size_t ystride, size_t zstride)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);

	if(m_Format.Tiles.Width <= 0 || m_Format.Tiles.Height <= 0)
	{
		vdLogWarning("Failed to write tile to image -- invalid tile size used in image format!");
		return Status::Code::ReadError;
	}
/*	
	if(!output->write_tile (x, y, z, OiioTypeDesc::FLOAT, ((char*)pixels.Data) + offset, 
							xstride ? xstride : OiioAutoStride,
							ystride ? ystride : OiioAutoStride,
							zstride ? zstride : OiioAutoStride))
*/
	if(!output->write_tile (x, y, z, OiioTypeDesc::FLOAT, ((char*)pixels.Data)))
	{
		vdLogWarning("Failed to save tile [%d,%d,%d] to image '%s'!", x, y, z, m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Saved tile [%d,%d,%d] %d x %d (%d channels - 32bit float) from '%s'!", 
		x,y,z, m_Format.Tiles.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Example #3
0
File: image.cpp Project: ICRAR/void
vd::status 
ImageOutput::Open(
	const std::string& location, 
	const ImageFormat& format)
{	
	if(m_Handle != NULL)
	{
		Close();
	}
	
	OiioImageOutput* output = OiioImageOutput::create (location.c_str());
	if (output == NULL)
	{
		vdLogWarning("Failed to open image for file '%s'!", location.c_str());
		return Status::Code::OpenError;
	}
	
	OiioImageSpec spec;
	if(format.Width > 0)			spec.width = format.Width;
	if(format.Height > 0)			spec.height = format.Height;
	if(format.Depth > 0)			spec.depth = format.Depth;
	if(format.Tiles.Width > 0)		spec.tile_width = format.Tiles.Width;
	if(format.Tiles.Height > 0)		spec.tile_height = format.Tiles.Height;
	if(format.Tiles.Depth > 0)		spec.tile_depth = format.Tiles.Depth;
	if(format.Channels.Count > 0)	spec.nchannels = format.Channels.Count;
	
	if(!output->open(location.c_str(), spec))
	{
		vdLogWarning("Failed to open image for file '%s'!", location.c_str());
		return Status::Code::OpenError;
	}
	
	vdLogInfo("Opened image %d x %d (%d channels) for '%s'!", 
		format.Width, format.Height, format.Channels.Count, location.c_str());

	m_Format = format;
	m_Format.Width = spec.width;
	m_Format.Height = spec.height;
	m_Format.Channels.Count = spec.nchannels;
	m_Format.Tiles.Width = spec.tile_width;
	m_Format.Tiles.Height = spec.tile_height;
	m_Format.Tiles.Depth = spec.tile_depth;

	m_Location = location;
	m_IsOpen = true;
	m_Handle = reinterpret_cast<void*>(output);

	return Status::Code::Success;
}
Example #4
0
Object::~Object()
{
#if !defined(VD_RELEASE_BUILD)
	vd::i32 count = GetRefCount();
#if defined(VD_DEBUG_REFCOUNTS)    
    if(count > 0)
    {
        vdLogWarning("Deleting %s with reference count %i!",
            ToString().c_str(), count);
    }
#else
    vdAssert(count == 0);
#endif
#endif
}
Example #5
0
File: image.cpp Project: ICRAR/void
vd::status
ImageOutput::WriteScanLine(
	vd::i32 y, vd::i32 z,
	const PixelBuffer8u& pixels)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);

	if(!output->write_scanline(y, z, OiioTypeDesc::UINT8, pixels.Data))
	{
		vdLogWarning("Failed to write scanline [%d %d] to image '%s'!", y, z, m_Location.c_str());
		return Status::Code::WriteError;
	}

	return Status::Code::Success;
}
Example #6
0
vd::status
Application::Startup(int* argc, void** argv)
{
    m_Status = Status::Code::Starting;
    Core::System::Startup();
    Runtime::System::Startup();

    if(!LoadResources())
    {
        vdLogWarning("Failed to load resources!");
        return Status::Code::LoadError;
    }

    m_Runtime = System::CreateContext(m_ParamSet);
	SetActive(this);
    return Status::Code::Success;
}
Example #7
0
File: image.cpp Project: ICRAR/void
vd::status
ImageOutput::Write(
	ImageBuffer32f& pixels)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);

	if(!output->write_image(OiioTypeDesc::FLOAT, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded image %d x %d (%d channels - 32 bit float) F32 from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Example #8
0
File: image.cpp Project: ICRAR/void
vd::status
ImageOutput::Write(
	ImageBuffer8u& pixels)
{
	OiioImageOutput* output = reinterpret_cast<OiioImageOutput*>(m_Handle);
	vdAssert(output != NULL);
	
	if(!output->write_image(OiioTypeDesc::UINT8, pixels.Data))
	{
		vdLogWarning("Failed to write image to '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Wrote image %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}
Example #9
0
File: image.cpp Project: ICRAR/void
vd::status
ImageInput::Read(
	ImageBuffer8u& pixels)
{
	OiioImageInput* input = reinterpret_cast<OiioImageInput*>(m_Handle);
	vdAssert(input != NULL);
	
	pixels.Setup(m_Format);
	
	if(!input->read_image(OiioTypeDesc::UINT8, pixels.Data))
	{
		vdLogWarning("Failed to load image from file '%s'!", m_Location.c_str());
		return Status::Code::ReadError;
	}

	vdLogInfo("Loaded image %d x %d (%d channels - 8-bit unsigned) from '%s'!", 
		m_Format.Width, m_Format.Height, m_Format.Channels.Count, m_Location.c_str());	

	return Status::Code::Success;
}