File indexing completed on 2025-03-09 04:09:53
0001 /* Flattning functions for xcftools 0002 * 0003 * This file was written by Henning Makholm <henning@makholm.net> 0004 * It is hereby in the public domain. 0005 * 0006 * In jurisdictions that do not recognise grants of copyright to the 0007 * public domain: I, the author and (presumably, in those jurisdictions) 0008 * copyright holder, hereby permit anyone to distribute and use this code, 0009 * in source code or binary form, with or without modifications. This 0010 * permission is world-wide and irrevocable. 0011 * 0012 * Of course, I will not be liable for any errors or shortcomings in the 0013 * code, since I give it away without asking any compenstations. 0014 * 0015 * If you use or distribute this code, I would appreciate receiving 0016 * credit for writing it, in whichever way you find proper and customary. 0017 */ 0018 0019 #ifndef FLATTEN_H 0020 #define FLATTEN_H 0021 0022 #include "xcftools.h" 0023 #include "pixels.h" 0024 0025 #define PERHAPS_ALPHA_CHANNEL (NEWALPHA(0,1)) 0026 #define FORCE_ALPHA_CHANNEL (NEWALPHA(0,2)) 0027 #define CHECKERED_BACKGROUND (NEWALPHA(0,200)) 0028 struct FlattenSpec { 0029 struct tileDimensions dim ; 0030 rgba default_pixel ; 0031 int numLayers ; 0032 struct xcfLayer *layers ; 0033 0034 const char * transmap_filename ; 0035 const char * output_filename ; 0036 enum out_color_mode { 0037 COLOR_BY_FILENAME, 0038 COLOR_BY_CONTENTS, 0039 COLOR_INDEXED, 0040 COLOR_RGB, 0041 COLOR_GRAY, 0042 COLOR_MONO 0043 } out_color_mode ; 0044 enum { ALLOW_PARTIAL_TRANSPARENCY, 0045 DISSOLVE_PARTIAL_TRANSPARENCY, 0046 FORBID_PARTIAL_TRANSPARENCY, 0047 PARTIAL_TRANSPARENCY_IMPOSSIBLE 0048 } partial_transparency_mode ; 0049 enum { USE_CANVAS = 0, 0050 MANUAL_OFFSET = 1, 0051 MANUAL_CROP = 2, 0052 AUTOCROP = 4 } window_mode ; 0053 int process_in_memory ; 0054 int gimpish_indexed ; 0055 }; 0056 0057 /* From flatspec.c */ 0058 0059 void init_flatspec(struct FlattenSpec *); 0060 0061 int add_layer_request(struct FlattenSpec *,const char *name); 0062 struct xcfLayer *lastlayerspec(struct FlattenSpec *,const char *option); 0063 0064 typedef enum out_color_mode (*guesser) (struct FlattenSpec *,rgba **); 0065 0066 /* Call this after processing options, and after opening the XCF file */ 0067 int complete_flatspec(struct FlattenSpec *,guesser); 0068 int analyse_colormode(struct FlattenSpec *,rgba **allPixels,guesser); 0069 0070 /* From flatten.c */ 0071 0072 typedef void (*lineCallback)(unsigned num,rgba *pixels); 0073 int flattenIncrementally(struct FlattenSpec *,lineCallback); 0074 rgba **flattenAll(struct FlattenSpec*); 0075 void shipoutWithCallback(struct FlattenSpec *,rgba **pixels,lineCallback); 0076 0077 #endif /* FLATTEN_H */