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

Method read

src/libOpenImageIO/imagebuf.cpp:757–857  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755
756
757bool
758ImageBufImpl::read (int subimage, int miplevel, bool force, TypeDesc convert,
759 ProgressCallback progress_callback,
760 void *progress_callback_data)
761{
762 if (! m_name.length())
763 return true;
764
765 if (m_pixels_valid && !force &&
766 subimage == m_current_subimage && miplevel == m_current_miplevel)
767 return true;
768
769 if (! init_spec (m_name.string(), subimage, miplevel)) {
770 m_badfile = true;
771 m_spec_valid = false;
772 return false;
773 }
774
775 m_current_subimage = subimage;
776 m_current_miplevel = miplevel;
777
778 if (m_spec.deep) {
779 boost::scoped_ptr<ImageInput> input (ImageInput::open (m_name.string()));
780 if (! input) {
781 error ("%s", OIIO::geterror());
782 return false;
783 }
784 ImageSpec dummyspec;
785 if (! input->seek_subimage (subimage, miplevel, dummyspec)) {
786 error ("%s", input->geterror());
787 return false;
788 }
789 if (! input->read_native_deep_image (m_deepdata)) {
790 error ("%s", input->geterror());
791 return false;
792 }
793 m_spec = m_nativespec; // Deep images always use native data
794 m_pixels_valid = true;
795 m_storage = ImageBuf::LOCALBUFFER;
796 return true;
797 }
798
799 // If we don't already have "local" pixels, and we aren't asking to
800 // convert the pixels to a specific (and different) type, then take an
801 // early out by relying on the cache.
802 int peltype = TypeDesc::UNKNOWN;
803 m_imagecache->get_image_info (m_name, subimage, miplevel,
804 ustring("cachedpixeltype"),
805 TypeDesc::TypeInt, &peltype);
806 m_cachedpixeltype = TypeDesc ((TypeDesc::BASETYPE)peltype);
807 if (! m_localpixels && ! force &&
808 (convert == m_cachedpixeltype || convert == TypeDesc::UNKNOWN)) {
809 m_spec.format = m_cachedpixeltype;
810 m_pixel_bytes = m_spec.pixel_bytes();
811 m_scanline_bytes = m_spec.scanline_bytes();
812 m_plane_bytes = clamped_mult64 (m_scanline_bytes, (imagesize_t)m_spec.height);
813 m_blackpixel.resize (m_pixel_bytes, 0);
814 m_pixels_valid = true;

Callers 7

write_mipmapFunction · 0.45
make_texture_implFunction · 0.45
BOOST_FOREACHFunction · 0.45
test_pixel_iterationFunction · 0.45
validate_pixelsMethod · 0.45
IBAprepMethod · 0.45

Calls 15

openFunction · 0.85
errorFunction · 0.85
TypeDescFunction · 0.85
clamped_mult64Function · 0.85
implFunction · 0.85
pixel_bytesMethod · 0.80
scanline_bytesMethod · 0.80
resizeMethod · 0.80
geterrorFunction · 0.70
seek_subimageMethod · 0.45
geterrorMethod · 0.45
get_image_infoMethod · 0.45

Tested by 3

BOOST_FOREACHFunction · 0.36
test_pixel_iterationFunction · 0.36