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

Method read_tiles

src/python/py_imageinput.cpp:334–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332
333
334object
335ImageInputWrap::read_tiles (int xbegin, int xend, int ybegin, int yend,
336 int zbegin, int zend, int chbegin, int chend,
337 TypeDesc format)
338{
339 // Allocate our own temp buffer and try to read the scanline into it.
340 // If the read fails, return None.
341 const ImageSpec &spec = m_input->spec();
342 chend = clamp (chend, chbegin+1, spec.nchannels);
343 int nchans = chend - chbegin;
344 size_t size = (size_t) ((xend-xbegin) * (yend-ybegin) *
345 (zend-zbegin) * nchans * format.size());
346 char *data = new char[size];
347 if (!m_input->read_tiles (xbegin, xend, ybegin, yend,
348 zbegin, zend, chbegin, chend, format, data)) {
349 delete [] data; // never mind
350 return object(handle<>(Py_None));
351 }
352
353 object array = C_array_to_Python_array (data, format, size);
354
355 // clean up and return the array handle
356 delete [] data;
357 return array;
358}
359
360
361object

Callers 3

test_readimageFunction · 0.80

Calls 4

clampFunction · 0.85
C_array_to_Python_arrayFunction · 0.85
specMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_readimageFunction · 0.64