summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscuri <scuri>2011-01-19 16:28:59 +0000
committerscuri <scuri>2011-01-19 16:28:59 +0000
commita3ef3df6ecc95439e2d6fb909cc30fab77675e9f (patch)
treebdd7c251dfaa9c5a7b6c91625cdf327e4ef32bc4 /src
parent1a113acb45c6228039b0b1d40afceaa041ff8869 (diff)
Fixed: support for alpha with gray images in SGI format.
Diffstat (limited to 'src')
-rw-r--r--src/im_format_sgi.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/im_format_sgi.cpp b/src/im_format_sgi.cpp
index 08bbf4d..695340b 100644
--- a/src/im_format_sgi.cpp
+++ b/src/im_format_sgi.cpp
@@ -2,7 +2,7 @@
* \brief SGI - Silicon Graphics Image File Format
*
* See Copyright Notice in im_lib.h
- * $Id: im_format_sgi.cpp,v 1.2 2008/12/03 15:45:34 scuri Exp $
+ * $Id: im_format_sgi.cpp,v 1.3 2011/01/19 16:28:59 scuri Exp $
*/
#include "im_format.h"
@@ -300,9 +300,13 @@ int imFileFormatSGI::ReadImageInfo(int index)
switch (dimension)
{
case 1:
+ // If this value is 1, the image file consists of only 1 channel and only 1 scanline (row).
+ // Only width is valid.
this->height = 1;
depth = 1;
case 2:
+ // If this value is 2, the file consists of a single channel with a number of scanlines.
+ // Only width and height are valid.
depth = 1;
break;
case 3:
@@ -319,6 +323,10 @@ int imFileFormatSGI::ReadImageInfo(int index)
case 1:
this->file_color_mode = IM_GRAY;
break;
+ case 2:
+ // This is NOT mentioned by the specification, but it is used
+ this->file_color_mode = IM_GRAY | IM_ALPHA;
+ break;
case 3:
this->file_color_mode = IM_RGB;
break;
@@ -411,6 +419,13 @@ int imFileFormatSGI::WriteImageInfo()
if (imColorModeHasAlpha(this->user_color_mode))
this->file_color_mode |= IM_ALPHA;
}
+ else if (this->file_color_mode == IM_GRAY &&
+ imColorModeHasAlpha(this->user_color_mode))
+ {
+ // This is NOT mentioned by the specification, but it is used
+ dimension = 3;
+ this->file_color_mode |= IM_ALPHA;
+ }
this->file_data_type = this->user_data_type;