@@ -61,7 +61,7 @@ typedef struct _VipsFlatten {
6161
6262 /* Background colour.
6363 */
64- VipsArea * background ;
64+ VipsArrayDouble * background ;
6565
6666 /* The [double] converted to the input image format.
6767 */
@@ -319,8 +319,9 @@ vips_flatten_build( VipsObject *object )
319319 /* Is the background black? We have a special path for this.
320320 */
321321 black = TRUE;
322- for ( i = 0 ; i < flatten -> background -> n ; i ++ )
323- if ( ((double * ) flatten -> background -> data )[i ] != 0.0 ) {
322+ for ( i = 0 ; i < VIPS_AREA ( flatten -> background )-> n ; i ++ )
323+ if ( vips_array_double_get ( flatten -> background , NULL )[i ] !=
324+ 0.0 ) {
324325 black = FALSE;
325326 break ;
326327 }
@@ -336,8 +337,8 @@ vips_flatten_build( VipsObject *object )
336337 */
337338 if ( !(flatten -> ink = vips__vector_to_ink ( class -> nickname ,
338339 conversion -> out ,
339- flatten -> background -> data , NULL ,
340- flatten -> background -> n )) )
340+ VIPS_AREA ( flatten -> background ) -> data , NULL ,
341+ VIPS_AREA ( flatten -> background ) -> n )) )
341342 return ( -1 );
342343
343344 if ( vips_image_generate ( conversion -> out ,
@@ -384,9 +385,7 @@ vips_flatten_class_init( VipsFlattenClass *class )
384385static void
385386vips_flatten_init ( VipsFlatten * flatten )
386387{
387- flatten -> background =
388- vips_area_new_array ( G_TYPE_DOUBLE , sizeof ( double ), 1 );
389- ((double * ) (flatten -> background -> data ))[0 ] = 0.0 ;
388+ flatten -> background = vips_array_double_newv ( 1 , 0.0 );
390389}
391390
392391/**
@@ -397,7 +396,7 @@ vips_flatten_init( VipsFlatten *flatten )
397396 *
398397 * Optional arguments:
399398 *
400- * @background: colour for new pixels
399+ * @background: #VipsArrayDouble colour for new pixels
401400 *
402401 * Take the last band of @in as an alpha and use it to blend the
403402 * remaining channels with @background.
0 commit comments