IC is even more restrictive than IB -- not only are all channels of an image 
stored as a single data format in the in-memory cache tiles, but in fact only a 
few types are allowed (I think uint8, uint16, half, and float) and anything 
else will be translated to one of those as the tiles are read into the cache.


> On Jul 28, 2021, at 2:23 PM, Anders Langlands <anderslangla...@gmail.com> 
> wrote:
> 
> Thanks Larry, yeah my question was really about whether I need to handle the 
> possibility of multiple types per pixel in the Rust API (which would be 
> gnarly). Does the same apply for ImageCache?
> 
> On Thu, 29 Jul 2021 at 09:05, Larry Gritz <l...@larrygritz.com 
> <mailto:l...@larrygritz.com>> wrote:
> ImageBuf stores one data type for all channels. It's a purposeful constraint 
> to simplify both the internals and the use of ImageBuf. (Just imagine the 
> extra complexity of any ImageBufAlgo function if it had to work correctly for 
> any mix of channel types within the same image.)
> 
> Upon reading a file in, it will choose the "smallest" type that can represent 
> all the channel types in the file (e.g., if an exr file that's a mix of float 
> and half, the ImageBuf will be float, but if it was all half channels, the IB 
> will be half).
> 
> But an ImageBuf remembers the types in the original file it read from (this 
> is partly what spec() vs nativespec() does), so when you call ib->write() to 
> save it as a file again, it will return everything to the original types. 
> That way, a file -> IB -> file round trip doesn't screw up the data types of 
> the files.
> 
> If you want in-memory per-channel formats, you need to manage your own 
> buffers and use ImageInput methods to read the truly native types (pass the 
> requested format as 'TypeUnknown' to mean "don't do any translation, keep the 
> original data types."
> 
> 
> 
>> On Jul 28, 2021, at 1:54 PM, Anders Langlands <anderslangla...@gmail.com 
>> <mailto:anderslangla...@gmail.com>> wrote:
>> 
> 
> 
>> Apologies if this is in the docs, but I haven't found a clear answer so far. 
>> Are images in an ImageBuf and an ImageCache stored in memory with the same 
>> type for each channel of a given subimage? Or might different channels have 
>> different types? 
>> 
>> Cheers,
>> Anders
> 
>> _______________________________________________
>> Oiio-dev mailing list
>> Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org>
>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
>> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
> 
> --
> Larry Gritz
> l...@larrygritz.com <mailto:l...@larrygritz.com>
> 
> 
> 
> 
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org>
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
> _______________________________________________
> Oiio-dev mailing list
> Oiio-dev@lists.openimageio.org
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

--
Larry Gritz
l...@larrygritz.com




_______________________________________________
Oiio-dev mailing list
Oiio-dev@lists.openimageio.org
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to