~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/FreeImage/TIFFLogLuv.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ==========================================================
 
2
// XYZ to RGB TIFF conversion routines
 
3
//
 
4
// Design and implementation by
 
5
// - Herv� Drolon (drolon@infonie.fr)
 
6
//
 
7
// This file is part of FreeImage 3
 
8
//
 
9
// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY
 
10
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES
 
11
// THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE
 
12
// OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED
 
13
// CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT
 
14
// THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY
 
15
// SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL
 
16
// PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER
 
17
// THIS DISCLAIMER.
 
18
//
 
19
// Use at your own risk!
 
20
// ==========================================================
 
21
 
 
22
#include "FreeImage.h"
 
23
#include "Utilities.h"
 
24
 
 
25
void tiff_ConvertLineXYZToRGB(BYTE *target, BYTE *source, double stonits, int width_in_pixels) {
 
26
        FIRGBF *rgbf = (FIRGBF*)target;
 
27
        float *xyz = (float*)source;
 
28
        
 
29
        for (int cols = 0; cols < width_in_pixels; cols++) {
 
30
                // assume CCIR-709 primaries (matrix from tif_luv.c)
 
31
                // LOG Luv XYZ (D65) -> sRGB (CIE Illuminant E)
 
32
                rgbf->red       = (float)( 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2]);
 
33
                rgbf->green     = (float)(-1.022*xyz[0] +  1.978*xyz[1] +  0.044*xyz[2]);
 
34
                rgbf->blue      = (float)( 0.061*xyz[0] + -0.224*xyz[1] +  1.163*xyz[2]);
 
35
                
 
36
                /*
 
37
                if (stonits != 0.0) {
 
38
                        rgbf->red       = (float)(rgbf->red   * stonits);
 
39
                        rgbf->green     = (float)(rgbf->green * stonits);
 
40
                        rgbf->blue      = (float)(rgbf->blue  * stonits);
 
41
                } 
 
42
                */
 
43
 
 
44
                rgbf++;
 
45
                xyz += 3;
 
46
        }
 
47
}
 
48
 
 
49
void tiff_ConvertLineRGBToXYZ(BYTE *target, BYTE *source, int width_in_pixels) {
 
50
        FIRGBF *rgbf = (FIRGBF*)source;
 
51
        float *xyz = (float*)target;
 
52
        
 
53
        for (int cols = 0; cols < width_in_pixels; cols++) {
 
54
                // assume CCIR-709 primaries, whitepoint x = 1/3 y = 1/3 (D_E)
 
55
                // "The LogLuv Encoding for Full Gamut, High Dynamic Range Images" <G.Ward>
 
56
                // sRGB ( CIE Illuminant E ) -> LOG Luv XYZ (D65)
 
57
                xyz[0] =  (float)(0.497*rgbf->red +  0.339*rgbf->green +  0.164*rgbf->blue);
 
58
                xyz[1] =  (float)(0.256*rgbf->red +  0.678*rgbf->green +  0.066*rgbf->blue);
 
59
                xyz[2] =  (float)(0.023*rgbf->red +  0.113*rgbf->green +  0.864*rgbf->blue);
 
60
 
 
61
                rgbf++;
 
62
                xyz += 3;
 
63
        }
 
64
}
 
65