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