diff options
Diffstat (limited to 'src/im_image.cpp')
| -rw-r--r-- | src/im_image.cpp | 35 | 
1 files changed, 34 insertions, 1 deletions
diff --git a/src/im_image.cpp b/src/im_image.cpp index 171d897..5f865f8 100644 --- a/src/im_image.cpp +++ b/src/im_image.cpp @@ -2,7 +2,7 @@   * \brief Image Manipulation   *   * See Copyright Notice in im_lib.h - * $Id: im_image.cpp,v 1.6 2010/01/15 17:21:47 scuri Exp $ + * $Id: im_image.cpp,v 1.7 2010/01/17 18:18:12 scuri Exp $   */  #include <stdlib.h> @@ -273,6 +273,39 @@ void imImageClear(imImage* image)      memset(image->data[image->depth], 0, image->plane_size);  } +template <class T>  +inline void iSet(T *map, T value, int count) +{ +  for (int i = 0; i < count; i++) +  { +    *map++ = value; +  } +} +   +void imImageSetAlpha(imImage* image, float alpha) +{ +  assert(image); + +  if (image->has_alpha) +  { +    switch(image->data_type) +    { +    case IM_BYTE: +      memset(image->data[image->depth], (imbyte)alpha, image->plane_size); +      break;                                                                                 +    case IM_USHORT:                                                                            +      iSet((imushort*)image->data[image->depth], (imushort)alpha, image->plane_size); +      break;                                                                                 +    case IM_INT:                                                                            +      iSet((int*)image->data[image->depth], (int)alpha, image->plane_size); +      break;                                                                                 +    case IM_FLOAT:                                                                            +      iSet((float*)image->data[image->depth], (float)alpha, image->plane_size); +      break;                                                                                 +    } +  } +} +  int imImageIsBitmap(const imImage* image)  {    assert(image);  | 
