void execute() { const int chanCount = num_channels(); ChannelSet channels = channel_mask(chanCount); const bool doAlpha = channels.contains(Chan_Alpha); iop->progressMessage("Preparing image"); input0().request(0, 0, width(), height(), channels, 1); if (aborted()) return; ImageSpec srcSpec(width(), height(), chanCount, TypeDesc::FLOAT); ImageBuf srcBuffer(srcSpec); Row row(0, width()); // Buffer for a channel-interleaved row after output LUT processing std::vector<float> lutBuffer(width() * chanCount); for (int y = 0; y < height(); y++) { iop->progressFraction(double(y) / height() * 0.85); get(height() - y - 1, 0, width(), channels, row); if (aborted()) return; const float* alpha = doAlpha ? row[Chan_Alpha] : NULL; for (int i = 0; i < chanCount; i++) to_float(i, &lutBuffer[i], row[channel(i)], alpha, width(), chanCount); for (int x = 0; x < width(); x++) srcBuffer.setpixel(x, y, &lutBuffer[x * chanCount]); } ImageSpec destSpec(width(), height(), chanCount, oiioBitDepths[bitDepth_]); setChannelNames(destSpec, channels); destSpec.attribute("maketx:filtername", gFilterNames[filter_]); switch (preset_) { case 0: destSpec.attribute("maketx:oiio_options", 1); break; case 1: destSpec.attribute("maketx:prman_options", 1); break; default: destSpec.tile_width = tileW_; destSpec.tile_height = tileH_; destSpec.attribute("planarconfig", planarMode_ ? "separate" : "contig"); break; } if (fixNan_) { if (nanFixType_) destSpec.attribute("maketx:fixnan", "box3"); else destSpec.attribute("maketx:fixnan", "black"); } else destSpec.attribute("maketx:fixnan", "none"); destSpec.attribute("maketx:checknan", checkNan_); destSpec.attribute("maketx:verbose", verbose_); destSpec.attribute("maketx:stats", stats_); OIIO::attribute("threads", (int)Thread::numCPUs); if (aborted()) return; iop->progressMessage("Writing %s", filename()); if (!ImageBufAlgo::make_texture(oiiotxMode[txMode_], srcBuffer, filename(), destSpec, &std::cout)) iop->critical("ImageBufAlgo::make_texture failed to write file %s", filename()); }
void _validate(bool for_real) { // do we need to open a port? if ( m_server.isConnected()==false && !m_inError && m_legit ) changePort(m_port); if (m_stat.progress > 0) status(m_stat.progress, m_stat.ram, m_stat.p_ram, m_stat.time); // handle any connection error if ( m_inError ) error(m_connectionError.c_str()); // setup format etc info_.format(*m_fmtp.fullSizeFormat()); info_.full_size_format(*m_fmtp.format()); // add aovs as nuke channels std::string rgba = "RGBA"; std::string z = "Z"; std::string n = "N"; std::string p = "P"; for(std::vector<std::string>::iterator it = m_aovs.begin(); it != m_aovs.end(); ++it) { if (it->compare(rgba)==0) { if (!m_channels.contains(Chan_Red)) { m_channels.insert(Chan_Red); m_channels.insert(Chan_Green); m_channels.insert(Chan_Blue); m_channels.insert(Chan_Alpha); } } else if (it->compare(z)==0) { if (!m_channels.contains(Chan_Z)) m_channels.insert( Chan_Z ); } else if (it->compare(n)==0 || it->compare(p)==0) { if (!m_channels.contains(channel((boost::format("%s.X")%it->c_str()).str().c_str()))) { m_channels.insert( channel((boost::format("%s.X")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.Y")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.Z")%it->c_str()).str().c_str()) ); } } else { if (!m_channels.contains( channel((boost::format("%s.red")%it->c_str()).str().c_str()))) { m_channels.insert( channel((boost::format("%s.red")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.blue")%it->c_str()).str().c_str()) ); m_channels.insert( channel((boost::format("%s.green")%it->c_str()).str().c_str()) ); } } } info_.channels( m_channels ); info_.set(info().format()); }