diff options
author | Pixel <pixel@nobis-crew.org> | 2010-06-14 23:47:31 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2010-06-14 23:47:31 -0700 |
commit | 7c0c85a86aa73c0c495523f994f8412e377a8195 (patch) | |
tree | 29929fdc4390224b3a4f8b728d50ae5dfc3589ce /im/src/im_image.cpp | |
parent | 5000908b9b2761854951cea3e7dad90be76ffd59 (diff) |
Upgrading im to 3.6
Diffstat (limited to 'im/src/im_image.cpp')
-rwxr-xr-x | im/src/im_image.cpp | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/im/src/im_image.cpp b/im/src/im_image.cpp index 1fb993d..5f865f8 100755 --- a/im/src/im_image.cpp +++ b/im/src/im_image.cpp @@ -2,7 +2,7 @@ * \brief Image Manipulation * * See Copyright Notice in im_lib.h - * $Id: im_image.cpp,v 1.4 2009/08/13 22:34:25 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); @@ -302,6 +335,15 @@ void imImageCopyData(const imImage* src_image, imImage* dst_image) } } +void imImageCopyPlane(const imImage* src_image, int src_plane, imImage* dst_image, int dst_plane) +{ + assert(src_image); + assert(dst_image); + assert(imImageMatchDataType(src_image, dst_image)); + + memcpy(dst_image->data[dst_plane], src_image->data[src_plane], src_image->plane_size); +} + imImage* imImageDuplicate(const imImage* image) { assert(image); |