home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / app / paint_funcs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-17  |  20.9 KB  |  591 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. /*
  20.  * gaussian_blur_region no longer does combination; arguments changed
  21.  *   -- scott@poverty.bloomington.in.us, 16Oct97
  22.  */
  23.  
  24. #ifndef __PAINT_FUNCS_H__
  25. #define __PAINT_FUNCS_H__
  26.  
  27. #include "apptypes.h"
  28. #include "pixel_region.h"
  29.  
  30.  
  31. /*  Called initially to setup accelerated rendering features  */
  32. void  paint_funcs_setup     (void);
  33. void  paint_funcs_free      (void);
  34.  
  35. void paint_funcs_invalidate_color_hash_table (GimpImage* gimage,
  36.                           gint       index);
  37.  
  38. /*  Paint functions  */
  39.  
  40. void  color_pixels          (unsigned char *dest, const unsigned char *color,
  41.                  int w, int bytes);
  42.  
  43. void  blend_pixels          (const unsigned char *src1,
  44.                  const unsigned char *src2,
  45.                  unsigned char *dest, 
  46.                  int blend, int w, int bytes, int has_alpha);
  47.  
  48. void  shade_pixels          (const unsigned char *src, unsigned char *dest,
  49.                  const unsigned char *color,
  50.                  int blend, int w, int bytes, int has_alpha);
  51.  
  52. void  extract_alpha_pixels  (const unsigned char *src,
  53.                  const unsigned char *mask,
  54.                  unsigned char *dest,
  55.                  int w, int bytes);
  56.  
  57. void  darken_pixels         (const unsigned char *src1,
  58.                  const unsigned char *src2,
  59.                   unsigned char *dest, int length,
  60.                  int bytes1, int bytes2,
  61.                  int has_alpha1, int has_alpha2);
  62.  
  63. void  lighten_pixels        (const unsigned char *src1,
  64.                  const unsigned char *src2,
  65.                   unsigned char *dest, int length,
  66.                  int bytes1, int bytes2,
  67.                  int has_alpha1, int has_alpha2);
  68.  
  69. void  hsv_only_pixels       (const unsigned char *src1,
  70.                  const unsigned char *src2,
  71.                   unsigned char *dest, int mode, int length,
  72.                  int bytes1, int bytes2,
  73.                  int has_alpha1, int has_alpha2);
  74.  
  75. void  color_only_pixels     (const unsigned char *src1,
  76.                  const unsigned char *src2,
  77.                   unsigned char *dest, int mode, int length,
  78.                  int bytes1, int bytes2,
  79.                  int has_alpha1, int has_alpha2);
  80.  
  81. void  multiply_pixels       (const unsigned char *src1,
  82.                  const unsigned char *src2,
  83.                   unsigned char *dest, int length,
  84.                  int bytes1, int bytes2,
  85.                  int has_alpha1, int has_alpha2);
  86.  
  87. void  divide_pixels         (const unsigned char *src1,
  88.                  const unsigned char *src2,
  89.                   unsigned char *dest, int length,
  90.                  int bytes1, int bytes2,
  91.                  int has_alpha1, int has_alpha2);
  92.  
  93. void  screen_pixels         (const unsigned char *src1,
  94.                  const unsigned char *src2,
  95.                   unsigned char *dest, int length,
  96.                  int bytes1, int bytes2,
  97.                  int has_alpha1, int has_alpha2);
  98.  
  99. void  overlay_pixels        (const unsigned char *src1,
  100.                  const unsigned char *src2,
  101.                   unsigned char *dest, int length,
  102.                  int bytes1, int bytes2,
  103.                  int has_alpha1, int has_alpha2);
  104.  
  105. void  add_pixels             (const unsigned char *src1,
  106.                  const unsigned char *src2,
  107.                   unsigned char *dest, int length,
  108.                  int bytes1, int bytes2,
  109.                  int has_alpha1, int has_alpha2);
  110.  
  111. void  subtract_pixels       (const unsigned char *src1,
  112.                  const unsigned char *src2,
  113.                   unsigned char *dest, int length,
  114.                  int bytes1, int bytes2,
  115.                  int has_alpha1, int has_alpha2);
  116.  
  117. void  difference_pixels     (const unsigned char *src1,
  118.                  const unsigned char *src2,
  119.                   unsigned char *dest, int length,
  120.                  int bytes1, int bytes2,
  121.                  int has_alpha1, int has_alpha2);
  122.  
  123. void  dissolve_pixels       (const unsigned char *src,
  124.                  unsigned char *dest, int x, int y,
  125.                  int opacity, int length, int sb, int db,
  126.                  int has_alpha);
  127.  
  128. void  swap_pixels           (unsigned char *src, unsigned char *dest,
  129.                  int length);
  130.  
  131. void  scale_pixels          (const unsigned char *src, unsigned char *dest,
  132.                  int length, int scale);
  133.  
  134. void  add_alpha_pixels      (const unsigned char *src, unsigned char *dest,
  135.                  int length, int bytes);
  136.  
  137. void  flatten_pixels        (const unsigned char *src, unsigned char *dest,
  138.                  const unsigned char *bg, int length, int bytes);
  139.  
  140. void  gray_to_rgb_pixels    (const unsigned char *src, unsigned char *dest,
  141.                  int length, int bytes);
  142.  
  143.  
  144. /*  apply the mask data to the alpha channel of the pixel data  */
  145. void  apply_mask_to_alpha_channel         (unsigned char *src,
  146.                        const unsigned char *mask,
  147.                        int opacity, int length, int bytes);
  148.  
  149. /*  combine the mask data with the alpha channel of the pixel data  */
  150. void  combine_mask_and_alpha_channel      (unsigned char *src,
  151.                        const unsigned char *mask,
  152.                        int opacity, int length, int bytes);
  153.  
  154.  
  155. /*  copy gray pixels to intensity-alpha pixels.  This function
  156.  *  essentially takes a source that is only a grayscale image and
  157.  *  copies it to the destination, expanding to RGB if necessary and
  158.  *  adding an alpha channel.  (OPAQUE)
  159.  */
  160. void  copy_gray_to_inten_a_pixels         (const unsigned char *src,
  161.                        unsigned char *dest,
  162.                        int length, int bytes);
  163.  
  164. /*  lay down the initial pixels in the case of only one
  165.  *  channel being visible and no layers...In this singular
  166.  *  case, we want to display a grayscale image w/o transparency
  167.  */
  168. void  initial_channel_pixels              (const unsigned char *src,
  169.                        unsigned char *dest,
  170.                        int length, int bytes);
  171.  
  172. /*  lay down the initial pixels in the case of an indexed image.
  173.  *  This process obviously requires no composition
  174.  */
  175. void  initial_indexed_pixels              (const unsigned char *src,
  176.                        unsigned char *dest,
  177.                        const unsigned char *cmap,
  178.                        int length);
  179.  
  180. /*  lay down the initial pixels in the case of an indexed image.
  181.  *  This process obviously requires no composition
  182.  */
  183. void  initial_indexed_a_pixels            (const unsigned char *src,
  184.                        unsigned char *dest,
  185.                        const unsigned char *mask,
  186.                        const unsigned char *cmap,
  187.                        int opacity, int length);
  188.  
  189. /*  lay down the initial pixels for the base layer.
  190.  *  This process obviously requires no composition.
  191.  */
  192. void  initial_inten_pixels                (const unsigned char *src,
  193.                        unsigned char *dest,
  194.                        const unsigned char *mask,
  195.                        int opacity, const int *affect,
  196.                        int length, int bytes);
  197.  
  198. /*  lay down the initial pixels for the base layer.
  199.  *  This process obviously requires no composition.
  200.  */
  201. void  initial_inten_a_pixels              (const unsigned char *src,
  202.                        unsigned char *dest,
  203.                        const unsigned char *mask,
  204.                        int opacity, const int *affect,
  205.                        int length, int bytes);
  206.  
  207. /*  combine indexed images with an optional mask which
  208.  *  is interpreted as binary...destination is indexed...
  209.  */
  210. void  combine_indexed_and_indexed_pixels  (const unsigned char *src1,
  211.                        const unsigned char *src2,
  212.                        unsigned char *dest,
  213.                        const unsigned char *mask,
  214.                        int opacity, const int *affect,
  215.                        int length, int bytes);
  216.  
  217. /*  combine indexed images with indexed-alpha images
  218.  *  result is an indexed image
  219.  */
  220. void  combine_indexed_and_indexed_a_pixels (const unsigned char *src1,
  221.                         const unsigned char *src2,
  222.                         unsigned char       *dest,
  223.                         const unsigned char *mask,
  224.                         int                  opacity,
  225.                         const int           *affect,
  226.                         int                  length,
  227.                         int                  bytes);
  228.  
  229. /*  combine indexed-alpha images with indexed-alpha images
  230.  *  result is an indexed-alpha image.  use this for painting
  231.  *  to an indexed floating sel
  232.  */
  233. void  combine_indexed_a_and_indexed_a_pixels(const unsigned char *src1,
  234.                          const unsigned char *src2,
  235.                          unsigned char       *dest,
  236.                          const unsigned char *mask,
  237.                          int                  opacity,
  238.                          const int           *affect,
  239.                          int                  length,
  240.                          int                  bytes);
  241.  
  242. /*  combine intensity with indexed, destination is
  243.  *  intensity-alpha...use this for an indexed floating sel
  244.  */
  245. void  combine_inten_a_and_indexed_a_pixels (const unsigned char *src1,
  246.                         const unsigned char *src2,
  247.                         unsigned char       *dest,
  248.                         const unsigned char *mask,
  249.                         const unsigned char *cmap,
  250.                         int                  opacity,
  251.                         int                  length,
  252.                         int                  bytes);
  253.  
  254. /*  combine RGB image with RGB or GRAY with GRAY
  255.  *  destination is intensity-only...
  256.  */
  257. void  combine_inten_and_inten_pixels       (const unsigned char *src1,
  258.                         const unsigned char *src2,
  259.                         unsigned char       *dest,
  260.                         const unsigned char *mask,
  261.                         int                  opacity,
  262.                         const int           *affect,
  263.                         int                  length,
  264.                         int                  bytes);
  265.  
  266. /*  combine an RGBA or GRAYA image with an RGB or GRAY image
  267.  *  destination is intensity-only...
  268.  */
  269. void  combine_inten_and_inten_a_pixels    (const unsigned char *src1,
  270.                        const unsigned char *src2,
  271.                        unsigned char *dest,
  272.                        const unsigned char *mask,
  273.                        int opacity, const int *affect,
  274.                        int length, int bytes);
  275.  
  276. /*  combine an RGB or GRAY image with an RGBA or GRAYA image
  277.  *  destination is intensity-alpha...
  278.  */
  279. void  combine_inten_a_and_inten_pixels    (const unsigned char *src1,
  280.                        const unsigned char *src2,
  281.                        unsigned char *dest,
  282.                        const unsigned char *mask,
  283.                        int opacity, const int *affect,
  284.                        int mode_affect, int length,
  285.                        int bytes);
  286.  
  287. /*  combine an RGBA or GRAYA image with an RGBA or GRAYA image
  288.  *  destination is of course intensity-alpha...
  289.  */
  290. void  combine_inten_a_and_inten_a_pixels   (const unsigned char *src1,
  291.                         const unsigned char *src2,
  292.                         unsigned char       *dest,
  293.                         const unsigned char *mask,
  294.                         int                 opacity,
  295.                         const int          *affect,
  296.                         int                 mode_affect,
  297.                         int                 length,
  298.                         int                 bytes);
  299.  
  300. /*  combine a channel with intensity-alpha pixels based
  301.  *  on some opacity, and a channel color...
  302.  *  destination is intensity-alpha
  303.  */
  304. void  combine_inten_a_and_channel_mask_pixels(const unsigned char *src,
  305.                           const unsigned char *channel,
  306.                           unsigned char       *dest,
  307.                           const unsigned char *col,
  308.                           int                  opacity,
  309.                           int                  length,
  310.                           int                  bytes);
  311.  
  312. void  combine_inten_a_and_channel_selection_pixels(const unsigned char *src,
  313.                          const unsigned char *channel,
  314.                          unsigned char       *dest,
  315.                              const unsigned char *col,
  316.                              int                  opacity,
  317.                              int                  length,
  318.                              int                  bytes);
  319.  
  320. /*  paint "behind" the existing pixel row.
  321.  *  This is similar in appearance to painting on a layer below
  322.  *  the existing pixels.
  323.  */
  324. void  behind_inten_pixels                    (const unsigned char *src1,
  325.                           const unsigned char *src2,
  326.                           unsigned char       *dest,
  327.                           const unsigned char *mask,
  328.                           int                  opacity,
  329.                           const int           *affect,
  330.                           int                  length,
  331.                           int                  bytes1,
  332.                           int                  bytes2,
  333.                           int                  has_alpha1,
  334.                           int                  has_alpha2);
  335.  
  336. /*  paint "behind" the existing pixel row (for indexed images).
  337.  *  This is similar in appearance to painting on a layer below
  338.  *  the existing pixels.
  339.  */
  340. void  behind_indexed_pixels                (const unsigned char *src1,
  341.                         const unsigned char *src2,
  342.                         unsigned char       *dest,
  343.                         const unsigned char *mask,
  344.                         int                  opacity,
  345.                         const int           *affect,
  346.                         int                  length,
  347.                         int                  bytes1,
  348.                         int                  bytes2,
  349.                         int                  has_alpha1,
  350.                         int                  has_alpha2);
  351.  
  352. /*  replace the contents of one pixel row with the other
  353.  *  The operation is still bounded by mask/opacity constraints
  354.  */
  355. void  replace_inten_pixels                (const unsigned char *src1,
  356.                        const unsigned char *src2,
  357.                        unsigned char       *dest,
  358.                        const unsigned char *mask,
  359.                        int                  opacity,
  360.                        const int           *affect,
  361.                        int                  length,
  362.                        int                  bytes1,
  363.                        int                  bytes2,
  364.                        int                  has_alpha1,
  365.                        int                  has_alpha2);
  366.  
  367. /*  replace the contents of one pixel row with the other
  368.  *  The operation is still bounded by mask/opacity constraints
  369.  */
  370. void  replace_indexed_pixels                (const unsigned char *src1,
  371.                          const unsigned char *src2,
  372.                          unsigned char       *dest,
  373.                          const unsigned char *mask,
  374.                          int                  opacity,
  375.                          const int           *affect,
  376.                          int                  length,
  377.                          int                  bytes1,
  378.                          int                  bytes2,
  379.                          int                  has_alpha1,
  380.                          int                  has_alpha2);
  381.  
  382. /*  apply source 2 to source 1, but in a non-additive way,
  383.  *  multiplying alpha channels  (works for intensity)
  384.  */
  385. void  erase_inten_pixels                  (const unsigned char *src1,
  386.                        const unsigned char *src2,
  387.                        unsigned char       *dest,
  388.                        const unsigned char *mask,
  389.                        int                  opacity,
  390.                        const int           *affect,
  391.                        int                  length,
  392.                        int                  bytes);
  393.  
  394. /*  apply source 2 to source 1, but in a non-additive way,
  395.  *  multiplying alpha channels  (works for indexed)
  396.  */
  397. void  erase_indexed_pixels                (const unsigned char *src1,
  398.                        const unsigned char *src2,
  399.                        unsigned char       *dest,
  400.                        const unsigned char *mask,
  401.                        int                  opacity,
  402.                        const int           *affect,
  403.                        int                  length,
  404.                        int                  bytes);
  405.  
  406. /*  extract information from intensity pixels based on
  407.  *  a mask.
  408.  */
  409. void  extract_from_inten_pixels           (unsigned char       *src,
  410.                        unsigned char       *dest,
  411.                        const unsigned char *mask,
  412.                        const unsigned char *bg,
  413.                        int                  cut,
  414.                        int                  length,
  415.                        int                  bytes,
  416.                        int                  has_alpha);
  417.  
  418. /*  extract information from indexed pixels based on
  419.  *  a mask.
  420.  */
  421. void  extract_from_indexed_pixels          (unsigned char *src,
  422.                         unsigned char       *dest,
  423.                         const unsigned char *mask,
  424.                         const unsigned char *cmap,
  425.                         const unsigned char *bg,
  426.                         int                  cut,
  427.                         int                  length,
  428.                         int                  bytes,
  429.                         int                  has_alpha);
  430.  
  431.  
  432. /*  variable source to RGB color mapping
  433.  *  src_type == 0  (RGB)
  434.  *  src_type == 1  (GRAY)
  435.  *  src_type == 2  (INDEXED)
  436.  */
  437. void
  438. map_to_color                              (int                  src_type,
  439.                        const unsigned char *cmap,
  440.                        const unsigned char *src,
  441.                        unsigned char       *rgb);
  442.  
  443.  
  444. /*  RGB to index mapping functions...
  445.  *
  446.  *  Hash table lookup speeds up the standard
  447.  *  least squares method
  448.  */
  449. int    map_rgb_to_indexed                 (const unsigned char *cmap,
  450.                        int num_cols, GimpImage* gimage,
  451.                        int r, int g, int b);
  452.  
  453.  
  454. /*  Region functions  */
  455. void  color_region                        (PixelRegion *dest, 
  456.                        const unsigned char *color);
  457.  
  458.  
  459. void  blend_region                        (PixelRegion *, PixelRegion *,
  460.                        PixelRegion *, int);
  461.  
  462. void  shade_region                        (PixelRegion *, PixelRegion *,
  463.                        unsigned char *, int);
  464.  
  465. void  copy_region                         (PixelRegion *, PixelRegion *);
  466.  
  467. void  add_alpha_region                    (PixelRegion *, PixelRegion *);
  468.  
  469. void  flatten_region                      (PixelRegion *, PixelRegion *,
  470.                        unsigned char *);
  471.  
  472. void  extract_alpha_region                (PixelRegion *, PixelRegion *,
  473.                        PixelRegion *);
  474.  
  475. void  extract_from_region                 (PixelRegion *, PixelRegion *,
  476.                        PixelRegion *, unsigned char *,
  477.                        unsigned char *, int, int, int);
  478.  
  479.  
  480. void  convolve_region                     (PixelRegion *,
  481.                        PixelRegion *,
  482.                        int *, int, int,
  483.                        ConvolutionType);
  484.  
  485. void  multiply_alpha_region               (PixelRegion *);
  486.  
  487. void  separate_alpha_region               (PixelRegion *);
  488.  
  489. void  gaussian_blur_region                (PixelRegion *, double, double);
  490.  
  491. void  border_region                       (PixelRegion *, gint16, gint16);
  492.  
  493. void  scale_region                        (PixelRegion *, PixelRegion *);
  494.  
  495. void  scale_region_no_resample            (PixelRegion *, PixelRegion *);
  496.  
  497. void  subsample_region                    (PixelRegion *, PixelRegion *,
  498.                        int);
  499.  
  500. float shapeburst_region                   (PixelRegion *, PixelRegion *);
  501.  
  502. void thin_region                           (PixelRegion *, gint16 xradius,
  503.                         gint16 yradius, int edge_lock);
  504.  
  505. void fatten_region                         (PixelRegion *, 
  506.                         gint16 xradius, gint16 yradius);
  507.  
  508. void  swap_region                         (PixelRegion *, PixelRegion *);
  509.  
  510.  
  511. /*  Apply a mask to an image's alpha channel  */
  512. void  apply_mask_to_region                (PixelRegion *, PixelRegion *, int);
  513.  
  514. /*  Combine a mask with an image's alpha channel  */
  515. void  combine_mask_and_region             (PixelRegion *, PixelRegion *, int);
  516.  
  517. /*  Copy a gray image to an intensity-alpha region  */
  518. void  copy_gray_to_region                 (PixelRegion *, PixelRegion *);
  519.  
  520. /*  Lay down the groundwork for layer construction...
  521.  *  This includes background images for indexed or non-alpha
  522.  *  images, floating selections, selective display of intensity
  523.  *  channels, and display of arbitrary mask channels
  524.  */
  525. #define INITIAL_CHANNEL_MASK         0
  526. #define INITIAL_CHANNEL_SELECTION    1
  527. #define INITIAL_INDEXED              2
  528. #define INITIAL_INDEXED_ALPHA        3
  529. #define INITIAL_INTENSITY            4
  530. #define INITIAL_INTENSITY_ALPHA      5
  531.  
  532. /*  Combine two source regions with the help of an optional mask
  533.  *  region into a destination region.  This is used for constructing
  534.  *  layer projections, and for applying image patches to an image
  535.  */
  536. #define COMBINE_INDEXED_INDEXED           0
  537. #define COMBINE_INDEXED_INDEXED_A         1
  538. #define COMBINE_INDEXED_A_INDEXED_A       2
  539. #define COMBINE_INTEN_A_INDEXED_A         3
  540. #define COMBINE_INTEN_A_CHANNEL_MASK      4
  541. #define COMBINE_INTEN_A_CHANNEL_SELECTION 5
  542. #define COMBINE_INTEN_INTEN               6
  543. #define COMBINE_INTEN_INTEN_A             7
  544. #define COMBINE_INTEN_A_INTEN             8
  545. #define COMBINE_INTEN_A_INTEN_A           9
  546.  
  547. /*  Non-conventional combination modes  */
  548. #define BEHIND_INTEN                      20
  549. #define BEHIND_INDEXED                    21
  550. #define REPLACE_INTEN                     22
  551. #define REPLACE_INDEXED                   23
  552. #define ERASE_INTEN                       24
  553. #define ERASE_INDEXED                     25
  554. #define ANTI_ERASE_INTEN                  26
  555. #define ANTI_ERASE_INDEXED                27
  556. #define NO_COMBINATION                    28
  557.  
  558. /* Opacities */
  559. #define TRANSPARENT_OPACITY        0
  560. #define OPAQUE_OPACITY             255
  561.  
  562. void  initial_region                      (PixelRegion *, PixelRegion *,
  563.                        PixelRegion *, unsigned char *,
  564.                        int, LayerModeEffects, int *, int);
  565.  
  566. void  combine_regions                     (PixelRegion *, PixelRegion *,
  567.                        PixelRegion *, PixelRegion *,
  568.                        unsigned char *, int,
  569.                        LayerModeEffects,
  570.                        int *, int);
  571.  
  572. void  combine_regions_replace             (PixelRegion *, PixelRegion *,
  573.                        PixelRegion *, PixelRegion *,
  574.                        unsigned char *,
  575.                        int, int *, int);
  576.  
  577.  
  578. /*  Applying layer modes...  */
  579.  
  580. int   apply_layer_mode         (unsigned char *, unsigned char *,
  581.                 unsigned char **, int, int, int,
  582.                 int,
  583.                 LayerModeEffects,
  584.                 int, int, int, int, int *);
  585.  
  586. int   apply_indexed_layer_mode (unsigned char *, unsigned char *,
  587.                 unsigned char **,
  588.                 LayerModeEffects, int, int);
  589.  
  590. #endif  /*  __PAINT_FUNCS_H__  */
  591.