@@ -218,12 +218,11 @@ vips_foreign_save_ppm_build(VipsObject *object)
218
218
VipsObjectClass * class = VIPS_OBJECT_GET_CLASS (object );
219
219
VipsForeignSave * save = (VipsForeignSave * ) object ;
220
220
VipsForeignSavePpm * ppm = (VipsForeignSavePpm * ) object ;
221
- VipsImage * * t = (VipsImage * * ) vips_object_local_array (object , 5 );
221
+ VipsImage * * t = (VipsImage * * ) vips_object_local_array (object , 4 );
222
222
223
223
VipsImage * image ;
224
224
char * magic ;
225
225
char * date ;
226
- VipsBandFormat target_format ;
227
226
VipsInterpretation target_interpretation ;
228
227
int target_bands ;
229
228
@@ -236,8 +235,8 @@ vips_foreign_save_ppm_build(VipsObject *object)
236
235
*/
237
236
if (vips_image_hasalpha (image )) {
238
237
if (vips_flatten (image , & t [0 ],
239
- "background" , save -> background ,
240
- NULL ))
238
+ "background" , save -> background ,
239
+ NULL ))
241
240
return -1 ;
242
241
image = t [0 ];
243
242
}
@@ -254,37 +253,27 @@ vips_foreign_save_ppm_build(VipsObject *object)
254
253
case VIPS_FOREIGN_PPM_FORMAT_PBM :
255
254
if (!vips_object_argument_isset (object , "bitdepth" ))
256
255
ppm -> bitdepth = 1 ;
257
- target_format = VIPS_FORMAT_UCHAR ;
258
256
target_interpretation = VIPS_INTERPRETATION_B_W ;
259
257
target_bands = 1 ;
260
258
break ;
261
259
262
260
case VIPS_FOREIGN_PPM_FORMAT_PGM :
263
- if (image -> BandFmt == VIPS_FORMAT_USHORT ) {
261
+ if (image -> BandFmt == VIPS_FORMAT_USHORT )
264
262
target_interpretation = VIPS_INTERPRETATION_GREY16 ;
265
- target_format = VIPS_FORMAT_USHORT ;
266
- }
267
- else {
263
+ else
268
264
target_interpretation = VIPS_INTERPRETATION_B_W ;
269
- target_format = VIPS_FORMAT_UCHAR ;
270
- }
271
265
target_bands = 1 ;
272
266
break ;
273
267
274
268
case VIPS_FOREIGN_PPM_FORMAT_PPM :
275
- if (image -> BandFmt == VIPS_FORMAT_USHORT ) {
269
+ if (image -> BandFmt == VIPS_FORMAT_USHORT )
276
270
target_interpretation = VIPS_INTERPRETATION_RGB16 ;
277
- target_format = VIPS_FORMAT_USHORT ;
278
- }
279
- else {
271
+ else
280
272
target_interpretation = VIPS_INTERPRETATION_sRGB ;
281
- target_format = VIPS_FORMAT_UCHAR ;
282
- }
283
273
target_bands = 3 ;
284
274
break ;
285
275
286
276
case VIPS_FOREIGN_PPM_FORMAT_PFM :
287
- target_format = VIPS_FORMAT_FLOAT ;
288
277
target_interpretation = VIPS_INTERPRETATION_scRGB ;
289
278
if (image -> Bands > 1 )
290
279
target_bands = 3 ;
@@ -295,27 +284,25 @@ vips_foreign_save_ppm_build(VipsObject *object)
295
284
296
285
case VIPS_FOREIGN_PPM_FORMAT_PNM :
297
286
default :
298
- /* Just use the input format and interpretation .
287
+ /* Just use the input interpretation and bands .
299
288
*/
300
- target_format = image -> BandFmt ;
301
289
target_interpretation = image -> Type ;
302
290
target_bands = image -> Bands ;
303
291
break ;
304
292
}
305
293
306
- if (vips_colourspace (image , & t [1 ], target_interpretation , NULL ) ||
307
- vips_cast (t [1 ], & t [2 ], target_format , NULL ))
294
+ if (vips_colourspace (image , & t [1 ], target_interpretation , NULL ))
308
295
return -1 ;
309
- image = t [2 ];
296
+ image = t [1 ];
310
297
311
298
/* Get bands right.
312
299
*/
313
300
if (image -> Bands > target_bands ) {
314
- if (vips_extract_band (image , & t [3 ], 0 ,
301
+ if (vips_extract_band (image , & t [2 ], 0 ,
315
302
"n" , target_bands ,
316
303
NULL ))
317
304
return -1 ;
318
- image = t [3 ];
305
+ image = t [2 ];
319
306
}
320
307
if (image -> Bands < target_bands ) {
321
308
vips_error (class -> nickname , "%s" , _ ("too few bands for format" ));
@@ -406,9 +393,8 @@ vips_foreign_save_ppm_build(VipsObject *object)
406
393
char buf [G_ASCII_DTOSTR_BUF_SIZE ];
407
394
408
395
scale = 1.0 ;
409
- if (vips_image_get_typeof (image , "pfm-scale" ) &&
410
- !vips_image_get_double (image , "pfm-scale" , & scale ))
411
- ;
396
+ if (vips_image_get_typeof (image , "pfm-scale" ))
397
+ vips_image_get_double (image , "pfm-scale" , & scale );
412
398
413
399
/* Need to be locale independent.
414
400
*/
0 commit comments