graphicscomposition/openwfcompositionengine/common/include/owfimage.h
changeset 0 5d03bc08d59c
child 19 bbf46f59e123
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 /* Copyright (c) 2009 The Khronos Group Inc.
       
     2  *
       
     3  * Permission is hereby granted, free of charge, to any person obtaining a
       
     4  * copy of this software and/or associated documentation files (the
       
     5  * "Materials"), to deal in the Materials without restriction, including
       
     6  * without limitation the rights to use, copy, modify, merge, publish,
       
     7  * distribute, sublicense, and/or sell copies of the Materials, and to
       
     8  * permit persons to whom the Materials are furnished to do so, subject to
       
     9  * the following conditions:
       
    10  *
       
    11  * The above copyright notice and this permission notice shall be included
       
    12  * in all copies or substantial portions of the Materials.
       
    13  *
       
    14  * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
       
    15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
       
    17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
       
    18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
       
    19  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
       
    20  * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
       
    21  */
       
    22 
       
    23 #ifndef OWFIMAGE_H_
       
    24 #define OWFIMAGE_H_
       
    25 
       
    26 #include "owftypes.h"
       
    27 
       
    28 #ifdef __cplusplus
       
    29 extern "C" {
       
    30 #endif
       
    31 
       
    32 typedef void*   OWF_DISPCTX;
       
    33 
       
    34 
       
    35 #undef USE_FLOAT_PIXEL
       
    36 
       
    37 /*
       
    38  * This is and always should be the only place where USE_FLOAT_PIXEL is 
       
    39  * defined so if #define USE_FLOAT_PIXEL is absent in owfimage.h then it
       
    40  * can be assumed it is not defined elsewhere. 
       
    41  */ 
       
    42 //#define USE_FLOAT_PIXEL
       
    43 
       
    44 /* --
       
    45 * internal pixel format
       
    46 */
       
    47 #ifdef USE_FLOAT_PIXEL
       
    48 #define OWF_IMAGE_INTERNAL_PIXEL_IS_FLOAT
       
    49 
       
    50 typedef OWFfloat            OWFsubpixel; /* subpixel representation */
       
    51 
       
    52 #define OWF_RED_MIN_VALUE   0.0f
       
    53 #define OWF_RED_MAX_VALUE   1.0f
       
    54 #define OWF_GREEN_MIN_VALUE 0.0f
       
    55 #define OWF_GREEN_MAX_VALUE 1.0f
       
    56 #define OWF_BLUE_MIN_VALUE  0.0f
       
    57 #define OWF_BLUE_MAX_VALUE  1.0f
       
    58 #define OWF_ALPHA_MIN_VALUE 0.0f
       
    59 #define OWF_ALPHA_MAX_VALUE 1.0f
       
    60 
       
    61 #define OWF_FULLY_OPAQUE        OWF_ALPHA_MAX_VALUE
       
    62 #define OWF_FULLY_TRANSPARENT   OWF_ALPHA_MIN_VALUE
       
    63 
       
    64 #define OWF_BYTE_MAX_VALUE  255.0f
       
    65 #define OWF_BILINEAR_ROUNDING_VALUE 0.0f
       
    66 #define OWF_BLEND_ROUNDING_VALUE 0.0f
       
    67 #define OWF_PREMUL_ROUNDING_FACTOR  0.0f
       
    68 #define OWF_SOURCE_CONVERSION_ROUNDING_VALUE 0.0f
       
    69 
       
    70 #else
       
    71 #undef OWF_IMAGE_INTERNAL_PIXEL_IS_FLOAT
       
    72 
       
    73 typedef OWFuint8            OWFsubpixel; /* subpixel representation */
       
    74 
       
    75 #define OWF_RED_MIN_VALUE         0
       
    76 #define OWF_RED_MAX_VALUE       255
       
    77 #define OWF_GREEN_MIN_VALUE       0
       
    78 #define OWF_GREEN_MAX_VALUE     255
       
    79 #define OWF_BLUE_MIN_VALUE        0
       
    80 #define OWF_BLUE_MAX_VALUE      255
       
    81 #define OWF_ALPHA_MIN_VALUE       0
       
    82 #define OWF_ALPHA_MAX_VALUE     255
       
    83 #define OWF_FULLY_OPAQUE        OWF_ALPHA_MAX_VALUE
       
    84 #define OWF_FULLY_TRANSPARENT   OWF_ALPHA_MIN_VALUE
       
    85 
       
    86 #define OWF_BYTE_MAX_VALUE      255
       
    87 
       
    88 #define OWF_BILINEAR_ROUNDING_VALUE 0.5f
       
    89 #define OWF_SOURCE_CONVERSION_ROUNDING_VALUE 0.5f
       
    90 #define OWF_BLEND_ROUNDING_VALUE (OWF_ALPHA_MAX_VALUE/2)
       
    91 #define OWF_PREMUL_ROUNDING_FACTOR (OWF_ALPHA_MAX_VALUE/2)
       
    92 
       
    93 #endif
       
    94 
       
    95 /*
       
    96  * Byte order of different color formats
       
    97  * these are used when converting from/to
       
    98  * internal format
       
    99  */
       
   100 
       
   101 #define ARGB8888_ALPHA_MASK         0xFF000000
       
   102 #define ARGB8888_RED_MASK           0x00FF0000
       
   103 #define ARGB8888_GREEN_MASK         0x0000FF00
       
   104 #define ARGB8888_BLUE_MASK          0x000000FF
       
   105 #define ARGB8888_ALPHA_SHIFT        24
       
   106 #define ARGB8888_RED_SHIFT          16
       
   107 #define ARGB8888_GREEN_SHIFT        8
       
   108 #define ARGB8888_BLUE_SHIFT         0
       
   109 
       
   110 #define RGB565_ALPHA_MASK   0xFFFF
       
   111 #define RGB565_RED_MASK     0xF800
       
   112 #define RGB565_GREEN_MASK   0x07E0
       
   113 #define RGB565_BLUE_MASK    0x001F
       
   114 
       
   115 /* These are used when converting from RGB565 to ARGB8888. */
       
   116 #define RGB565_ALPHA_SHIFT  16
       
   117 #define RGB565_RED_SHIFT    11
       
   118 #define RGB565_GREEN_SHIFT  5
       
   119 
       
   120 /* subpixels per pixel */
       
   121 #define OWF_PIXEL_SIZE      4
       
   122 
       
   123 /* subpixel in bytes */
       
   124 #define OWF_SUBPIXEL_SIZE   sizeof(OWFsubpixel)
       
   125 #define OWF_BYTES_PER_PIXEL (OWF_PIXEL_SIZE * OWF_SUBPIXEL_SIZE)
       
   126 
       
   127 #pragma pack(push, 1)
       
   128 typedef union {
       
   129     struct {
       
   130         OWFsubpixel         blue;
       
   131         OWFsubpixel         green;
       
   132         OWFsubpixel         red;
       
   133         OWFsubpixel         alpha;
       
   134     } color;
       
   135     OWFsubpixel             subpixel[OWF_PIXEL_SIZE];
       
   136     OWFuint8                pixelbytes[OWF_BYTES_PER_PIXEL];
       
   137 } OWFpixel;
       
   138 #pragma pack(pop)
       
   139 
       
   140 /* -- */
       
   141 
       
   142 /* filters used in OWF_Image_Stretch */
       
   143 typedef enum {
       
   144     OWF_FILTER_POINT_SAMPLING,  /* nearest pixel */
       
   145     OWF_FILTER_BILINEAR        /* nearest 4 */
       
   146 } OWF_FILTERING;
       
   147 
       
   148 typedef struct {
       
   149     OWFint                  width;
       
   150     OWFint                  height;
       
   151     OWFint                  stride; /* number of bytes per line */
       
   152     OWFint                  pixelSize; /* pixel size in bytes */
       
   153     OWF_IMAGE_FORMAT        format;
       
   154     OWFboolean              foreign;
       
   155     OWFint                  dataMax; /* data buffer max size */
       
   156     void*                   data;
       
   157 } OWF_IMAGE;
       
   158 
       
   159 /* This typedef denotes an owned OWF_IMAGE, as opposed to a temporary association.
       
   160  * Owned instances must be destroyed when the containing object is destroyed.
       
   161  */
       
   162 typedef OWF_IMAGE* OWF_IMAGE_INST;
       
   163 
       
   164 typedef enum {
       
   165     OWF_FLIP_NONE,
       
   166     OWF_FLIP_VERTICALLY     = 1,
       
   167     OWF_FLIP_HORIZONTALLY   = 2
       
   168 } OWF_FLIP_DIRECTION;
       
   169 
       
   170 typedef enum {
       
   171     OWF_ROTATION_0          = 0,
       
   172     OWF_ROTATION_90         = 90,
       
   173     OWF_ROTATION_180        = 180,
       
   174     OWF_ROTATION_270        = 270
       
   175 } OWF_ROTATION;
       
   176 
       
   177 typedef enum {
       
   178     OWF_TRANSPARENCY_NONE,
       
   179     OWF_TRANSPARENCY_GLOBAL_ALPHA   = (1 << 0),
       
   180     OWF_TRANSPARENCY_SOURCE_ALPHA   = (1 << 1),
       
   181     OWF_TRANSPARENCY_MASK           = (1 << 2),
       
   182     OWF_TRANSPARENCY_COLOR_KEY      = (1 << 3)
       
   183 } OWF_TRANSPARENCY;
       
   184 
       
   185 typedef struct _OWF_BLEND_INFO {
       
   186     struct {
       
   187         OWF_IMAGE*          image;
       
   188         OWF_RECTANGLE*      rectangle;
       
   189     } destination;
       
   190 
       
   191     struct {
       
   192         OWF_IMAGE*          image;
       
   193         OWF_RECTANGLE*      rectangle;
       
   194     } source;
       
   195 
       
   196     OWF_IMAGE*              mask;
       
   197     OWFsubpixel             globalAlpha;
       
   198     OWFboolean              destinationFullyOpaque;
       
   199     OWFpixel*               tsColor;
       
   200 } OWF_BLEND_INFO;
       
   201 
       
   202 
       
   203 /*!---------------------------------------------------------------------------
       
   204  *  \brief Initialize image object
       
   205  *
       
   206  *  \param image            Image object to initialize
       
   207  *----------------------------------------------------------------------------*/
       
   208 OWF_API_CALL void
       
   209 OWF_Image_Init(OWF_IMAGE* image);
       
   210 
       
   211 /*!---------------------------------------------------------------------------
       
   212  *  \brief Creates new reference counted image object
       
   213  *
       
   214  *  \param width            Image width (in pixels)
       
   215  *  \param height           Image height (in pixels)
       
   216  *  \param format           Image format (\see OWF_IMAGE_FORMAT)
       
   217  *  \param buffer           Pointer to image pixel data. If NULL, then a new
       
   218  *                          buffer is allocated for storing image pixel data.
       
   219  *                          Allocated buffer is owned by the image. If non-NULL,
       
   220  *                          then the image will be a "foreign" one, that doesn't
       
   221  *                          own the pixel data but merely uses it.
       
   222  *  \param minimumStride    Minimum number of bytes per scanline (may be zero)
       
   223  *
       
   224  *
       
   225  *  \return New image object or NULL if error occured.
       
   226  *----------------------------------------------------------------------------*/
       
   227 OWF_PUBLIC OWF_IMAGE*
       
   228 OWF_Image_Create(OWFint width,
       
   229                  OWFint height,
       
   230                  const OWF_IMAGE_FORMAT* format,
       
   231                  void* buffer,
       
   232                  OWFint minimumStride);
       
   233 
       
   234 /*!---------------------------------------------------------------------------
       
   235  *  \brief Destroy image object. Rather than actually destroying the image
       
   236  *  immediately, this decrements image's reference count by one and once the
       
   237  *  counter reaches zero, the actual deletion will occur.
       
   238  *
       
   239  *  \param image            Image to destroy
       
   240  *----------------------------------------------------------------------------*/
       
   241 OWF_PUBLIC void
       
   242 OWF_Image_Destroy(OWF_IMAGE* image);
       
   243 
       
   244 /*!---------------------------------------------------------------------------
       
   245  *  \brief Create a pixel-perfect copy (clone) of the image. The copy will be
       
   246  *  totally independent from the original image, i.e. doesn't share pixel
       
   247  *  buffers or anything.
       
   248  *
       
   249  *  \param image            Image to copy
       
   250  *
       
   251  *  \param Copy of the image or NULL if error occured.
       
   252  *----------------------------------------------------------------------------*/
       
   253 OWF_API_CALL OWF_IMAGE*
       
   254 OWF_Image_Copy(const OWF_IMAGE* image);
       
   255 
       
   256 /*!---------------------------------------------------------------------------
       
   257  *  \brief Set image size. This doesn't modify the pixel data in anyway,
       
   258  *  merely just changes the image header. Mostly used for (recycling) foreign
       
   259  *  images that point to external pixel buffers.
       
   260  *
       
   261  *  If the new pixel count (width * height) exceeds
       
   262  *  current values, the pixel buffer will NOT be resized, but the call will FAIL.
       
   263  *
       
   264  *  \param image            Image to resize
       
   265  *  \param width            New width of the image
       
   266  *  \param height           New height of the image
       
   267  *
       
   268  *
       
   269  *  \return Boolean value indicating success of the operation. In case of
       
   270  *  failure, no modifications are done to original image.
       
   271  *----------------------------------------------------------------------------*/
       
   272 OWF_API_CALL OWFboolean
       
   273 OWF_Image_SetSize(OWF_IMAGE* image,
       
   274                   OWFint width,
       
   275                   OWFint height);
       
   276 
       
   277 /*!---------------------------------------------------------------------------
       
   278  *  \brief Set internal mode flags. This doesn't modify the pixel data in anyway,
       
   279  *  merely just changes the image header. Mostly used for (recycling) foreign
       
   280  *  images that point to external pixel buffers.
       
   281  *
       
   282  *
       
   283  *  \param image            Image to resize
       
   284  *  \param premultiply      Image data is premultiplied
       
   285  *  \param linear           Image colour data is linear
       
   286  *
       
   287  *
       
   288  *  \return Boolean value indicating success of the operation. In case of
       
   289  *  failure, no modifications are done to original image.
       
   290  *----------------------------------------------------------------------------*/
       
   291 OWF_API_CALL void
       
   292 OWF_Image_SetFlags(OWF_IMAGE* image,
       
   293                   OWFboolean premultiply,
       
   294                   OWFboolean linear);
       
   295 
       
   296 /*!---------------------------------------------------------------------------
       
   297  *  \brief Set the pixel buffer to an alternate location.
       
   298  *  All other parameters remain the same.
       
   299  *
       
   300  *  \param image            Image to resize
       
   301  *  \param buffer           Image data source to start using
       
   302  *
       
   303  *----------------------------------------------------------------------------*/
       
   304 OWF_API_CALL void
       
   305 OWF_Image_SetPixelBuffer(OWF_IMAGE* image,      void* buffer);
       
   306 
       
   307 
       
   308 /*!---------------------------------------------------------------------------
       
   309  *  \brief Blit (1:1 copy) pixels from image to another w/ clipping.
       
   310  *
       
   311  *  \param dst              Destination image
       
   312  *  \param dstRect          Destination rectangle
       
   313  *  \param src              Source image
       
   314  *  \param srcRect          Source rectangle
       
   315  *
       
   316  *  \return Boolean value indicating whether pixels were copied or not. If not,
       
   317  *  it means that either of the rectangles is outside its respective image's
       
   318  *  bounds.
       
   319  *----------------------------------------------------------------------------*/
       
   320 OWF_API_CALL OWFboolean
       
   321 OWF_Image_Blit(OWF_IMAGE* dst,
       
   322                OWF_RECTANGLE const* dstRect,
       
   323                OWF_IMAGE const* src,
       
   324                OWF_RECTANGLE const* srcRect);
       
   325 
       
   326 /*!---------------------------------------------------------------------------
       
   327  *  \brief Stretch-blit (scaled copy) pixels from image to another w/ clipping.
       
   328  *
       
   329  *  \param dst              Destination image
       
   330  *  \param dstRect          Destination rectangle
       
   331  *  \param src              Source image
       
   332  *  \param srcRect          Source rectangle
       
   333  *
       
   334  *  \return Boolean value indicating whether pixels were copied or not. If not,
       
   335  *  it means that either of the rectangles is outside its respective image's
       
   336  *  bounds.
       
   337  *----------------------------------------------------------------------------*/
       
   338 OWF_API_CALL OWFboolean
       
   339 OWF_Image_Stretch(OWF_IMAGE* dst,
       
   340                   OWF_RECTANGLE* dstRect,
       
   341                   OWF_IMAGE* src,
       
   342                   OWFfloat* srcRect,
       
   343                   OWF_FILTERING filter);
       
   344 
       
   345 /*!---------------------------------------------------------------------------
       
   346  *  \brief Multiply pixels' alpha value into rgb-color components.
       
   347  *  Multiplies only if image source image is non-premultiplied.
       
   348  *  \param image            Image to convert to pre-multiplied domain.
       
   349  *----------------------------------------------------------------------------*/
       
   350 OWF_API_CALL void
       
   351 OWF_Image_PremultiplyAlpha(OWF_IMAGE* image);
       
   352 
       
   353 /*!---------------------------------------------------------------------------
       
   354  *  \brief Divide pixels' rgb-color components by its alpha value.
       
   355  *
       
   356  *  \param image            Image to convert to nonpre-multiplied domain.
       
   357  *----------------------------------------------------------------------------*/
       
   358 OWF_API_CALL void
       
   359 OWF_Image_UnpremultiplyAlpha(OWF_IMAGE* image);
       
   360 
       
   361 /*!---------------------------------------------------------------------------
       
   362  *  \brief Linearizes image pixel data
       
   363  *
       
   364  *  \param image            Image to convert to linear domain
       
   365  *----------------------------------------------------------------------------*/
       
   366 OWF_API_CALL void
       
   367 OWF_Image_LinearizeData(OWF_IMAGE* image);
       
   368 
       
   369 /*!---------------------------------------------------------------------------
       
   370  *  \brief Non-linearizes image pixel data
       
   371  *
       
   372  *  \param image            Image to convert to non-linear domain
       
   373  *----------------------------------------------------------------------------*/
       
   374 OWF_API_CALL void
       
   375 OWF_Image_NonLinearizeData(OWF_IMAGE* image);
       
   376 
       
   377 /*!---------------------------------------------------------------------------
       
   378  *  \brief Apply gamma correction to image pixel values
       
   379  *
       
   380  *  \param image            Image to operate on
       
   381  *  \param gamma            Gamma value
       
   382  *----------------------------------------------------------------------------*/
       
   383 OWF_API_CALL void
       
   384 OWF_Image_Gamma(OWF_IMAGE* image, OWFfloat gamma);
       
   385 
       
   386 /*!---------------------------------------------------------------------------
       
   387  *  \brief Flip (mirror) image about one or both of its center axes.
       
   388  *
       
   389  *  \param image            Image to flip
       
   390  *  \param dir              Flip direction. Valid values are
       
   391  *                          OWF_FLIP_NONE, OWF_FLIP_HORIZONTALLY,
       
   392  *                          OWF_FLIP_VERTICALLY or any bitwise-or combination
       
   393  *                          of the former.
       
   394  *----------------------------------------------------------------------------*/
       
   395 OWF_API_CALL void
       
   396 OWF_Image_Flip(OWF_IMAGE* image,
       
   397                OWF_FLIP_DIRECTION dir);
       
   398 
       
   399 /*!---------------------------------------------------------------------------
       
   400  *  \brief Rotate image n*90 degrees about its center
       
   401  *
       
   402  *  \param dst              Result (rotated) image.
       
   403  *  \param src              Source image.
       
   404  *  \param rotation         Rotation angle (OWF_ROTATION_0, OWF_ROTATION_90,
       
   405  *                          OWF_ROTATION_180, or OWF_ROTATION_270)
       
   406  *----------------------------------------------------------------------------*/
       
   407 OWF_API_CALL void
       
   408 OWF_Image_Rotate(OWF_IMAGE* dst,
       
   409                  OWF_IMAGE* src,
       
   410                  OWF_ROTATION rotation);
       
   411 
       
   412 /*!---------------------------------------------------------------------------
       
   413  *  \brief
       
   414  *
       
   415  *  \param
       
   416  *
       
   417  *  \return
       
   418  *----------------------------------------------------------------------------*/
       
   419 OWF_API_CALL void
       
   420 OWF_Image_Blend(OWF_BLEND_INFO* blend,
       
   421                 OWF_TRANSPARENCY transparency);
       
   422 
       
   423 /*!---------------------------------------------------------------------------
       
   424  *  \brief
       
   425  *
       
   426  *  \param
       
   427  *
       
   428  *  \return
       
   429  *----------------------------------------------------------------------------*/
       
   430 OWF_API_CALL void
       
   431 OWF_Image_Clear(OWF_IMAGE* image,
       
   432                 OWFsubpixel red,
       
   433                 OWFsubpixel green,
       
   434                 OWFsubpixel blue,
       
   435                 OWFsubpixel alpha);
       
   436 
       
   437 /*!---------------------------------------------------------------------------
       
   438  *  \brief Convert image data from internal color format to destination format
       
   439  *
       
   440  *  \param dst
       
   441  *  \param src
       
   442  *
       
   443  *  \return
       
   444  *----------------------------------------------------------------------------*/
       
   445 OWF_API_CALL OWFboolean
       
   446 OWF_Image_DestinationFormatConversion(OWF_IMAGE* dst,
       
   447                                       OWF_IMAGE* src);
       
   448 /*!---------------------------------------------------------------------------
       
   449  *  \brief Test whether it will be possible to convert to destination format.
       
   450  *  Note, no IMAGE object yet extists. This is effectively a "static" member method.
       
   451  *  \param format proposed destination format
       
   452  *
       
   453  *  \return boolean true if image lib can convert image data from internal color format 
       
   454  *----------------------------------------------------------------------------*/
       
   455 OWF_API_CALL OWFboolean
       
   456 OWF_Image_IsValidDestinationFormat(OWF_IMAGE_FORMAT* format);
       
   457 
       
   458 /*!---------------------------------------------------------------------------
       
   459 *  \brief Convert image data from source format to internal format
       
   460  *
       
   461  *  \param src
       
   462  *  \param dst
       
   463  *
       
   464  *  \return
       
   465  *----------------------------------------------------------------------------*/
       
   466 OWF_API_CALL OWFboolean
       
   467 OWF_Image_SourceFormatConversion(OWF_IMAGE* dst,
       
   468                                  OWF_IMAGE* src);
       
   469 
       
   470 /*!---------------------------------------------------------------------------
       
   471  *  \brief
       
   472  *
       
   473  *  \param
       
   474  *
       
   475  *  \return
       
   476  *----------------------------------------------------------------------------*/
       
   477 OWF_API_CALL void*
       
   478 OWF_Image_AllocData(OWF_DISPCTX dc, OWFint width,
       
   479                     OWFint height,
       
   480                     OWF_PIXEL_FORMAT format);
       
   481 
       
   482 
       
   483 /*!---------------------------------------------------------------------------
       
   484  *  \brief
       
   485  *
       
   486  *  \param
       
   487  *
       
   488  *  \return
       
   489  *----------------------------------------------------------------------------*/
       
   490 OWF_API_CALL void
       
   491 OWF_Image_FreeData(OWF_DISPCTX dc, void** buffer);
       
   492 
       
   493 /*!---------------------------------------------------------------------------
       
   494  *  \brief
       
   495  *
       
   496  *  \param
       
   497  *
       
   498  *  \return
       
   499  *----------------------------------------------------------------------------*/
       
   500 OWF_API_CALL OWFint
       
   501 OWF_Image_GetFormatPixelSize(OWF_PIXEL_FORMAT format);
       
   502 
       
   503 
       
   504 /*!---------------------------------------------------------------------------
       
   505  * \brief Return stride (aligned row size in bytes) calculated from image
       
   506  * width and pixelSize. If pixelSize is negative image width must be divisible
       
   507  * by pixelSize.
       
   508  *
       
   509  * \param width             Width of image
       
   510  * \param pixelSize         Size of single pixel in bytes. Negative size
       
   511  *                          means value is a divisor (i.e. 1/pixelSize)
       
   512  * \param padding           Number of bits each row is padded to.
       
   513 
       
   514  * \return Row size in bytes.
       
   515  *----------------------------------------------------------------------------*/
       
   516 OWF_PUBLIC OWFint
       
   517 OWF_Image_GetStride(OWFint width,
       
   518                     const OWF_IMAGE_FORMAT* format,OWFint minimumStride);
       
   519 
       
   520 /*!---------------------------------------------------------------------------
       
   521  *  \brief
       
   522  *
       
   523  *  \param
       
   524  *
       
   525  *  \return
       
   526  *----------------------------------------------------------------------------*/
       
   527 OWF_API_CALL OWFint
       
   528 OWF_Image_GetFormatPadding(OWF_PIXEL_FORMAT format);
       
   529 
       
   530 /*!---------------------------------------------------------------------------
       
   531  *  \brief Swap image width & height values in image header. Doesn't modify
       
   532  *  image pixel data.
       
   533  *
       
   534  *  \param image            Image to operate on.
       
   535  *----------------------------------------------------------------------------*/
       
   536 OWF_API_CALL void
       
   537 OWF_Image_SwapWidthAndHeight(OWF_IMAGE* image);
       
   538 
       
   539 /*!---------------------------------------------------------------------------
       
   540  *  \brief Convert mask from external format to internal 8bpp format.
       
   541  *
       
   542  *  \param output           Result (converted) mask image
       
   543  *  \param input            Input mask image to convert.
       
   544  *
       
   545  *  \return Boolean value indicating operation success. OWF_FALSE means that
       
   546  *  input mask is either invalid or unsupported, or degenerate in some other
       
   547  *  fascinating way.
       
   548  *----------------------------------------------------------------------------*/
       
   549 OWF_API_CALL OWFboolean
       
   550 OWF_Image_ConvertMask(OWF_IMAGE* output,
       
   551                       OWF_IMAGE* input);
       
   552 
       
   553 /*!---------------------------------------------------------------------------
       
   554  *  \brief Return pointer to given pixel in image.
       
   555  *
       
   556  *  \param image            Image
       
   557  *  \param x                X-coordinate of the pixel (0..width-1)
       
   558  *  \param y                Y-coordinate of the pixel (0..height-1)
       
   559  *
       
   560  *  The x & y coordinates will be clamped to [0..width-1, 0..height-1]
       
   561  *
       
   562  *  \return Pointer to given pixel
       
   563  *----------------------------------------------------------------------------*/
       
   564 OWF_API_CALL OWFpixel*
       
   565 OWF_Image_GetPixelPtr(OWF_IMAGE* image,
       
   566                       OWFint x,
       
   567                       OWFint y);
       
   568 
       
   569 /*!---------------------------------------------------------------------------
       
   570  *  \brief Read single pixel from image
       
   571  *
       
   572  *  \param image Image
       
   573  *  \param x Pixel x coordinate
       
   574  *  \param y Pixel y coordinate
       
   575  *  \param pixel Where to store the pixel color value
       
   576  *
       
   577  *  Coordinates are clamped to region (0..width-1, 0..height-1)
       
   578  *----------------------------------------------------------------------------*/
       
   579 OWF_API_CALL void
       
   580 OWF_Image_GetPixel(OWF_IMAGE* image,
       
   581                    OWFint x,
       
   582                    OWFint y,
       
   583                    OWFpixel* pixel);
       
   584 
       
   585 /*!---------------------------------------------------------------------------
       
   586  *  \brief Write a pixel into image
       
   587  *
       
   588  *  \param image Image
       
   589  *  \param x Pixel x coordinate
       
   590  *  \param y Pixel y coordinate
       
   591  *  \param pixel Color of the pixel
       
   592  *
       
   593  *  Coordinates are clamped to region (0..width-1, 0..height-1)
       
   594  *----------------------------------------------------------------------------*/
       
   595 OWF_API_CALL void
       
   596 OWF_Image_SetPixel(OWF_IMAGE* image,
       
   597                    OWFint x,
       
   598                    OWFint y,
       
   599                    OWFpixel const* pixel);
       
   600 
       
   601 #ifdef __cplusplus
       
   602 }
       
   603 #endif
       
   604 
       
   605 #endif