"Fossies" - the Fresh Open Source Software Archive

Member "darktable-2.6.3/src/common/imageio_module.h" (20 Oct 2019, 9564 Bytes) of package /linux/misc/darktable-2.6.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "imageio_module.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.6.3_vs_3.0.0.rc0.

    1 /*
    2     This file is part of darktable,
    3     copyright (c) 2009--2010 johannes hanika.
    4 
    5     darktable is free software: you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation, either version 3 of the License, or
    8     (at your option) any later version.
    9 
   10     darktable is distributed in the hope that it will be useful,
   11     but WITHOUT ANY WARRANTY; without even the implied warranty of
   12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13     GNU General Public License for more details.
   14 
   15     You should have received a copy of the GNU General Public License
   16     along with darktable.  If not, see <http://www.gnu.org/licenses/>.
   17 */
   18 
   19 #pragma once
   20 
   21 #include "common/colorspaces.h"
   22 #include "common/darktable.h"
   23 #include <gmodule.h>
   24 #include <gtk/gtk.h>
   25 #include <inttypes.h>
   26 #ifdef USE_LUA
   27 #include "lua/call.h"
   28 #include "lua/events.h"
   29 #include "lua/format.h"
   30 #include "lua/modules.h"
   31 #include "lua/storage.h"
   32 #include "lua/types.h"
   33 #endif
   34 
   35 
   36 /** Flag for the format modules */
   37 typedef enum dt_imageio_format_flags_t
   38 {
   39   FORMAT_FLAGS_SUPPORT_XMP = 1,
   40   FORMAT_FLAGS_NO_TMPFILE = 2
   41 } dt_imageio_format_flags_t;
   42 
   43 /**
   44  * defines the plugin structure for image import and export.
   45  *
   46  * io is handled by the module_format plugins, which in turn is
   47  * called by the module_storage plugins, which handles the type of export,
   48  * such as flickr upload or simple on-disk storage.
   49  */
   50 
   51 /*
   52  * custom data for the module. append private stuff after width and height.
   53  * this will be inited once when the export button is hit, so the user can make
   54  * gui adjustments that won't affect the currently running export.
   55  */
   56 typedef struct dt_imageio_module_data_t
   57 {
   58   int max_width, max_height;
   59   int width, height;
   60   char style[128];
   61   gboolean style_append;
   62 } dt_imageio_module_data_t;
   63 
   64 struct dt_imageio_module_format_t;
   65 /* responsible for image encoding, such as jpg,png,etc */
   66 typedef struct dt_imageio_module_format_t
   67 {
   68   // !!! MUST BE KEPT IN SYNC WITH src/imageio/format/imageio_format_api.h !!!
   69 
   70   // office use only:
   71   char plugin_name[128];
   72   GModule *module;
   73 
   74   // gui stuff:
   75   GtkWidget *widget;
   76 
   77   // data for you to initialize
   78   void *gui_data;
   79 
   80   // gui and management:
   81   /** version */
   82   int (*version)();
   83   /* get translated module name */
   84   const char *(*name)();
   85   /* construct widget above */
   86   void (*gui_init)(struct dt_imageio_module_format_t *self);
   87   /* destroy resources */
   88   void (*gui_cleanup)(struct dt_imageio_module_format_t *self);
   89   /* reset options to defaults */
   90   void (*gui_reset)(struct dt_imageio_module_format_t *self);
   91 
   92   /* construct widget above */
   93   void (*init)(struct dt_imageio_module_format_t *self);
   94   /* construct widget above */
   95   void (*cleanup)(struct dt_imageio_module_format_t *self);
   96 
   97   /* gets the current export parameters from gui/conf and stores in this struct for later use. */
   98   void *(*legacy_params)(struct dt_imageio_module_format_t *self, const void *const old_params,
   99                          const size_t old_params_size, const int old_version, const int new_version,
  100                          size_t *new_size);
  101   size_t (*params_size)(struct dt_imageio_module_format_t *self);
  102   void *(*get_params)(struct dt_imageio_module_format_t *self);
  103   void (*free_params)(struct dt_imageio_module_format_t *self, dt_imageio_module_data_t *data);
  104   /* resets the gui to the parameters as given here. return != 0 on fail. */
  105   int (*set_params)(struct dt_imageio_module_format_t *self, const void *params, const int size);
  106 
  107   /* returns the mime type of the exported image. */
  108   const char *(*mime)(dt_imageio_module_data_t *data);
  109   /* this extension (plus dot) is appended to the exported filename. */
  110   const char *(*extension)(dt_imageio_module_data_t *data);
  111   /* get storage max supported image dimension, return 0 if no dimension restrictions exists. */
  112   int (*dimension)(struct dt_imageio_module_format_t *self, dt_imageio_module_data_t *data, uint32_t *width, uint32_t *height);
  113 
  114   // writing functions:
  115   /* bits per pixel and color channel we want to write: 8: char x3, 16: uint16_t x3, 32: float x3. */
  116   int (*bpp)(dt_imageio_module_data_t *data);
  117   /* write to file, with exif if not NULL, and icc profile if supported. */
  118   int (*write_image)(dt_imageio_module_data_t *data, const char *filename, const void *in,
  119                      dt_colorspaces_color_profile_type_t over_type, const char *over_filename,
  120                      void *exif, int exif_len, int imgid, int num, int total);
  121   /* flag that describes the available precision/levels of output format. mainly used for dithering. */
  122   int (*levels)(dt_imageio_module_data_t *data);
  123 
  124   // sometimes we want to tell the world about what we can do
  125   int (*flags)(dt_imageio_module_data_t *data);
  126 
  127   int (*read_image)(dt_imageio_module_data_t *data, uint8_t *out);
  128   luaA_Type parameter_lua_type;
  129 
  130 } dt_imageio_module_format_t;
  131 
  132 
  133 /* responsible for image storage, such as flickr, harddisk, etc */
  134 typedef struct dt_imageio_module_storage_t
  135 {
  136   // !!! MUST BE KEPT IN SYNC WITH src/imageio/storage/imageio_storage_api.h !!!
  137 
  138   // office use only:
  139   char plugin_name[128];
  140   GModule *module;
  141 
  142   // gui stuff:
  143   GtkWidget *widget;
  144 
  145   // data for you to initialize
  146   void *gui_data;
  147 
  148   // gui and management:
  149   /** version */
  150   int (*version)();
  151   /* get translated module name */
  152   const char *(*name)(const struct dt_imageio_module_storage_t *self);
  153   /* construct widget above */
  154   void (*gui_init)(struct dt_imageio_module_storage_t *self);
  155   /* destroy resources */
  156   void (*gui_cleanup)(struct dt_imageio_module_storage_t *self);
  157   /* reset options to defaults */
  158   void (*gui_reset)(struct dt_imageio_module_storage_t *self);
  159   /* allow the module to initialize itself */
  160   void (*init)(struct dt_imageio_module_storage_t *self);
  161   /* try and see if this format is supported? */
  162   int (*supported)(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_format_t *format);
  163   /* get storage max supported image dimension, return 0 if no dimension restrictions exists. */
  164   int (*dimension)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data, uint32_t *width, uint32_t *height);
  165   /* get storage recommended image dimension, return 0 if no recommendation exists. */
  166   int (*recommended_dimension)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data, uint32_t *width, uint32_t *height);
  167 
  168   /* called once at the beginning (before exporting image), if implemented
  169      * can change the list of exported images (including a NULL list)
  170    */
  171   int (*initialize_store)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data,
  172                           dt_imageio_module_format_t **format, dt_imageio_module_data_t **fdata,
  173                           GList **images, const gboolean high_quality, const gboolean upscale);
  174   /* this actually does the work */
  175   int (*store)(struct dt_imageio_module_storage_t *self, struct dt_imageio_module_data_t *self_data,
  176                const int imgid, dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata,
  177                const int num, const int total, const gboolean high_quality, const gboolean upscale,
  178                dt_colorspaces_color_profile_type_t icc_type, const gchar *icc_filename,
  179                dt_iop_color_intent_t icc_intent);
  180   /* called once at the end (after exporting all images), if implemented. */
  181   void (*finalize_store)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data);
  182 
  183   void *(*legacy_params)(struct dt_imageio_module_storage_t *self, const void *const old_params,
  184                          const size_t old_params_size, const int old_version, const int new_version,
  185                          size_t *new_size);
  186   size_t (*params_size)(struct dt_imageio_module_storage_t *self);
  187   void *(*get_params)(struct dt_imageio_module_storage_t *self);
  188   void (*free_params)(struct dt_imageio_module_storage_t *self, dt_imageio_module_data_t *data);
  189   int (*set_params)(struct dt_imageio_module_storage_t *self, const void *params, const int size);
  190 
  191   void (*export_dispatched)(struct dt_imageio_module_storage_t *self);
  192 
  193   luaA_Type parameter_lua_type;
  194 } dt_imageio_module_storage_t;
  195 
  196 
  197 /* main struct */
  198 typedef struct dt_imageio_t
  199 {
  200   GList *plugins_format;
  201   GList *plugins_storage;
  202 } dt_imageio_t;
  203 
  204 /* load all modules */
  205 void dt_imageio_init(dt_imageio_t *iio);
  206 /* cleanup */
  207 void dt_imageio_cleanup(dt_imageio_t *iio);
  208 
  209 /* get selected imageio plugin for export */
  210 dt_imageio_module_format_t *dt_imageio_get_format();
  211 
  212 /* get selected imageio plugin for export */
  213 dt_imageio_module_storage_t *dt_imageio_get_storage();
  214 
  215 /* get by name. */
  216 dt_imageio_module_format_t *dt_imageio_get_format_by_name(const char *name);
  217 dt_imageio_module_storage_t *dt_imageio_get_storage_by_name(const char *name);
  218 
  219 /* get by index */
  220 dt_imageio_module_format_t *dt_imageio_get_format_by_index(int index);
  221 dt_imageio_module_storage_t *dt_imageio_get_storage_by_index(int index);
  222 int dt_imageio_get_index_of_format(dt_imageio_module_format_t *format);
  223 int dt_imageio_get_index_of_storage(dt_imageio_module_storage_t *storage);
  224 
  225 /* add a module into the known module list */
  226 void dt_imageio_insert_storage(dt_imageio_module_storage_t *storage);
  227 
  228 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
  229 // vim: shiftwidth=2 expandtab tabstop=2 cindent
  230 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;