diff options
| author | Martin Lambers <[email protected]> | 2018-02-23 12:01:48 +0100 |
|---|---|---|
| committer | Martin Lambers <[email protected]> | 2018-02-23 12:01:48 +0100 |
| commit | 35da68fb658e4b9c57b319d5443ac5e4ca547ebd (patch) | |
| tree | 2cb5a6ae1dba2f5e66a86f4f0a1b5962bc45c003 | |
| parent | 37db71ca51f29b09b1e8e8f6335243ce7120e3ac (diff) | |
| download | gta-master.tar.gz | |
| -rw-r--r-- | gtatool/src/conv-exr/from-exr.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/gtatool/src/conv-exr/from-exr.cpp b/gtatool/src/conv-exr/from-exr.cpp index efaac3a..90cb3dd 100644 --- a/gtatool/src/conv-exr/from-exr.cpp +++ b/gtatool/src/conv-exr/from-exr.cpp @@ -2,7 +2,7 @@ * This file is part of gtatool, a tool to manipulate Generic Tagged Arrays * (GTAs). * - * Copyright (C) 2010, 2011, 2012, 2013 + * Copyright (C) 2010, 2011, 2012, 2013, 2018 * Martin Lambers <[email protected]> * * This program is free software; you can redistribute it and/or modify @@ -117,12 +117,31 @@ extern "C" int gtatool_from_exr(int argc, char *argv[]) } blob data(checked_cast<size_t>(hdr.data_size())); FrameBuffer framebuffer; - int c = 0; - for (ChannelList::ConstIterator iter = channellist.begin(); iter != channellist.end(); iter++) - { - framebuffer.insert(iter.name(), Slice(FLOAT, data.ptr<char>(c * sizeof(float)), + if ((channels == 3 || channels == 4) + && channellist.findChannel("R") && channellist.findChannel("G") && channellist.findChannel("B") + && (channels == 3 || channellist.findChannel("A"))) { + hdr.component_taglist(0).set("INTERPRETATION", "RED"); + framebuffer.insert("R", Slice(FLOAT, data.ptr<char>(0 * sizeof(float)), + channels * sizeof(float), channels * width * sizeof(float), 1, 1, 0.0f)); + hdr.component_taglist(1).set("INTERPRETATION", "GREEN"); + framebuffer.insert("G", Slice(FLOAT, data.ptr<char>(1 * sizeof(float)), + channels * sizeof(float), channels * width * sizeof(float), 1, 1, 0.0f)); + hdr.component_taglist(2).set("INTERPRETATION", "BLUE"); + framebuffer.insert("B", Slice(FLOAT, data.ptr<char>(2 * sizeof(float)), channels * sizeof(float), channels * width * sizeof(float), 1, 1, 0.0f)); - c++; + if (channels == 4) { + hdr.component_taglist(3).set("INTERPRETATION", "ALPHA"); + framebuffer.insert("A", Slice(FLOAT, data.ptr<char>(3 * sizeof(float)), + channels * sizeof(float), channels * width * sizeof(float), 1, 1, 0.0f)); + } + } else { + int c = 0; + for (ChannelList::ConstIterator iter = channellist.begin(); iter != channellist.end(); iter++) + { + framebuffer.insert(iter.name(), Slice(FLOAT, data.ptr<char>(c * sizeof(float)), + channels * sizeof(float), channels * width * sizeof(float), 1, 1, 0.0f)); + c++; + } } file.setFrameBuffer(framebuffer); file.readPixels(dw.min.y, dw.max.y); |
