~ubuntu-branches/ubuntu/natty/qtpfsgui/natty

« back to all changes in this revision

Viewing changes to src/Fileformat/pfsoutldrimage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-01-06 04:39:36 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080106043936-a9u9g7yih3w16ru5
Tags: 1.9.0-1
* New upstream release.
* Replace “COPYING” with “LICENSE” in the NOT_NEEDED variable of
  debian/rules, following upstream's renaming.
* Update debian/links accordingly.
* Delete the matching TODO item since there's no longer needed to have a
  patched (with HTML tags) license file to get a correct display in the
  “License agreement” tab.
* Update the gcc4.3 patch (drop the hunk touching src/Libpfs/pfs.cpp):
   - 20_gcc4.3_includes.
* Add a link from /usr/share/qtpfsgui/html to the HTML documentation
  under /usr/share/doc/qtpfsgui/html since the former is used at runtime
  to display the manual.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
}
39
39
 
40
40
 
41
 
#include "../Threads/tonemapper_thread.h"
 
41
#include "../Threads/tonemapperThread.h"
42
42
QImage TonemapperThread::fromLDRPFStoQImage( pfs::Frame* inpfsframe ) {
43
43
        assert(inpfsframe!=NULL);
44
44
 
45
45
        pfs::DOMIO pfsio;
46
 
        pfs::Channel *X, *Y, *Z;
47
 
        inpfsframe->getXYZChannels( X,Y,Z );
48
 
        assert( X!=NULL && Y!=NULL && Z!=NULL );
49
 
 
50
 
        //we are modifying the input buffer here!!!
51
 
        //but it should be ok since this is the endpoint
52
 
        //keep SRGB for compatibility with pfstmo...
53
 
        pfs::transformColorSpace( pfs::CS_XYZ, X,Y,Z, pfs::CS_SRGB, X,Y,Z );
54
 
 
55
 
        int width = X->getCols();
56
 
        int height =  X->getRows();
 
46
        pfs::Channel *R, *G, *B;
 
47
        inpfsframe->getRGBChannels( R,G,B );
 
48
        assert( R!=NULL && G!=NULL && B!=NULL );
 
49
 
 
50
        //inpfsframe's colorspace is either sRGB or RGB.
 
51
        //sRGB is used for compatibility with pfstmo.
 
52
        //fattal, reinhard05 and ashickmin (somewhat) prefer a RGB colorspace
 
53
 
 
54
        int width = R->getCols();
 
55
        int height =  R->getRows();
57
56
        uchar *data=new uchar[width*height*4]; //this will contain the image data: data must be 32-bit aligned, in Format: 0xffRRGGBB
58
57
        for( int y = 0; y < height; y++ ) { // For each row of the image
59
58
                for( int x = 0; x < width; x++ ) {
60
59
                        if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
61
 
                        *(data + 0 + (y*width+x)*4) = ( clamp( (*Z)( x, y )*255.f, 0, 255) );
62
 
                        *(data + 1 + (y*width+x)*4) = ( clamp( (*Y)( x, y )*255.f, 0, 255) );
63
 
                        *(data + 2 + (y*width+x)*4) = ( clamp( (*X)( x, y )*255.f, 0, 255) );
 
60
                        *(data + 0 + (y*width+x)*4) = ( clamp( (*B)( x, y )*255.f, 0, 255) );
 
61
                        *(data + 1 + (y*width+x)*4) = ( clamp( (*G)( x, y )*255.f, 0, 255) );
 
62
                        *(data + 2 + (y*width+x)*4) = ( clamp( (*R)( x, y )*255.f, 0, 255) );
64
63
                        *(data + 3 + (y*width+x)*4) = 0xff;
65
64
                        } else {
66
 
                        *(data + 3 + (y*width+x)*4) = ( clamp( (*Z)( x, y )*255.f, 0, 255) );
67
 
                        *(data + 2 + (y*width+x)*4) = ( clamp( (*Y)( x, y )*255.f, 0, 255) );
68
 
                        *(data + 1 + (y*width+x)*4) = ( clamp( (*X)( x, y )*255.f, 0, 255) );
 
65
                        *(data + 3 + (y*width+x)*4) = ( clamp( (*B)( x, y )*255.f, 0, 255) );
 
66
                        *(data + 2 + (y*width+x)*4) = ( clamp( (*G)( x, y )*255.f, 0, 255) );
 
67
                        *(data + 1 + (y*width+x)*4) = ( clamp( (*R)( x, y )*255.f, 0, 255) );
69
68
                        *(data + 0 + (y*width+x)*4) = 0xff;
70
69
                        }
71
70
                }
72
71
        }
 
72
 
73
73
//special treament for qt 4.2.1... removing "const" doesn't seem to work.
74
74
#if QT_VERSION == 0x040201
75
75
        QImage toreturn(const_cast<const uchar *>(data),width,height,QImage::Format_ARGB32);