@@ -65,21 +65,18 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
6565 if (mode == IMAGING_MODE_1 ) {
6666 /* 1-bit images */
6767 im -> bands = im -> pixelsize = 1 ;
68- im -> linesize = xsize ;
6968 strcpy (im -> band_names [0 ], "1" );
7069
7170 } else if (mode == IMAGING_MODE_P ) {
7271 /* 8-bit palette mapped images */
7372 im -> bands = im -> pixelsize = 1 ;
74- im -> linesize = xsize ;
7573 im -> palette = ImagingPaletteNew (IMAGING_MODE_RGB );
7674 strcpy (im -> band_names [0 ], "P" );
7775
7876 } else if (mode == IMAGING_MODE_PA ) {
7977 /* 8-bit palette with alpha */
8078 im -> bands = 2 ;
8179 im -> pixelsize = 4 ; /* store in image32 memory */
82- im -> linesize = xsize * 4 ;
8380 im -> palette = ImagingPaletteNew (IMAGING_MODE_RGB );
8481 strcpy (im -> band_names [0 ], "P" );
8582 strcpy (im -> band_names [1 ], "X" );
@@ -89,14 +86,12 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
8986 } else if (mode == IMAGING_MODE_L ) {
9087 /* 8-bit grayscale (luminance) images */
9188 im -> bands = im -> pixelsize = 1 ;
92- im -> linesize = xsize ;
9389 strcpy (im -> band_names [0 ], "L" );
9490
9591 } else if (mode == IMAGING_MODE_LA ) {
9692 /* 8-bit grayscale (luminance) with alpha */
9793 im -> bands = 2 ;
9894 im -> pixelsize = 4 ; /* store in image32 memory */
99- im -> linesize = xsize * 4 ;
10095 strcpy (im -> band_names [0 ], "L" );
10196 strcpy (im -> band_names [1 ], "X" );
10297 strcpy (im -> band_names [2 ], "X" );
@@ -106,7 +101,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
106101 /* 8-bit grayscale (luminance) with premultiplied alpha */
107102 im -> bands = 2 ;
108103 im -> pixelsize = 4 ; /* store in image32 memory */
109- im -> linesize = xsize * 4 ;
110104 strcpy (im -> band_names [0 ], "L" );
111105 strcpy (im -> band_names [1 ], "X" );
112106 strcpy (im -> band_names [2 ], "X" );
@@ -116,7 +110,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
116110 /* 32-bit floating point images */
117111 im -> bands = 1 ;
118112 im -> pixelsize = 4 ;
119- im -> linesize = xsize * 4 ;
120113 im -> type = IMAGING_TYPE_FLOAT32 ;
121114 strcpy (im -> arrow_band_format , "f" );
122115 strcpy (im -> band_names [0 ], "F" );
@@ -125,7 +118,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
125118 /* 32-bit integer images */
126119 im -> bands = 1 ;
127120 im -> pixelsize = 4 ;
128- im -> linesize = xsize * 4 ;
129121 im -> type = IMAGING_TYPE_INT32 ;
130122 strcpy (im -> arrow_band_format , "i" );
131123 strcpy (im -> band_names [0 ], "I" );
@@ -135,7 +127,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
135127 /* 16-bit raw integer images */
136128 im -> bands = 1 ;
137129 im -> pixelsize = 2 ;
138- im -> linesize = xsize * 2 ;
139130 im -> type = IMAGING_TYPE_SPECIAL ;
140131 strcpy (im -> arrow_band_format , "s" );
141132 strcpy (im -> band_names [0 ], "I" );
@@ -144,7 +135,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
144135 /* 24-bit true colour images */
145136 im -> bands = 3 ;
146137 im -> pixelsize = 4 ;
147- im -> linesize = xsize * 4 ;
148138 strcpy (im -> band_names [0 ], "R" );
149139 strcpy (im -> band_names [1 ], "G" );
150140 strcpy (im -> band_names [2 ], "B" );
@@ -153,7 +143,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
153143 } else if (mode == IMAGING_MODE_RGBX ) {
154144 /* 32-bit true colour images with padding */
155145 im -> bands = im -> pixelsize = 4 ;
156- im -> linesize = xsize * 4 ;
157146 strcpy (im -> band_names [0 ], "R" );
158147 strcpy (im -> band_names [1 ], "G" );
159148 strcpy (im -> band_names [2 ], "B" );
@@ -162,7 +151,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
162151 } else if (mode == IMAGING_MODE_RGBA ) {
163152 /* 32-bit true colour images with alpha */
164153 im -> bands = im -> pixelsize = 4 ;
165- im -> linesize = xsize * 4 ;
166154 strcpy (im -> band_names [0 ], "R" );
167155 strcpy (im -> band_names [1 ], "G" );
168156 strcpy (im -> band_names [2 ], "B" );
@@ -171,7 +159,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
171159 } else if (mode == IMAGING_MODE_RGBa ) {
172160 /* 32-bit true colour images with premultiplied alpha */
173161 im -> bands = im -> pixelsize = 4 ;
174- im -> linesize = xsize * 4 ;
175162 strcpy (im -> band_names [0 ], "R" );
176163 strcpy (im -> band_names [1 ], "G" );
177164 strcpy (im -> band_names [2 ], "B" );
@@ -180,7 +167,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
180167 } else if (mode == IMAGING_MODE_CMYK ) {
181168 /* 32-bit colour separation */
182169 im -> bands = im -> pixelsize = 4 ;
183- im -> linesize = xsize * 4 ;
184170 strcpy (im -> band_names [0 ], "C" );
185171 strcpy (im -> band_names [1 ], "M" );
186172 strcpy (im -> band_names [2 ], "Y" );
@@ -190,7 +176,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
190176 /* 24-bit video format */
191177 im -> bands = 3 ;
192178 im -> pixelsize = 4 ;
193- im -> linesize = xsize * 4 ;
194179 strcpy (im -> band_names [0 ], "Y" );
195180 strcpy (im -> band_names [1 ], "Cb" );
196181 strcpy (im -> band_names [2 ], "Cr" );
@@ -201,7 +186,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
201186 /* L is uint8, a,b are int8 */
202187 im -> bands = 3 ;
203188 im -> pixelsize = 4 ;
204- im -> linesize = xsize * 4 ;
205189 strcpy (im -> band_names [0 ], "L" );
206190 strcpy (im -> band_names [1 ], "a" );
207191 strcpy (im -> band_names [2 ], "b" );
@@ -212,7 +196,6 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
212196 /* L is uint8, a,b are int8 */
213197 im -> bands = 3 ;
214198 im -> pixelsize = 4 ;
215- im -> linesize = xsize * 4 ;
216199 strcpy (im -> band_names [0 ], "H" );
217200 strcpy (im -> band_names [1 ], "S" );
218201 strcpy (im -> band_names [2 ], "V" );
@@ -223,6 +206,8 @@ ImagingNewPrologueSubtype(const ModeID mode, int xsize, int ysize, int size) {
223206 return (Imaging )ImagingError_ValueError ("unrecognized image mode" );
224207 }
225208
209+ im -> linesize = xsize * im -> pixelsize ;
210+
226211 /* Setup image descriptor */
227212 im -> mode = mode ;
228213
0 commit comments