[arrayfire] 36/75: Added support for loading 32 bit integer images
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:01:13 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.
commit 9b10c0e7c8ff267582e65700e9efcdfdb986414a
Author: Youssef Nashed <ynashed at anl.gov>
Date: Tue Feb 16 14:40:45 2016 -0600
Added support for loading 32 bit integer images
---
src/api/c/imageio.cpp | 40 ++++++++++++++++++++++++++++++++++------
src/api/c/imageio2.cpp | 26 ++++++++++++++++++++++----
2 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/src/api/c/imageio.cpp b/src/api/c/imageio.cpp
index 748ddbc..d990b10 100644
--- a/src/api/c/imageio.cpp
+++ b/src/api/c/imageio.cpp
@@ -186,7 +186,10 @@ af_err af_load_image(af_array *out, const char* filename, const bool isColor)
if(fi_bpc != 8 && fi_bpc != 16 && fi_bpc != 32) {
AF_ERROR("FreeImage Error: Bits per channel not supported", AF_ERR_NOT_SUPPORTED);
}
-
+
+ // data type
+ FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(pBitmap);
+
// sizes
uint fi_w = FreeImage_GetWidth(pBitmap);
uint fi_h = FreeImage_GetHeight(pBitmap);
@@ -204,21 +207,36 @@ af_err af_load_image(af_array *out, const char* filename, const bool isColor)
else if(fi_bpc == 16)
AF_CHECK((readImage<ushort, AFFI_RGBA, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage<float, AFFI_RGBA, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage<uint, AFFI_RGBA, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage<int, AFFI_RGBA, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage<float, AFFI_RGBA, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
} else if (fi_color == 1) {
if(fi_bpc == 8)
AF_CHECK((readImage<uchar, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 16)
AF_CHECK((readImage<ushort, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage<float, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage<uint, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage<int, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage<float, AFFI_GRAY, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
} else { //3 channel image
if(fi_bpc == 8)
AF_CHECK((readImage<uchar, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 16)
AF_CHECK((readImage<ushort, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage<float, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage<uint, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage<int, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage<float, AFFI_RGB, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
}
} else { //output gray irrespective
if(fi_color == 1) { //4 channel image
@@ -227,14 +245,24 @@ af_err af_load_image(af_array *out, const char* filename, const bool isColor)
else if(fi_bpc == 16)
AF_CHECK((readImage<ushort, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage<float, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage<uint, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage<int, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage<float, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
} else if (fi_color == 3 || fi_color == 4) {
if(fi_bpc == 8)
AF_CHECK((readImage<uchar, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 16)
AF_CHECK((readImage<ushort, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage<float, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage<uint, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage<int, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage<float, AFFI_RGB>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
}
}
diff --git a/src/api/c/imageio2.cpp b/src/api/c/imageio2.cpp
index ff7a4a8..44886aa 100644
--- a/src/api/c/imageio2.cpp
+++ b/src/api/c/imageio2.cpp
@@ -162,7 +162,10 @@ af_err af_load_image_native(af_array *out, const char* filename)
if(fi_bpc != 8 && fi_bpc != 16 && fi_bpc != 32) {
AF_ERROR("FreeImage Error: Bits per channel not supported", AF_ERR_NOT_SUPPORTED);
}
-
+
+ // data type
+ FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(pBitmap);
+
// sizes
uint fi_w = FreeImage_GetWidth(pBitmap);
uint fi_h = FreeImage_GetHeight(pBitmap);
@@ -179,21 +182,36 @@ af_err af_load_image_native(af_array *out, const char* filename)
else if(fi_bpc == 16)
AF_CHECK((readImage_t<ushort, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage_t<float, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage_t<uint, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage_t<int, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage_t<float, AFFI_RGBA>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
} else if (fi_color == 1) {
if(fi_bpc == 8)
AF_CHECK((readImage_t<uchar, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 16)
AF_CHECK((readImage_t<ushort, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage_t<float, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage_t<uint, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage_t<int, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage_t<float, AFFI_GRAY>)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
} else { //3 channel imag
if(fi_bpc == 8)
AF_CHECK((readImage_t<uchar, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 16)
AF_CHECK((readImage_t<ushort, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
else if(fi_bpc == 32)
- AF_CHECK((readImage_t<float, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h));
+ switch(image_type) {
+ case FIT_UINT32: AF_CHECK((readImage_t<uint, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_INT32: AF_CHECK((readImage_t<int, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ case FIT_FLOAT: AF_CHECK((readImage_t<float, AFFI_RGB >)(&rImage, pSrcLine, nSrcPitch, fi_w, fi_h)); break;
+ default: AF_ERROR("FreeImage Error: Unknown image type", AF_ERR_NOT_SUPPORTED); break;
+ }
}
std::swap(*out,rImage);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list