summaryrefslogtreecommitdiff
path: root/common/image.cpp
diff options
context:
space:
mode:
authorleo2001-03-26 18:03:32 +0000
committerleo2001-03-26 18:03:32 +0000
commit8d291f870c589a35930c068326daffceebc63daa (patch)
tree2aa85c440c4f3e68efe9c938e6a09d9c74dbe708 /common/image.cpp
parentf1b22e07982337233ee4c1ad4cfbee0334ad93df (diff)
Fixed the file dialog preview.
git-svn-id: http://svn.leocad.org/trunk@264 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common/image.cpp')
-rw-r--r--common/image.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/common/image.cpp b/common/image.cpp
index 7f2e5c8..1accf6f 100644
--- a/common/image.cpp
+++ b/common/image.cpp
@@ -41,6 +41,20 @@ void Image::FreeData ()
m_pData = NULL;
}
+void Image::Allocate (int width, int height, bool alpha)
+{
+ FreeData ();
+
+ m_nWidth = width;
+ m_nHeight = height;
+ m_bAlpha = alpha;
+
+ if (m_bAlpha)
+ m_pData = (unsigned char*)malloc (width * height * 4);
+ else
+ m_pData = (unsigned char*)malloc (width * height * 3);
+}
+
void Image::ResizePow2 ()
{
int i, shifted_x, shifted_y;
@@ -124,12 +138,11 @@ bool Image::FileLoad (File& file)
file.Seek (-8, SEEK_CUR);
// Check for the BMP header
- if ((buf[0] == 'B') && (buf[1] == 'M'))
+ if ((buf[0] == 'B') && (buf[1] == 'M'))
{
if (!LoadBMP (file))
return false;
- ResizePow2 ();
return true;
}
@@ -139,7 +152,6 @@ bool Image::FileLoad (File& file)
if (!LoadJPG (file))
return false;
- ResizePow2 ();
return true;
}
#endif
@@ -153,20 +165,18 @@ bool Image::FileLoad (File& file)
if (!LoadPNG (file))
return false;
- ResizePow2 ();
return true;
}
#endif
// Check for the GIF header
if ((buf[0] == 'G') && (buf[1] == 'I') && (buf[2] == 'F') &&
- (buf[3] == '8') && ((buf[4] != '7') || (buf[4] == '9')) &&
+ (buf[3] == '8') && ((buf[4] == '7') || (buf[4] == '9')) &&
(buf[5] == 'a'))
{
if (!LoadGIF (file))
return false;
- ResizePow2 ();
return true;
}