blob: d733bf29840c40b2f01897c92e34414fb8ae1d89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <QvSFImage.h>
// Can't use macro, since we define a constructor.
QvSFImage::QvSFImage()
{
size[0] = size[1] = 0;
numComponents = 0;
bytes = NULL;
}
QvSFImage::~QvSFImage()
{
if (bytes != NULL)
delete [] bytes;
}
QvBool
QvSFImage::readValue(QvInput *in)
{
if (! in->read(size[0]) ||
! in->read(size[1]) ||
! in->read(numComponents))
return FALSE;
if (bytes != NULL)
delete [] bytes;
bytes = new unsigned char[size[0] * size[1] * numComponents];
int byte = 0;
for (int i = 0; i < size[0] * size[1]; i++) {
unsigned long l;
if (! in->read(l))
return FALSE;
for (int j = 0; j < numComponents; j++)
bytes[byte++] =
(unsigned char) ((l >> (8*(numComponents-j-1))) & 0xFF);
}
return TRUE;
}
|