Skip to content

Commit eadfc2e

Browse files
committed
Amendment: get rid of z parameter to write_scanline
Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 0c4d8d3 commit eadfc2e

3 files changed

Lines changed: 20 additions & 24 deletions

File tree

src/include/OpenImageIO/imageio.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,16 +2321,16 @@ class OIIO_API ImageOutput {
23212321
return write_image(ispan);
23222322
}
23232323

2324-
/// Write one scanline that include pixels (*,y,z) from `data`, which is
2325-
/// an `image_span` of un-typed bytes incorporating its bounded dimensions
2324+
/// Write one scanline that include pixels (*,y) from `data`, which is an
2325+
/// `image_span` of un-typed bytes incorporating its bounded dimensions
23262326
/// and strides. The data type is given explicity by the `format`
23272327
/// argument, and will be automatically converted to the type being stored
23282328
/// in the file.
23292329
///
23302330
/// The image_span must have a width equal to a full scanline width,
23312331
/// and its height and depth must be 1.
23322332
///
2333-
/// @param y/z The y & z coordinates of the scanline.
2333+
/// @param y The y coordinate of the scanline.
23342334
/// @param format A TypeDesc describing the type of the pixel data
23352335
/// that `data`'s memory contains. Use `TypeUnknown`
23362336
/// to indicate that the data is already in the native
@@ -2340,34 +2340,32 @@ class OIIO_API ImageOutput {
23402340
/// dimension (channel, x, y, z).
23412341
/// @returns `true` upon success, or `false` upon failure.
23422342
///
2343-
virtual bool write_scanline(int y, int z, TypeDesc format,
2343+
virtual bool write_scanline(int y, TypeDesc format,
23442344
const image_span<const std::byte>& data);
23452345

23462346
/// A version of `write_scanline()` taking an `image_span<T>`, where the
23472347
/// type of the underlying data is `T`. This is a convenience wrapper
23482348
/// around the `write_scanline()` that takes an `image_span<const
23492349
/// std::byte>`.
2350-
template<typename T>
2351-
bool write_scanline(int y, int z, const image_span<T>& data)
2350+
template<typename T> bool write_scanline(int y, const image_span<T>& data)
23522351
{
23532352
// reduce to type + image_span<byte>
2354-
return write_scanline(y, z, TypeDescFromC<T>::value(),
2353+
return write_scanline(y, TypeDescFromC<T>::value(),
23552354
as_image_span_bytes(data));
23562355
}
23572356

23582357
/// A version of `write_scanline()` taking a `cspan<T>`, which assumes
23592358
/// contiguous strides in all dimensions. This is a convenience wrapper
23602359
/// around the `write_scanline()` that takes an `image_span<const T>`.
2361-
template<typename T> bool write_scanline(int y, int z, span<T> data)
2360+
template<typename T> bool write_scanline(int y, span<T> data)
23622361
{
23632362
// reduce to type + image_span<byte>
23642363
auto isize = m_spec.image_bytes(TypeDescFromC<T>::value());
2365-
return write_scanline(y, z,
2366-
image_span<T>(data.data(), m_spec.nchannels,
2367-
m_spec.width, 1, 1));
2364+
return write_scanline(y, image_span<T>(data.data(), m_spec.nchannels,
2365+
m_spec.width, 1, 1));
23682366
}
23692367

2370-
/// Write multiple scanlines that include pixels (*,y,z) for all `ybegin
2368+
/// Write multiple scanlines that include pixels (*,y) for all `ybegin
23712369
/// <= y < yend`, from `data`, which is an `image_span` of un-typed bytes
23722370
/// incorporating its bounded dimensions and strides. The data type is
23732371
/// given explicity by the `format` argument, and will be automatically
@@ -2380,7 +2378,6 @@ class OIIO_API ImageOutput {
23802378
/// and its height must be yend - ybegin.
23812379
///
23822380
/// @param ybegin/yend The y range of the scanlines being passed.
2383-
/// @param z The z coordinate of the scanline.
23842381
/// @param format A TypeDesc describing the type of the pixel data
23852382
/// that `data`'s memory contains. Use `TypeUnknown`
23862383
/// to indicate that the data is already in the native
@@ -2390,32 +2387,32 @@ class OIIO_API ImageOutput {
23902387
/// dimension (channel, x, y, z).
23912388
/// @returns `true` upon success, or `false` upon failure.
23922389
///
2393-
virtual bool write_scanlines(int ybegin, int yend, int z, TypeDesc format,
2390+
virtual bool write_scanlines(int ybegin, int yend, TypeDesc format,
23942391
const image_span<const std::byte>& data);
23952392

23962393
/// A version of `write_scanlines()` taking an `image_span<T>`, where the
23972394
/// type of the underlying data is `T`. This is a convenience wrapper
23982395
/// around the `write_scanlines()` that takes an `image_span<const
23992396
/// std::byte>`.
24002397
template<typename T>
2401-
bool write_scanlines(int ybegin, int yend, int z, const image_span<T>& data)
2398+
bool write_scanlines(int ybegin, int yend, const image_span<T>& data)
24022399
{
24032400
// image_span<T>: reduces to type + byte_buffer
2404-
return write_scanlines(ybegin, yend, z, TypeDescFromC<T>::value(),
2401+
return write_scanlines(ybegin, yend, TypeDescFromC<T>::value(),
24052402
data.as_image_span_bytes());
24062403
}
24072404

24082405
/// A version of `write_scanlines()` taking a `cspan<T>`, which assumes
24092406
/// contiguous strides in all dimensions. This is a convenience wrapper
24102407
/// around the `write_scanlines()` that takes an `image_span<const T>`.
24112408
template<typename T>
2412-
bool write_scanlines(int ybegin, int yend, int z, span<T> data)
2409+
bool write_scanlines(int ybegin, int yend, span<T> data)
24132410
{
24142411
auto ispan = image_span<T>(data.data(), m_spec.nchannels, m_spec.width,
24152412
yend - ybegin, 1);
24162413
OIIO_DASSERT(data.size_bytes() == ispan.size_bytes()
24172414
&& ispan.is_contiguous());
2418-
return write_scanlines(ybegin, yend, z, ispan);
2415+
return write_scanlines(ybegin, yend, ispan);
24192416
}
24202417

24212418

src/libOpenImageIO/imageoutput.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ ImageOutput::write_scanline(int /*y*/, int /*z*/, TypeDesc /*format*/,
111111

112112

113113
bool
114-
ImageOutput::write_scanline(int y, int z, TypeDesc format,
114+
ImageOutput::write_scanline(int y, TypeDesc format,
115115
const image_span<const std::byte>& data)
116116
{
117117
size_t sz = (format == TypeUnknown ? m_spec.pixel_bytes(true /*native*/)
@@ -125,7 +125,7 @@ ImageOutput::write_scanline(int y, int z, TypeDesc format,
125125
}
126126

127127
// Default implementation (for now): call the old pointer+stride
128-
return write_scanline(y, z, format, data.data(), data.xstride());
128+
return write_scanline(y, 0, format, data.data(), data.xstride());
129129
}
130130

131131

@@ -153,7 +153,7 @@ ImageOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format,
153153

154154

155155
bool
156-
ImageOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format,
156+
ImageOutput::write_scanlines(int ybegin, int yend, TypeDesc format,
157157
const image_span<const std::byte>& data)
158158
{
159159
size_t sz = (format == TypeUnknown ? m_spec.pixel_bytes(true /*native*/)
@@ -167,7 +167,7 @@ ImageOutput::write_scanlines(int ybegin, int yend, int z, TypeDesc format,
167167
}
168168

169169
// Default implementation (for now): call the old pointer+stride
170-
return write_scanlines(ybegin, yend, z, format, data.data(), data.xstride(),
170+
return write_scanlines(ybegin, yend, 0, format, data.data(), data.xstride(),
171171
data.ystride());
172172
}
173173

testsuite/docs-examples-cpp/src/docs-examples-imageoutput.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ scanlines_write()
7070
// BEGIN-imageoutput-scanlines
7171
std::vector<unsigned char> scanline(xres * channels);
7272
out->open(filename, spec);
73-
int z = 0; // Always zero for 2D images
7473
for (int y = 0; y < yres; ++y) {
7574
// ... generate data in scanline[0..xres*channels-1] ...
76-
out->write_scanline(y, z, make_span(scanline));
75+
out->write_scanline(y, make_span(scanline));
7776
}
7877
out->close();
7978
// END-imageoutput-scanlines

0 commit comments

Comments
 (0)