summaryrefslogtreecommitdiff
path: root/im/src/im_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'im/src/im_image.cpp')
-rwxr-xr-xim/src/im_image.cpp44
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);