@@ -60,75 +60,55 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
6060 im -> ysize = ysize ;
6161 im -> refcount = 1 ;
6262 im -> type = IMAGING_TYPE_UINT8 ;
63- strcpy (im -> arrow_band_format , "C" );
6463
6564 if (mode == IMAGING_MODE_1 ) {
6665 /* 1-bit images */
6766 im -> bands = im -> pixelsize = 1 ;
6867 im -> linesize = xsize ;
69- strcpy (im -> band_names [0 ], "1" );
7068
7169 } else if (mode == IMAGING_MODE_P ) {
7270 /* 8-bit palette mapped images */
7371 im -> bands = im -> pixelsize = 1 ;
7472 im -> linesize = xsize ;
7573 im -> palette = ImagingPaletteNew (IMAGING_MODE_RGB );
76- strcpy (im -> band_names [0 ], "P" );
7774
7875 } else if (mode == IMAGING_MODE_PA ) {
7976 /* 8-bit palette with alpha */
8077 im -> bands = 2 ;
8178 im -> pixelsize = 4 ; /* store in image32 memory */
8279 im -> linesize = xsize * 4 ;
8380 im -> palette = ImagingPaletteNew (IMAGING_MODE_RGB );
84- strcpy (im -> band_names [0 ], "P" );
85- strcpy (im -> band_names [1 ], "X" );
86- strcpy (im -> band_names [2 ], "X" );
87- strcpy (im -> band_names [3 ], "A" );
8881
8982 } else if (mode == IMAGING_MODE_L ) {
9083 /* 8-bit grayscale (luminance) images */
9184 im -> bands = im -> pixelsize = 1 ;
9285 im -> linesize = xsize ;
93- strcpy (im -> band_names [0 ], "L" );
9486
9587 } else if (mode == IMAGING_MODE_LA ) {
9688 /* 8-bit grayscale (luminance) with alpha */
9789 im -> bands = 2 ;
9890 im -> pixelsize = 4 ; /* store in image32 memory */
9991 im -> linesize = xsize * 4 ;
100- strcpy (im -> band_names [0 ], "L" );
101- strcpy (im -> band_names [1 ], "X" );
102- strcpy (im -> band_names [2 ], "X" );
103- strcpy (im -> band_names [3 ], "A" );
10492
10593 } else if (mode == IMAGING_MODE_La ) {
10694 /* 8-bit grayscale (luminance) with premultiplied alpha */
10795 im -> bands = 2 ;
10896 im -> pixelsize = 4 ; /* store in image32 memory */
10997 im -> linesize = xsize * 4 ;
110- strcpy (im -> band_names [0 ], "L" );
111- strcpy (im -> band_names [1 ], "X" );
112- strcpy (im -> band_names [2 ], "X" );
113- strcpy (im -> band_names [3 ], "a" );
11498
11599 } else if (mode == IMAGING_MODE_F ) {
116100 /* 32-bit floating point images */
117101 im -> bands = 1 ;
118102 im -> pixelsize = 4 ;
119103 im -> linesize = xsize * 4 ;
120104 im -> type = IMAGING_TYPE_FLOAT32 ;
121- strcpy (im -> arrow_band_format , "f" );
122- strcpy (im -> band_names [0 ], "F" );
123105
124106 } else if (mode == IMAGING_MODE_I ) {
125107 /* 32-bit integer images */
126108 im -> bands = 1 ;
127109 im -> pixelsize = 4 ;
128110 im -> linesize = xsize * 4 ;
129111 im -> type = IMAGING_TYPE_INT32 ;
130- strcpy (im -> arrow_band_format , "i" );
131- strcpy (im -> band_names [0 ], "I" );
132112
133113 } else if (isModeI16 (mode )) {
134114 /* EXPERIMENTAL */
@@ -137,86 +117,52 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
137117 im -> pixelsize = 2 ;
138118 im -> linesize = xsize * 2 ;
139119 im -> type = IMAGING_TYPE_SPECIAL ;
140- strcpy (im -> arrow_band_format , "s" );
141- strcpy (im -> band_names [0 ], "I" );
142120
143121 } else if (mode == IMAGING_MODE_RGB ) {
144122 /* 24-bit true colour images */
145123 im -> bands = 3 ;
146124 im -> pixelsize = 4 ;
147125 im -> linesize = xsize * 4 ;
148- strcpy (im -> band_names [0 ], "R" );
149- strcpy (im -> band_names [1 ], "G" );
150- strcpy (im -> band_names [2 ], "B" );
151- strcpy (im -> band_names [3 ], "X" );
152126
153127 } else if (mode == IMAGING_MODE_RGBX ) {
154128 /* 32-bit true colour images with padding */
155129 im -> bands = im -> pixelsize = 4 ;
156130 im -> linesize = xsize * 4 ;
157- strcpy (im -> band_names [0 ], "R" );
158- strcpy (im -> band_names [1 ], "G" );
159- strcpy (im -> band_names [2 ], "B" );
160- strcpy (im -> band_names [3 ], "X" );
161131
162132 } else if (mode == IMAGING_MODE_RGBA ) {
163133 /* 32-bit true colour images with alpha */
164134 im -> bands = im -> pixelsize = 4 ;
165135 im -> linesize = xsize * 4 ;
166- strcpy (im -> band_names [0 ], "R" );
167- strcpy (im -> band_names [1 ], "G" );
168- strcpy (im -> band_names [2 ], "B" );
169- strcpy (im -> band_names [3 ], "A" );
170136
171137 } else if (mode == IMAGING_MODE_RGBa ) {
172138 /* 32-bit true colour images with premultiplied alpha */
173139 im -> bands = im -> pixelsize = 4 ;
174140 im -> linesize = xsize * 4 ;
175- strcpy (im -> band_names [0 ], "R" );
176- strcpy (im -> band_names [1 ], "G" );
177- strcpy (im -> band_names [2 ], "B" );
178- strcpy (im -> band_names [3 ], "a" );
179141
180142 } else if (mode == IMAGING_MODE_CMYK ) {
181143 /* 32-bit colour separation */
182144 im -> bands = im -> pixelsize = 4 ;
183145 im -> linesize = xsize * 4 ;
184- strcpy (im -> band_names [0 ], "C" );
185- strcpy (im -> band_names [1 ], "M" );
186- strcpy (im -> band_names [2 ], "Y" );
187- strcpy (im -> band_names [3 ], "K" );
188146
189147 } else if (mode == IMAGING_MODE_YCbCr ) {
190148 /* 24-bit video format */
191149 im -> bands = 3 ;
192150 im -> pixelsize = 4 ;
193151 im -> linesize = xsize * 4 ;
194- strcpy (im -> band_names [0 ], "Y" );
195- strcpy (im -> band_names [1 ], "Cb" );
196- strcpy (im -> band_names [2 ], "Cr" );
197- strcpy (im -> band_names [3 ], "X" );
198152
199153 } else if (mode == IMAGING_MODE_LAB ) {
200154 /* 24-bit color, luminance, + 2 color channels */
201155 /* L is uint8, a,b are int8 */
202156 im -> bands = 3 ;
203157 im -> pixelsize = 4 ;
204158 im -> linesize = xsize * 4 ;
205- strcpy (im -> band_names [0 ], "L" );
206- strcpy (im -> band_names [1 ], "a" );
207- strcpy (im -> band_names [2 ], "b" );
208- strcpy (im -> band_names [3 ], "X" );
209159
210160 } else if (mode == IMAGING_MODE_HSV ) {
211161 /* 24-bit color, luminance, + 2 color channels */
212162 /* L is uint8, a,b are int8 */
213163 im -> bands = 3 ;
214164 im -> pixelsize = 4 ;
215165 im -> linesize = xsize * 4 ;
216- strcpy (im -> band_names [0 ], "H" );
217- strcpy (im -> band_names [1 ], "S" );
218- strcpy (im -> band_names [2 ], "V" );
219- strcpy (im -> band_names [3 ], "X" );
220166
221167 } else {
222168 free (im );
@@ -689,6 +635,7 @@ ImagingNewArrow(
689635 if (!im ) {
690636 return NULL ;
691637 }
638+ ModeData * modedata = getModeData (mode );
692639
693640 int64_t pixels = (int64_t )xsize * (int64_t )ysize ;
694641
@@ -699,7 +646,7 @@ ImagingNewArrow(
699646 && im -> pixelsize == 4 // 4xchar* storage
700647 && im -> bands >= 2 ) // INT32 into any INT32 Storage mode
701648 || // (()||()) &&
702- (strcmp (schema -> format , im -> arrow_band_format ) == 0 // same mode
649+ (strcmp (schema -> format , modedata -> arrow_band_format ) == 0 // same mode
703650 && im -> bands == 1 )) // Single band match
704651 && pixels == external_array -> length ) {
705652 // one arrow element per, and it matches a pixelsize*char
@@ -713,7 +660,7 @@ ImagingNewArrow(
713660 && schema -> n_children > 0 // make sure schema is well formed.
714661 && schema -> children // make sure schema is well formed
715662 && strcmp (schema -> children [0 ]-> format , "C" ) == 0 // Expected format
716- && strcmp (im -> arrow_band_format , "C" ) == 0 // Expected Format
663+ && strcmp (modedata -> arrow_band_format , "C" ) == 0 // Expected Format
717664 && pixels == external_array -> length // expected length
718665 && external_array -> n_children == 1 // array is well formed
719666 && external_array -> children // array is well formed
@@ -727,7 +674,7 @@ ImagingNewArrow(
727674 if (strcmp (schema -> format , "C" ) == 0 // uint8
728675 && im -> pixelsize == 4 // storage as 32 bpc
729676 && schema -> n_children == 0 // make sure schema is well formed.
730- && strcmp (im -> arrow_band_format , "C" ) == 0 // expected format
677+ && strcmp (modedata -> arrow_band_format , "C" ) == 0 // expected format
731678 && 4 * pixels == external_array -> length ) { // expected length
732679 // single flat array, interleaved storage.
733680 if (ImagingBorrowArrow (im , external_array , 1 , array_capsule )) {
0 commit comments