Skip to content

Commit

Permalink
docs: Convert more examples within the imagebufalgo chapter. (#4039)
Browse files Browse the repository at this point in the history
Convert C++ and Python examples from the "Image transformations and data
movement" section of the "imagebufalgo" chapter into tests within the
"docs-examples" testsuites (related to issue #3992).

Update 'oiiotool' tabs to use a simple 'tab' instead of 'code-tab' to
prevent synchronized tab selection, which is inconsistent with the other
tabs using the 'literalinclude' directive.


---------

Signed-off-by: Jeremy Retailleau <[email protected]>
  • Loading branch information
buddly27 authored Sep 11, 2024
1 parent e0a3fce commit 856dc6f
Show file tree
Hide file tree
Showing 12 changed files with 1,314 additions and 412 deletions.
616 changes: 310 additions & 306 deletions src/doc/imagebufalgo.rst

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion testsuite/docs-examples-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set (CMAKE_CXX_EXTENSIONS OFF)

# Make sure we have dependencies we need
find_package (OpenImageIO CONFIG REQUIRED)
find_package (Imath CONFIG REQUIRED)

# Special for OIIO testsuite when running in sanitize mode
if (DEFINED ENV{SANITIZE})
Expand All @@ -34,5 +35,5 @@ set (chapters imageioapi imageoutput imageinput writingplugins
foreach (chapter ${chapters})
add_executable(docs-examples-${chapter} src/docs-examples-${chapter}.cpp)
target_link_libraries (docs-examples-${chapter}
PRIVATE OpenImageIO::OpenImageIO)
PRIVATE OpenImageIO::OpenImageIO Imath::Imath)
endforeach ()
112 changes: 112 additions & 0 deletions testsuite/docs-examples-cpp/ref/out-arm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
example_output_error1
error: Uninitialized input image
example_output_error2
error: Uninitialized input image
example_zero
example_fill
example_checker
example_noise1
example_noise2
example_point
example_lines
example_box
example_text1
example_text2
example_channels
example_channel_append
example_copy
example_crop
example_cut
example_paste
example_rotate_n
example_flip_flop_transpose
example_reorient
example_circular_shift
example_rotate
example_resize
example_resample
example_fit
example_warp
example_make_texture
zero1.exr : 512 x 512, 3 channel, half openexr
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
zero2.exr : 256 x 256, 4 channel, half openexr
SHA-1: 6A521E1D2A632C26E53B83D2CC4B0EDECFC1E68C
zero3.exr : 256 x 256, 4 channel, half openexr
SHA-1: 1254F2956229777B721576B94A6A944ECB806A37
zero4.exr : 256 x 256, 4 channel, half openexr
SHA-1: 36EB49C5102703693C078717CE82AE05D4904680
fill.exr : 640 x 480, 3 channel, half openexr
SHA-1: 1BBCA1D5966D02554C13C1FAEF01F6E6E6169356
checker.exr : 640 x 480, 3 channel, half openexr
SHA-1: 64508259AE242B593B906C848A2D69C443A3FBFD
noise1.exr : 256 x 256, 3 channel, half openexr
SHA-1: 66FF64DDAFDDE290031C20FAA208A193908EE9D4
noise2.exr : 256 x 256, 3 channel, half openexr
SHA-1: 06011F9D59106096F4742A3DAB458D506A08E34C
noise3.exr : 512 x 384, 3 channel, half openexr
SHA-1: 95EDBCA9953281CE63A3E18C7C04BCCB07CB4C8A
noise4.exr : 512 x 384, 3 channel, half openexr
SHA-1: 43BC1FDFA1F18635B635A57D71DB08BB347CBD46
blue-noise.exr : 256 x 256, 4 channel, half openexr
SHA-1: 5A0A51D1AD3F34633B781AFF9B90E59996C31AD0
point.exr : 640 x 480, 4 channel, half openexr
SHA-1: 56E2BDBE03826F203132BD9E80AF44450307BDCE
lines.exr : 640 x 480, 4 channel, half openexr
SHA-1: 177C4C5C61ACDD54F198A45E52836DE897C4CE96
box.exr : 640 x 480, 4 channel, half openexr
SHA-1: 984273B0A06E54873E24A732651490117E40410C
text1.exr : 640 x 480, 3 channel, half openexr
SHA-1: 1CF68F9B099A30EFF06850CEFBEDD3C2F861A654
text2.exr : 640 x 480, 3 channel, half openexr
SHA-1: 00C96AE28FD12752AD1968D3D07EE30F1F218D76
channels-rgba.exr : 256 x 256, 4 channel, half openexr
SHA-1: C823E3701152B4B3C20DD79EA8A20CF4293F4B71
channels-rgb.exr : 256 x 256, 3 channel, half openexr
SHA-1: 4074B050432CE7C664CEC4546A46E74F9A310CDC
channels-brga.exr : 256 x 256, 4 channel, half openexr
SHA-1: 04E09E64C61CEA1634D26FB2E6C733875D163671
channels-alpha.exr : 256 x 256, 1 channel, half openexr
SHA-1: 99C332E70F321F0EA47C0F70AF8B0E3E6524F91F
channel-append.exr : 640 x 480, 5 channel, half openexr
SHA-1: E6A50C80C051F0F587FCB68B515B50E4DC3E9359
copy.exr : 256 x 256, 4 channel, float openexr
SHA-1: 7044589C8B904DAF6A2BA3246224E97DD460AC93
crop.exr : 200 x 100, 4 channel, half openexr
SHA-1: 4DA3918566D087A9D2D9E93B2A7BABE971FE6BBD
cut.exr : 200 x 100, 4 channel, half openexr
SHA-1: 4DA3918566D087A9D2D9E93B2A7BABE971FE6BBD
paste.exr : 256 x 256, 4 channel, half openexr
SHA-1: 67A4C36DEAED98A5A8ABA5F0E0EDE697345DC22A
rotate-90.exr : 256 x 256, 4 channel, half openexr
SHA-1: AFFAEA876E8E7760226B017B0A89A3549B7A5895
rotate-180.exr : 256 x 256, 4 channel, half openexr
SHA-1: A5E42C5F18177DA146EC7E4567E4AE3AE2816C3C
rotate-270.exr : 256 x 256, 4 channel, half openexr
SHA-1: 46C803894186457376A0C590768C9DB4877737BB
flip.exr : 256 x 256, 4 channel, half openexr
SHA-1: A9EB9A8762BCD8DD161C00B01E2DF39E5C91B0D4
flop.exr : 256 x 256, 4 channel, half openexr
SHA-1: 7C10717DB4F2E21F0B4F6D5404C660CA8B504F5E
rotate-45.tif : 256 x 256, 4 channel, uint8 tiff
SHA-1: E2E41264B7BD250C3AACF9F6161A0FA86B22FA57
resize.tif : 320 x 240, 4 channel, uint8 tiff
SHA-1: 6FD1A7A97729CD6D51A22ADE0709CC4DFDC3C826
resample.exr : 320 x 240, 4 channel, half openexr
SHA-1: 16FC7DCFE01DC312593B00B9F90D71BAF3D52450
fit.tif : 240 x 240, 4 channel, uint8 tiff
SHA-1: 5474A93DED5F9F44E561B70A53F509677961AB34
warp.exr : 256 x 256, 4 channel, half openexr
SHA-1: 7EA7EB6798E051B5F4EB3722498371E55869BC91
transpose.exr : 256 x 256, 4 channel, half openexr
SHA-1: FAD57FB60460383D3D2D24B346F35A44846CCC39
reorient.exr : 256 x 256, 4 channel, half openexr
SHA-1: 46C803894186457376A0C590768C9DB4877737BB
cshift.exr : 256 x 256, 4 channel, half openexr
SHA-1: 000F95FDC44D4DBDA8B4041C2506149C7AE28ACA
texture.exr : 256 x 256, 3 channel, half openexr (+mipmap)
SHA-1: 4074B050432CE7C664CEC4546A46E74F9A310CDC
Comparing "simple.tif" and "ref/simple.tif"
PASS
Comparing "scanlines.tif" and "ref/scanlines.tif"
PASS
114 changes: 92 additions & 22 deletions testsuite/docs-examples-cpp/ref/out.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,107 @@
example_output_error1
error: Uninitialized input image
example_output_error2
error: Uninitialized input image
zero1.exr : 512 x 512, 3 channel, float openexr
SHA-1: 1E5F8DEF40BB0CB0F7156B9C2BAB9EFB49CFB699
example_zero
example_fill
example_checker
example_noise1
example_noise2
example_point
example_lines
example_box
example_text1
example_text2
example_channels
example_channel_append
example_copy
example_crop
example_cut
example_paste
example_rotate_n
example_flip_flop_transpose
example_reorient
example_circular_shift
example_rotate
example_resize
example_resample
example_fit
example_warp
example_make_texture
zero1.exr : 512 x 512, 3 channel, half openexr
SHA-1: 95823C334FCE55968E8D2827CCD1CF77CEE19ABD
zero2.exr : 256 x 256, 4 channel, half openexr
SHA-1: 6A521E1D2A632C26E53B83D2CC4B0EDECFC1E68C
zero3.exr : 256 x 256, 4 channel, half openexr
SHA-1: 1254F2956229777B721576B94A6A944ECB806A37
zero4.exr : 256 x 256, 4 channel, half openexr
SHA-1: 36EB49C5102703693C078717CE82AE05D4904680
fill.exr : 640 x 480, 3 channel, float openexr
SHA-1: D517EA07CB6DB931AE4BF6D9E9957EEF9228734E
checker.exr : 640 x 480, 3 channel, float openexr
SHA-1: 87A4424581AAFCE31E6D1134E5025B620B48BBB3
noise1.exr : 256 x 256, 3 channel, float openexr
SHA-1: 9E9278C8F5460068363D36DBD395FA59CA5986DC
noise2.exr : 256 x 256, 3 channel, float openexr
SHA-1: 0A75E8EF38846D8DC5D8BA997EB54F7A36058288
fill.exr : 640 x 480, 3 channel, half openexr
SHA-1: 1BBCA1D5966D02554C13C1FAEF01F6E6E6169356
checker.exr : 640 x 480, 3 channel, half openexr
SHA-1: 64508259AE242B593B906C848A2D69C443A3FBFD
noise1.exr : 256 x 256, 3 channel, half openexr
SHA-1: 66FF64DDAFDDE290031C20FAA208A193908EE9D4
noise2.exr : 256 x 256, 3 channel, half openexr
SHA-1: 06011F9D59106096F4742A3DAB458D506A08E34C
noise3.exr : 512 x 384, 3 channel, half openexr
SHA-1: 95EDBCA9953281CE63A3E18C7C04BCCB07CB4C8A
noise4.exr : 512 x 384, 3 channel, half openexr
SHA-1: 43BC1FDFA1F18635B635A57D71DB08BB347CBD46
blue-noise.exr : 256 x 256, 4 channel, float openexr
SHA-1: 36F448FE29C9DE6CFA65FC0BFCF4178DC66581C4
point.exr : 640 x 480, 4 channel, float openexr
SHA-1: A2AC7CC98AB44798EEEA76C253DE44F6E49FFB8D
lines.exr : 640 x 480, 4 channel, float openexr
SHA-1: 69C0317F92256FD30415D1FE12419DC1C514D818
box.exr : 640 x 480, 4 channel, float openexr
SHA-1: 6CBE5E98B145C5975CB930A91BAEE981C30E6B32
text1.exr : 640 x 480, 3 channel, float openexr
SHA-1: 014ECFC5EBF07F77DF24A592F43BC7CB101534AE
text2.exr : 640 x 480, 3 channel, float openexr
SHA-1: 53359E96A286F909A89ACC99A67A9ED3BADC4A7A
blue-noise.exr : 256 x 256, 4 channel, half openexr
SHA-1: 5A0A51D1AD3F34633B781AFF9B90E59996C31AD0
point.exr : 640 x 480, 4 channel, half openexr
SHA-1: 56E2BDBE03826F203132BD9E80AF44450307BDCE
lines.exr : 640 x 480, 4 channel, half openexr
SHA-1: 177C4C5C61ACDD54F198A45E52836DE897C4CE96
box.exr : 640 x 480, 4 channel, half openexr
SHA-1: 984273B0A06E54873E24A732651490117E40410C
text1.exr : 640 x 480, 3 channel, half openexr
SHA-1: 1CF68F9B099A30EFF06850CEFBEDD3C2F861A654
text2.exr : 640 x 480, 3 channel, half openexr
SHA-1: 00C96AE28FD12752AD1968D3D07EE30F1F218D76
channels-rgba.exr : 256 x 256, 4 channel, half openexr
SHA-1: C823E3701152B4B3C20DD79EA8A20CF4293F4B71
channels-rgb.exr : 256 x 256, 3 channel, half openexr
SHA-1: 4074B050432CE7C664CEC4546A46E74F9A310CDC
channels-brga.exr : 256 x 256, 4 channel, half openexr
SHA-1: 04E09E64C61CEA1634D26FB2E6C733875D163671
channels-alpha.exr : 256 x 256, 1 channel, half openexr
SHA-1: 99C332E70F321F0EA47C0F70AF8B0E3E6524F91F
channel-append.exr : 640 x 480, 5 channel, half openexr
SHA-1: E6A50C80C051F0F587FCB68B515B50E4DC3E9359
copy.exr : 256 x 256, 4 channel, float openexr
SHA-1: 7044589C8B904DAF6A2BA3246224E97DD460AC93
crop.exr : 200 x 100, 4 channel, half openexr
SHA-1: 4DA3918566D087A9D2D9E93B2A7BABE971FE6BBD
cut.exr : 200 x 100, 4 channel, half openexr
SHA-1: 4DA3918566D087A9D2D9E93B2A7BABE971FE6BBD
paste.exr : 256 x 256, 4 channel, half openexr
SHA-1: 67A4C36DEAED98A5A8ABA5F0E0EDE697345DC22A
rotate-90.exr : 256 x 256, 4 channel, half openexr
SHA-1: AFFAEA876E8E7760226B017B0A89A3549B7A5895
rotate-180.exr : 256 x 256, 4 channel, half openexr
SHA-1: A5E42C5F18177DA146EC7E4567E4AE3AE2816C3C
rotate-270.exr : 256 x 256, 4 channel, half openexr
SHA-1: 46C803894186457376A0C590768C9DB4877737BB
flip.exr : 256 x 256, 4 channel, half openexr
SHA-1: A9EB9A8762BCD8DD161C00B01E2DF39E5C91B0D4
flop.exr : 256 x 256, 4 channel, half openexr
SHA-1: 7C10717DB4F2E21F0B4F6D5404C660CA8B504F5E
rotate-45.tif : 256 x 256, 4 channel, uint8 tiff
SHA-1: 2D4AECFD398F9E0AA0051888D0EE7CDC1E438A5A
resize.tif : 320 x 240, 4 channel, uint8 tiff
SHA-1: 6FD1A7A97729CD6D51A22ADE0709CC4DFDC3C826
resample.exr : 320 x 240, 4 channel, half openexr
SHA-1: 5C0CC0A293FCD30B2AE44A0BED7D27DB9B8C8E50
fit.tif : 240 x 240, 4 channel, uint8 tiff
SHA-1: AC77B6A4BFF3E42EB207CFDADEE6BCED4653D2B4
warp.exr : 256 x 256, 4 channel, half openexr
SHA-1: EEB460766F07B47C647D630B568F25FFEEBF5A62
transpose.exr : 256 x 256, 4 channel, half openexr
SHA-1: FAD57FB60460383D3D2D24B346F35A44846CCC39
reorient.exr : 256 x 256, 4 channel, half openexr
SHA-1: 46C803894186457376A0C590768C9DB4877737BB
cshift.exr : 256 x 256, 4 channel, half openexr
SHA-1: 000F95FDC44D4DBDA8B4041C2506149C7AE28ACA
texture.exr : 256 x 256, 3 channel, half openexr (+mipmap)
Expand Down
30 changes: 29 additions & 1 deletion testsuite/docs-examples-cpp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
command += run_app(prefix + "docs-examples-" + chapter)

# hashes merely check that the images don't change, but saves us the space
# of checking in a full copy of the image if it's not needed.
# of checking in a full copy of the image if it's not needed. This is not
# suitable if the image may change slightly from platform to platform or
# with different versions of dependencies, for that we should use the
# full reference image comparison with appropriate thresholds.
hashes = [
# Outputs from the ImageBufAlgo chapter:
"zero1.exr",
Expand All @@ -43,6 +46,27 @@
"box.exr",
"text1.exr",
"text2.exr",
"channels-rgba.exr",
"channels-rgb.exr",
"channels-brga.exr",
"channels-alpha.exr",
"channel-append.exr",
"copy.exr",
"crop.exr",
"cut.exr",
"paste.exr",
"rotate-90.exr",
"rotate-180.exr",
"rotate-270.exr",
"flip.exr",
"flop.exr",
"rotate-45.tif",
"resize.tif",
"resample.exr",
"fit.tif",
"warp.exr",
"transpose.exr",
"reorient.exr",
"cshift.exr",
"texture.exr"
]
Expand All @@ -56,6 +80,10 @@
"simple.tif", "scanlines.tif",
# Outputs from the ImageInput chapter:

# Outputs from the ImageBuf chapter:

# Outputs from the ImageBufAlgo chapter:

# ... etc ... other chapters ...

# Last, we have the out.txt that captures console output of the test
Expand Down
Loading

0 comments on commit 856dc6f

Please sign in to comment.