// construction based on clip instance Image::Image(ClipInstance& instance, double renderScaleX, double renderScaleY, void* data, const OfxRectI &bounds, const OfxRectI &rod, int rowBytes, std::string field, std::string uniqueIdentifier) : Property::Set(imageStuffs) , _referenceCount(1) { getClipBits(instance); // set other data setDoubleProperty(kOfxImageEffectPropRenderScale,renderScaleX, 0); setDoubleProperty(kOfxImageEffectPropRenderScale,renderScaleY, 1); setPointerProperty(kOfxImagePropData,data); setIntProperty(kOfxImagePropBounds,bounds.x1, 0); setIntProperty(kOfxImagePropBounds,bounds.y1, 1); setIntProperty(kOfxImagePropBounds,bounds.x2, 2); setIntProperty(kOfxImagePropBounds,bounds.y2, 3); setIntProperty(kOfxImagePropRegionOfDefinition,rod.x1, 0); setIntProperty(kOfxImagePropRegionOfDefinition,rod.y1, 1); setIntProperty(kOfxImagePropRegionOfDefinition,rod.x2, 2); setIntProperty(kOfxImagePropRegionOfDefinition,rod.y2, 3); setIntProperty(kOfxImagePropRowBytes,rowBytes); setStringProperty(kOfxImagePropField,field); setStringProperty(kOfxImageClipPropFieldOrder,field); setStringProperty(kOfxImagePropUniqueIdentifier,uniqueIdentifier); }
// construction based on clip instance Image::Image(ClipInstance& instance, double renderScaleX, double renderScaleY, void* data, const OfxRectI &bounds, const OfxRectI &rod, int rowBytes, std::string field, std::string uniqueIdentifier) : ImageBase(instance, renderScaleX, renderScaleY, bounds, rod, rowBytes, field, uniqueIdentifier) { addProperties(imageStuffs); // set other data setPointerProperty(kOfxImagePropData,data); }
/// images are always SD PAL progressive full res images for the purpose of this example only MyImage::MyImage(MyClipInstance &clip, OfxTime time, int view) : OFX::Host::ImageEffect::Image(clip) /// this ctor will set basic props on the image , _data(NULL) { // make some memory _data = new OfxRGBAColourB[kPalSizeXPixels * kPalSizeYPixels] ; /// PAL SD RGBA int fillValue = (int)(floor(255.0 * (time/OFXHOSTDEMOCLIPLENGTH))) & 0xff; OfxRGBAColourB color; #ifdef OFX_EXTENSIONS_VEGAS color.r = view == 0 ? fillValue : 0; color.g = view == 1 ? fillValue : 0; color.b = view == 1 ? fillValue : 0; #else color.r = color.g = color.b = fillValue; #endif color.a = 255; std::fill(_data, _data + kPalSizeXPixels * kPalSizeYPixels, color); // draw the time and the view number in reverse color const int scale = 5; const int charwidth = 4*scale; #ifdef OFX_EXTENSIONS_VEGAS color.r = view == 0 ? 255-fillValue : 0; color.g = view == 1 ? 255-fillValue : 0; color.b = view == 1 ? 255-fillValue : 0; #else color.r = color.g = color.b = 255-fillValue; #endif int xx = 50; int yy = 50; int d; d = (int(time)/10)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = int(time)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = 10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx += charwidth; d = int(time*10)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); xx = 50; yy += 8*scale; d = int(view)%10; drawDigit(_data, kPalSizeXPixels, kPalSizeYPixels, d, xx, yy, scale, color); // render scale x and y of 1.0 setDoubleProperty(kOfxImageEffectPropRenderScale, 1.0, 0); setDoubleProperty(kOfxImageEffectPropRenderScale, 1.0, 1); // data ptr setPointerProperty(kOfxImagePropData,_data); // bounds and rod setIntProperty(kOfxImagePropBounds, kPalRegionPixels.x1, 0); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.y1, 1); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.x2, 2); setIntProperty(kOfxImagePropBounds, kPalRegionPixels.y2, 3); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.x1, 0); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.y1, 1); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.x2, 2); setIntProperty(kOfxImagePropRegionOfDefinition, kPalRegionPixels.y2, 3); // row bytes setIntProperty(kOfxImagePropRowBytes, kPalSizeXPixels * sizeof(OfxRGBAColourB)); }