@@ -64,35 +64,45 @@ complete details, but to get started, the "Hello, world" [`exrwriter.cpp`](https
6464 #include <ImfRgbaFile.h>
6565 #include <ImfArray.h>
6666 #include <iostream>
67-
67+
6868 int
6969 main()
7070 {
71+ int width = 100;
72+ int height = 50;
73+
74+ Imf::Array2D<Imf::Rgba> pixels(height, width);
75+ for (int y=0; y<height; y++)
76+ {
77+ float c = (y / 5 % 2 == 0) ? (y / (float) height) : 0.0;
78+ for (int x=0; x<width; x++)
79+ pixels[y][x] = Imf::Rgba(c, c, c);
80+ }
81+
7182 try {
72- int width = 10;
73- int height = 10;
74-
75- Imf::Array2D<Imf::Rgba> pixels(width, height);
76- for (int y=0; y<height; y++)
77- for (int x=0; x<width; x++)
78- pixels[y][x] = Imf::Rgba(0, x / (width-1.0f), y / (height-1.0f));
79-
80- Imf::RgbaOutputFile file ("hello.exr", width, height, Imf::WRITE_RGBA);
83+ Imf::RgbaOutputFile file ("stripes.exr", width, height, Imf::WRITE_RGBA);
8184 file.setFrameBuffer (&pixels[0][0], 1, width);
8285 file.writePixels (height);
8386 } catch (const std::exception &e) {
84- std::cerr << "Unable to read image file hello .exr:" << e.what() << std::endl;
87+ std::cerr << "error writing image file stripes .exr:" << e.what() << std::endl;
8588 return 1;
8689 }
8790 return 0;
8891 }
8992
93+ This creates an image 100 pixels wide and 50 pixels high with
94+ horizontal stripes 5 pixels high of graduated intensity, bright on the
95+ bottom of the image and dark towards the top. Note that `` pixel[0][0] ``
96+ is in the upper left:
97+
98+ ![ stripes] ( website/images/stripes.png )
99+
90100The [ ` CMakeLists.txt ` ] ( https://raw.githubusercontent.com/AcademySoftwareFoundation/openexr/main/website/src/exrwriter/CMakeLists.txt ) to build:
91101
92102 cmake_minimum_required(VERSION 3.12)
93103 project(exrwriter)
94104 find_package(OpenEXR REQUIRED)
95-
105+
96106 add_executable(${PROJECT_NAME} exrwriter.cpp)
97107 target_link_libraries(${PROJECT_NAME} OpenEXR::OpenEXR)
98108
@@ -135,7 +145,7 @@ API](https://openexr.readthedocs.io/en/latest/API.html#the-openexr-api).
135145
136146 - Sign the [ Contributor License
137147 Agreement] ( https://contributor.easycla.lfx.linuxfoundation.org/#/cla/project/2e8710cb-e379-4116-a9ba-964f83618cc5/user/564e571e-12d7-4857-abd4-898939accdd7 )
138-
148+
139149 - Submit a Pull Request: https://github.com/AcademySoftwareFoundation/openexr/pulls
140150
141151# Resources
0 commit comments