Ejemplo n.º 1
0
static void CIELabToRGB16(float L, float a, float b, FIRGB16 *rgb) {
	float X, Y, Z;
	float R, G, B;
	const float max_value = 65535.0F;

	CIELabToXYZ(L, a, b, &X, &Y, &Z);
	XYZToRGB(X, Y, Z, &R, &G, &B);
	rgb->red   = (WORD)PSD_CLAMP(R * max_value, 0, max_value);
	rgb->green = (WORD)PSD_CLAMP(G * max_value, 0, max_value);
	rgb->blue  = (WORD)PSD_CLAMP(B * max_value, 0, max_value);	
}
Ejemplo n.º 2
0
static void CIELabToRGB8(float L, float a, float b, RGBTRIPLE *rgb) {
	float X, Y, Z;
	float R, G, B;
	const float max_value = 255.0F;

	CIELabToXYZ(L, a, b, &X, &Y, &Z);
	XYZToRGB(X, Y, Z, &R, &G, &B);
	rgb->rgbtRed   = (BYTE)PSD_CLAMP(R * max_value, 0, max_value);
	rgb->rgbtGreen = (BYTE)PSD_CLAMP(G * max_value, 0, max_value);
	rgb->rgbtBlue  = (BYTE)PSD_CLAMP(B * max_value, 0, max_value);	
}
Ejemplo n.º 3
0
void Film::WriteImage(Float splatScale) {
    // Convert image to RGB and compute final pixel values
    std::unique_ptr<Float[]> rgb(new Float[3 * croppedPixelBounds.Area()]);
    int offset = 0;
    for (Point2i p : croppedPixelBounds) {
        // Convert pixel XYZ color to RGB
        Pixel &pixel = GetPixel(p);
        XYZToRGB(pixel.xyz, &rgb[3 * offset]);

        // Normalize pixel with weight sum
        Float filterWeightSum = pixel.filterWeightSum;
        if (filterWeightSum != 0) {
            Float invWt = (Float)1 / filterWeightSum;
            rgb[3 * offset] = std::max((Float)0, rgb[3 * offset] * invWt);
            rgb[3 * offset + 1] =
                std::max((Float)0, rgb[3 * offset + 1] * invWt);
            rgb[3 * offset + 2] =
                std::max((Float)0, rgb[3 * offset + 2] * invWt);
        }

        // Add splat value at pixel
        Float splatRGB[3];
        Float splatXYZ[3] = {pixel.splatXYZ[0], pixel.splatXYZ[1],
                             pixel.splatXYZ[2]};
        XYZToRGB(splatXYZ, splatRGB);
        rgb[3 * offset] += splatScale * splatRGB[0];
        rgb[3 * offset + 1] += splatScale * splatRGB[1];
        rgb[3 * offset + 2] += splatScale * splatRGB[2];

        // Scale pixel value by _scale_
        rgb[3 * offset] *= scale;
        rgb[3 * offset + 1] *= scale;
        rgb[3 * offset + 2] *= scale;
        ++offset;
    }

    // Write RGB image
    ::WriteImage(filename, &rgb[0], croppedPixelBounds, fullResolution);
}