MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenImageIO / IBAprep

Method IBAprep

src/libOpenImageIO/imagebufalgo.cpp:105–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104
105bool
106ImageBufAlgo::IBAprep (ROI &roi, ImageBuf *dst,
107 const ImageBuf *A, const ImageBuf *B,
108 ImageSpec *force_spec, int prepflags)
109{
110 if ((A && !A->initialized()) || (B && !B->initialized())) {
111 if (dst)
112 dst->error ("Uninitialized input image");
113 return false;
114 }
115 if (dst->initialized()) {
116 // Valid destination image. Just need to worry about ROI.
117 if (roi.defined()) {
118 // Shrink-wrap ROI to the destination (including chend)
119 roi = roi_intersection (roi, get_roi(dst->spec()));
120 } else {
121 // No ROI? Set it to all of dst's pixel window.
122 roi = get_roi (dst->spec());
123 }
124 // If the dst is initialized but is a cached image, we'll need
125 // to fully read it into allocated memory so that we're able
126 // to write to it subsequently.
127 if (dst->storage() == ImageBuf::IMAGECACHE) {
128 dst->read (dst->subimage(), dst->miplevel(), true /*force*/);
129 ASSERT (dst->storage() == ImageBuf::LOCALBUFFER);
130 }
131 } else {
132 // Not an initialized destination image!
133 ASSERT ((A || roi.defined()) &&
134 "ImageBufAlgo without any guess about region of interest");
135 ROI full_roi;
136 if (! roi.defined()) {
137 // No ROI -- make it the union of the pixel regions of the inputs
138 roi = get_roi (A->spec());
139 full_roi = get_roi_full (A->spec());
140 if (B) {
141 roi = roi_union (roi, get_roi (B->spec()));
142 full_roi = roi_union (full_roi, get_roi_full (B->spec()));
143 }
144 } else {
145 if (A)
146 roi.chend = std::min (roi.chend, A->nchannels());
147 full_roi = roi;
148 }
149 // Now we allocate space for dst. Give it A's spec, but adjust
150 // the dimensions to match the ROI.
151 ImageSpec spec;
152 if (A) {
153 // If there's an input image, give dst A's spec (with
154 // modifications detailed below...)
155 spec = force_spec ? (*force_spec) : A->spec();
156 // For two inputs, if they aren't the same data type, punt and
157 // allocate a float buffer. If the user wanted something else,
158 // they should have pre-allocated dst with their desired format.
159 if (B && A->spec().format != B->spec().format)
160 spec.set_format (TypeDesc::FLOAT);
161 // No good can come from automatically polluting an ImageBuf
162 // with some other ImageBuf's tile sizes.

Callers

nothing calls this directly

Calls 15

roi_intersectionFunction · 0.85
get_roiFunction · 0.85
get_roi_fullFunction · 0.85
roi_unionFunction · 0.85
set_roiFunction · 0.85
set_roi_fullFunction · 0.85
definedMethod · 0.80
default_channel_namesMethod · 0.80
erase_attributeMethod · 0.80
initializedMethod · 0.45
errorMethod · 0.45
specMethod · 0.45

Tested by

no test coverage detected