Esempio n. 1
0
void Image::load(std::string const& path, float gamma)
{
	int num_components;
	stbi_ldr_to_hdr_gamma(gamma);
    float *data = stbi_loadf(path.c_str(), &m_width, &m_height, &num_components, 4);
	if(!data) {
		std::cerr << "error: could not load image \"" << path << "\"" << std::endl;
		return;
	}
	m_pixels.resize(m_width * m_height);
	/* flip image in Y */
	for(int y = 0; y < m_height; y++) {
		memcpy(&m_pixels[(m_height - y - 1) * m_width],
				data + y * m_width * 4,
				4 * m_width * sizeof(float));
	}
	stbi_image_free(data);
}
Esempio n. 2
0
/*
  call-seq:
    set_ldr_to_hdr_gamma(value) => value
    ldr_to_hdr_gamma = value => value

  Sets the LDR to HDR gamma used when loading LDR images with load_float_image.
 */
static VALUE sr_set_ldr_to_hdr_gamma(VALUE self, VALUE gamma)
{
  stbi_ldr_to_hdr_gamma((float)NUM2DBL(gamma));
  return gamma;
}