summaryrefslogtreecommitdiffstats
path: root/flatspec.c
diff options
context:
space:
mode:
authorHenning Makholm <henning@makholm.net>2009-07-02 18:00:00 (EDT)
committer Julien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:11:16 (EST)
commitf43ff6cf8942deab3e554fc2ed1ca83911c62043 (patch)
tree6240bbec976d01d68ce5e817e0d403febacf8ddf /flatspec.c
parent70a9b1ca8750a43e8092807d174a8c49407aa213 (diff)
downloadxcftools-f43ff6cf8942deab3e554fc2ed1ca83911c62043.zip
xcftools-f43ff6cf8942deab3e554fc2ed1ca83911c62043.tar.gz
xcftools-f43ff6cf8942deab3e554fc2ed1ca83911c62043.tar.bz2
Import of release 1.0.6
Diffstat (limited to 'flatspec.c')
-rw-r--r--flatspec.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/flatspec.c b/flatspec.c
index a67ce59..81fc1a2 100644
--- a/flatspec.c
+++ b/flatspec.c
@@ -1,19 +1,19 @@
/* Flattening selections function for xcftools
*
- * Copyright (C) 2006 Henning Makholm
+ * This file was written by Henning Makholm <henning@makholm.net>
+ * It is hereby in the public domain.
+ *
+ * In jurisdictions that do not recognise grants of copyright to the
+ * public domain: I, the author and (presumably, in those jurisdictions)
+ * copyright holder, hereby permit anyone to distribute and use this code,
+ * in source code or binary form, with or without modifications. This
+ * permission is world-wide and irrevocable.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
+ * Of course, I will not be liable for any errors or shortcomings in the
+ * code, since I give it away without asking any compenstations.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * If you use or distribute this code, I would appreciate receiving
+ * credit for writing it, in whichever way you find proper and customary.
*/
#include "xcftools.h"
@@ -79,13 +79,22 @@ static enum out_color_mode
color_by_layers(struct FlattenSpec *spec)
{
int colormap_is_colored = 0 ;
- enum out_color_mode grayish = COLOR_MONO ;
+ enum out_color_mode grayish ;
int i ;
if( spec->default_pixel == CHECKERED_BACKGROUND )
grayish = COLOR_GRAY ;
- else if( degrayPixel(spec->default_pixel) < 0 )
- return COLOR_RGB ;
+ else {
+ int degrayed = degrayPixel(spec->default_pixel);
+ if( degrayed < 0 ) {
+ return COLOR_RGB ;
+ } else if( spec->gimpish_indexed &&
+ (degrayed == 0 || degrayed == 255) ) {
+ grayish = COLOR_MONO ;
+ } else {
+ grayish = COLOR_GRAY ;
+ }
+ }
for( i=0; i<colormapLength; i++ ) {
if( colormap[i] == NEWALPHA(0,0) || colormap[i] == NEWALPHA(-1,0) )
continue ;
@@ -227,6 +236,7 @@ complete_flatspec(struct FlattenSpec *spec, guesser guess_callback)
if( spec->layers[i].mode == GIMP_NORMAL_MODE )
anyPartial = 1;
} else if( isSubrect(spec->dim.c,spec->layers[i].dim.c) &&
+ !spec->layers[i].hasMask &&
(spec->layers[i].mode == GIMP_NORMAL_MODE ||
spec->layers[i].mode == GIMP_NORMAL_NOPARTIAL_MODE ||
spec->layers[i].mode == GIMP_DISSOLVE_MODE) ) {