示例#1
0
// tells the host what region we are capable of filling
OfxStatus getSpatialRoD(OfxImageEffectHandle effect, OfxPropertySetHandle inArgs, OfxPropertySetHandle outArgs)
{
	OfxStatus status = kOfxStatOK;

	// retrieve any instance data associated with this effect
	Instance *instance = getInstanceData(effect);

	// Read the mas now
	bool black;
	const std::string finalName = computeFinalName (inArgs, instance, black);

	try 
	{
		DeepScanLineInputFile file (finalName.c_str ());
		const Header& header = file.header();
		const Box2i displayWindow = header.displayWindow();
		const Box2i dataWindow = header.dataWindow();
		const int w = dataWindow.max.x+1-dataWindow.min.x;
		const int h = dataWindow.max.y+1-dataWindow.min.y;
		const int imageH = displayWindow.max.y+1;
		const int xMin = dataWindow.min.x;
		const int yMin = imageH-dataWindow.max.y-1;
		const double res[] = {(double)xMin, (double)yMin, (double)(xMin+w), (double)(yMin+h)};
		gPropHost->propSetDoubleN(outArgs, kOfxImageEffectPropRegionOfDefinition, 4, res);
	}
	catch (const std::exception &e)
	{
		std::cerr << e.what () << std::endl;
		status = kOfxStatFailed;
	}

	return status;
}
示例#2
0
void
DeepScanLineOutputFile::copyPixels (DeepScanLineInputFile &in)
{

    Lock lock (*_data->_streamData);

    //
    // Check if this file's and and the InputFile's
    // headers are compatible.
    //

    const Header &hdr = _data->header;
    const Header &inHdr = in.header();

    if(!inHdr.hasType() || inHdr.type()!=DEEPSCANLINE)
    {
        THROW (IEX_NAMESPACE::ArgExc, "Cannot copy pixels from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\": the input needs to be a deep scanline image");
    }
    if (!(hdr.dataWindow() == inHdr.dataWindow()))
        THROW (IEX_NAMESPACE::ArgExc, "Cannot copy pixels from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\". "
               "The files have different data windows.");

    if (!(hdr.lineOrder() == inHdr.lineOrder()))
        THROW (IEX_NAMESPACE::ArgExc, "Quick pixel copy from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\" failed. "
               "The files have different line orders.");

    if (!(hdr.compression() == inHdr.compression()))
        THROW (IEX_NAMESPACE::ArgExc, "Quick pixel copy from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\" failed. "
               "The files use different compression methods.");

    if (!(hdr.channels() == inHdr.channels()))
        THROW (IEX_NAMESPACE::ArgExc, "Quick pixel copy from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\" failed.  "
               "The files have different channel lists.");

    //
    // Verify that no pixel data have been written to this file yet.
    //

    const Box2i &dataWindow = hdr.dataWindow();

    if (_data->missingScanLines != dataWindow.max.y - dataWindow.min.y + 1)
        THROW (IEX_NAMESPACE::LogicExc, "Quick pixel copy from image "
               "file \"" << in.fileName() << "\" to image "
               "file \"" << fileName() << "\" failed. "
               "\"" << fileName() << "\" already contains "
               "pixel data.");

    //
    // Copy the pixel data.
    //

    vector<char> data(4096);

    while (_data->missingScanLines > 0)
    {
        Int64 dataSize = (Int64) data.size();
        in.rawPixelData(_data->currentScanLine, &data[0], dataSize);
        if(dataSize > data.size())
        {
            // block wasn't big enough - go again with enough memory this time
            data.resize(dataSize);
            in.rawPixelData(_data->currentScanLine, &data[0], dataSize);
        }

        // extract header from block to pass to writePixelData

        Int64 packedSampleCountSize = *(Int64 *) (&data[4]);
        Int64 packedDataSize = *(Int64 *) (&data[12]);
        Int64 unpackedDataSize = *(Int64 *) (&data[20]);
        const char * sampleCountTable = &data[0]+28;
        const char * pixelData = sampleCountTable + packedSampleCountSize;


        writePixelData (_data->_streamData, _data, lineBufferMinY (_data->currentScanLine,
                        _data->minY,
                        _data->linesInBuffer),
                        pixelData, packedDataSize, unpackedDataSize,sampleCountTable,packedSampleCountSize);

        _data->currentScanLine += (_data->lineOrder == INCREASING_Y)?
                                  _data->linesInBuffer: -_data->linesInBuffer;

        _data->missingScanLines -= _data->linesInBuffer;
    }
}