Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/include/OpenImageIO/imagebuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,16 @@ class OIIO_API ImageBuf {
void* localpixels();
const void* localpixels() const;

/// Return an `image_span<const std::byte>` giving the extent and layout
/// of "local" pixel memory, if they are fully in RAM and not backed by an
/// ImageCache, or an empty span otherwise.
Comment on lines +1372 to +1374
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[consider] It may be clearer to indicate that the return of this can be inferred from ImageBuf::storage. So for example:

Return an .. if ImageBuf::storage() is Storage::MEMORY`, otherwise ...

Apokogies if I botched that ayntax but hopefully the intention comes across

image_span<const std::byte> localpixels_as_byte_image_span() const;

/// Return an `image_span<std::byte>` giving the extent and layout of
/// "local" pixel memory, if they are fully in RAM and not backed by an
/// ImageCache, and it is a writable IB, or an empty span otherwise.
image_span<std::byte> localpixels_as_writable_byte_image_span() const;

/// Pixel-to-pixel stride within the localpixels memory.
stride_t pixel_stride() const;
/// Scanline-to-scanline stride within the localpixels memory.
Expand Down
16 changes: 16 additions & 0 deletions src/libOpenImageIO/imagebuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,22 @@ ImageBuf::localpixels()



image_span<const std::byte>
ImageBuf::localpixels_as_byte_image_span() const
{
return m_impl->m_bufspan;
}



image_span<std::byte>
ImageBuf::localpixels_as_writable_byte_image_span() const
{
return m_impl->m_readonly ? image_span<std::byte>() : m_impl->m_bufspan;
}



const void*
ImageBuf::localpixels() const
{
Expand Down
Loading