@@ -45,7 +45,8 @@ writeRead (
4545 const Array2D<half>& h2out,
4646 const char fileName[],
4747 int width,
48- int height)
48+ int height,
49+ bool manyC)
4950{
5051 //
5152 // Write an image file with three channels, H1, H2 and H3.
@@ -78,6 +79,17 @@ writeRead (
7879 1 , // xSampling
7980 1 ) // ySampling
8081 );
82+ if (manyC)
83+ {
84+ for ( int curc = 0 ; curc < 132 ; ++curc )
85+ {
86+ char cname[32 ];
87+ snprintf (cname, 32 , " c%03d" , curc);
88+ hdr.channels ().insert (
89+ cname,
90+ Channel (HALF , 1 , 1 ));
91+ }
92+ }
8193
8294 {
8395 FrameBuffer fb;
@@ -104,7 +116,10 @@ writeRead (
104116 1 ) // ySampling
105117 );
106118
107- cout << " writing" << flush;
119+ if (manyC)
120+ cout << " Many Channels: writing" << flush;
121+ else
122+ cout << " Values: writing" << flush;
108123
109124 remove (fileName);
110125 OutputFile out (fileName, hdr);
@@ -213,6 +228,41 @@ writeRead (
213228 assert (h4in[y][x] == 3.0 );
214229 }
215230 }
231+
232+ if (manyC)
233+ {
234+ for ( int curc = 0 ; curc < 132 ; ++curc )
235+ {
236+ char cname[32 ];
237+ snprintf (cname, 32 , " c%03d" , curc);
238+
239+ cout << " " << curc << flush;
240+ Array2D<half> testcin (h, w);
241+
242+ FrameBuffer fb;
243+
244+ /* if the channel isn't there, will fill with 3 but we should have 0 */
245+ fb.insert (
246+ cname, // name
247+ Slice (
248+ HALF , // type
249+ (char *) &testcin[-dy][-dx], // base
250+ sizeof (testcin[0 ][0 ]), // xStride
251+ sizeof (testcin[0 ][0 ]) * w, // yStride
252+ 1 , 1 , 3.0 )
253+ );
254+
255+ in.setFrameBuffer (fb);
256+ in.readPixels (dw.min .y , dw.max .y );
257+ for (int y = 0 ; y < h; ++y)
258+ {
259+ for (int x = 0 ; x < w; ++x)
260+ {
261+ assert (testcin[y][x] == 0.0 );
262+ }
263+ }
264+ }
265+ }
216266 }
217267
218268 remove (fileName);
@@ -306,7 +356,8 @@ testChannels (const std::string& tempDir)
306356
307357 std::string filename = tempDir + " imf_test_channels.exr" ;
308358
309- writeRead (ph1, ph2, filename.c_str (), W, H);
359+ writeRead (ph1, ph2, filename.c_str (), W, H, false );
360+ writeRead (ph1, ph2, filename.c_str (), W, H, true );
310361
311362 cout << " ok\n " << endl;
312363 }
0 commit comments