From aecd48e2adafaf3fd16cc940ff6584228ef23d7e Mon Sep 17 00:00:00 2001 From: bootchk Date: Wed, 28 Oct 2015 11:47:05 -0400 Subject: [PATCH] Separate ImageFormat and ImageFormatIndicies headers so library users independent of glib macros. --- .travis.yml | 1 + lib/engine.c | 2 + lib/imageBuffer.h | 4 ++ lib/imageFormat.c | 1 + lib/imageFormat.h | 56 ++------------------ lib/imageFormatIndicies.h | 87 +++++++++++++++++++++++++++++++ lib/imageSynth.c | 1 + lib/imageSynth.h | 3 +- src/resynthesizer/resynthesizer.c | 1 + 9 files changed, 102 insertions(+), 54 deletions(-) create mode 100644 .travis.yml create mode 100644 lib/imageFormatIndicies.h diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b455aa3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: c diff --git a/lib/engine.c b/lib/engine.c index 3492090..e20c3a6 100644 --- a/lib/engine.c +++ b/lib/engine.c @@ -99,6 +99,8 @@ It doesn't make tiles in the target, it makes a target that is suitable as a til // True header files #include "imageFormat.h" +#include "imageFormatIndicies.h" + #include "map.h" #include "engineParams.h" #include "engine.h" diff --git a/lib/imageBuffer.h b/lib/imageBuffer.h index 10d527c..15f2162 100644 --- a/lib/imageBuffer.h +++ b/lib/imageBuffer.h @@ -6,6 +6,9 @@ Interpretation of pixels (order and count of pixelels (unsigned bytes)) is given Rows padded. */ +#ifndef __SYNTH_IMAGE_BUFFER_H__ +#define __SYNTH_IMAGE_BUFFER_H__ + typedef struct _ImageBuffer { unsigned char * data; // data must be sequential RGBA for image, sequence of bytes for a mask @@ -17,3 +20,4 @@ ImageBuffer; // Mask same as image except only one pixelel per pixel (different, or assumed format code of on pixelel per pixel.) +#endif diff --git a/lib/imageFormat.c b/lib/imageFormat.c index c89d59e..331ab6d 100644 --- a/lib/imageFormat.c +++ b/lib/imageFormat.c @@ -34,6 +34,7 @@ The internal Pixel aggregates color, mask, and map pixelels; for memory locality #include "imageSynthConstants.h" #include "engineParams.h" #include "imageFormat.h" +#include "imageFormatIndicies.h" extern unsigned int countPixelelsPerPixelForFormat( diff --git a/lib/imageFormat.h b/lib/imageFormat.h index cd0e4b2..ff353a6 100644 --- a/lib/imageFormat.h +++ b/lib/imageFormat.h @@ -30,6 +30,9 @@ Not depend on Gimp #ifndef __SYNTH_IMAGE_FORMAT_H__ #define __SYNTH_IMAGE_FORMAT_H__ +// Enumerates different layouts of pixelels within pixels, for in images +// This type is exported, needed by callers of library +// The library lays pixelels out in its own internal format typedef enum ImageFormat { T_RGB, @@ -37,59 +40,6 @@ typedef enum ImageFormat T_Gray, T_GrayA } TImageFormat; - -/* -bpp i.e. count of bytes (channels) per pixel or index thereof. -bpp is bytes per pixel -bip is byte index within pixel. -See data layout in resynth_types.h -*/ -typedef unsigned char TPixelelIndex; - -/* -Struct of indices of pixelels within pixels in internal image format. -Also flags. -One is used for the target, one for the source. -*/ -typedef struct indicesStruct { - TPixelelIndex colorEndBip; /* Index of last color pixelels in target/context image. */ - TPixelelIndex alpha_bip; /* Index of target alpha pixelel */ - TPixelelIndex map_start_bip; /* Index of map pixelels */ - TPixelelIndex map_end_bip; - - TPixelelIndex img_match_bpp; /* bpp to match in image. */ - TPixelelIndex map_match_bpp; /* bpp to match in map. */ - TPixelelIndex total_bpp; /* Total pixelels */ - - gboolean isAlphaTarget; // Does target have alpha? - gboolean isAlphaSource; // Does source have alpha? -} TFormatIndices; - -extern unsigned int -countPixelelsPerPixelForFormat( - TImageFormat format // IN - ); - -extern int -prepareImageFormatIndicesFromFormatType( - TFormatIndices* indices, // OUT - TImageFormat format // IN - ); - -extern void -prepareImageFormatIndices( - TFormatIndices* indices, // OUT - guint count_color_channels_target, // Must be same count in source - guint count_color_channels_map, - gboolean is_alpha_target, - gboolean is_alpha_source, - gboolean isMap - ); - -extern void -prepareDefaultFormatIndices( - TFormatIndices* formatIndices - ); #endif /* __SYNTH_IMAGE_FORMAT_H__ */ diff --git a/lib/imageFormatIndicies.h b/lib/imageFormatIndicies.h new file mode 100644 index 0000000..1c7436f --- /dev/null +++ b/lib/imageFormatIndicies.h @@ -0,0 +1,87 @@ +/* +Prepare indices into our pixel format. + +Synthesizer engine pixel contains mask pixelel and map pixelels +(Not just the color and alpha pixelels.) + +IN: Image format (RGB, RGBA, Grey, etc.) +OUT: global index variables. + +Not depend on Gimp + + Copyright (C) 2010, 2011 Lloyd Konneker + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#ifndef __SYNTH_IMAGE_FORMAT_INDICIES_H__ +#define __SYNTH_IMAGE_FORMAT_INDICIES_H__ + +/* +bpp i.e. count of bytes (channels) per pixel or index thereof. +bpp is bytes per pixel +bip is byte index within pixel. +See data layout in resynth_types.h +*/ +typedef unsigned char TPixelelIndex; + +/* +Struct of indices of pixelels within pixels in internal image format. +Also flags. +One is used for the target, one for the source. +*/ +typedef struct indicesStruct { + TPixelelIndex colorEndBip; /* Index of last color pixelels in target/context image. */ + TPixelelIndex alpha_bip; /* Index of target alpha pixelel */ + TPixelelIndex map_start_bip; /* Index of map pixelels */ + TPixelelIndex map_end_bip; + + TPixelelIndex img_match_bpp; /* bpp to match in image. */ + TPixelelIndex map_match_bpp; /* bpp to match in map. */ + TPixelelIndex total_bpp; /* Total pixelels */ + + gboolean isAlphaTarget; // Does target have alpha? + gboolean isAlphaSource; // Does source have alpha? +} TFormatIndices; + +extern unsigned int +countPixelelsPerPixelForFormat( + TImageFormat format // IN + ); + +extern int +prepareImageFormatIndicesFromFormatType( + TFormatIndices* indices, // OUT + TImageFormat format // IN + ); + +extern void +prepareImageFormatIndices( + TFormatIndices* indices, // OUT + guint count_color_channels_target, // Must be same count in source + guint count_color_channels_map, + gboolean is_alpha_target, + gboolean is_alpha_source, + gboolean isMap + ); + +extern void +prepareDefaultFormatIndices( + TFormatIndices* formatIndices + ); + +#endif /* __SYNTH_IMAGE_FORMAT_H__ */ + diff --git a/lib/imageSynth.c b/lib/imageSynth.c index 29cae0c..b7a2417 100644 --- a/lib/imageSynth.c +++ b/lib/imageSynth.c @@ -45,6 +45,7 @@ To make: #include "glibProxy.h" // glibProxy.c #include "imageFormat.h" +#include "imageFormatIndicies.h" #include "map.h" // header for mapOps.h included by engine.c #include "engineParams.h" // engineParams.c #include "engine.h" // engine.c diff --git a/lib/imageSynth.h b/lib/imageSynth.h index 933273e..1993b66 100644 --- a/lib/imageSynth.h +++ b/lib/imageSynth.h @@ -22,9 +22,10 @@ Header for the simple API to libresynthesizer // The full API takes two images (target and corpus) and can do many things. // The simple API munges one image into two and calls the full API. -// Type defs of struct you must pass +// Type defs of structs passed to imageSynth() #include "imageBuffer.h" #include "imageFormat.h" +#include "engineParams.h" // Signature of the only simple API function int diff --git a/src/resynthesizer/resynthesizer.c b/src/resynthesizer/resynthesizer.c index 561844d..1a757f6 100644 --- a/src/resynthesizer/resynthesizer.c +++ b/src/resynthesizer/resynthesizer.c @@ -91,6 +91,7 @@ Types, etc. from resynthesizer (image_synth) library #include "glibProxy.h" #endif #include "imageFormat.h" +#include "imageFormatIndicies.h" #include "map.h" #include "engineParams.h" #include "engine.h" // requires map.h