Last change
on this file since 2096 was
2096,
checked in by ldelgass, 13 years ago
|
Normalize line endings, set eol-style to native on *.cpp, *.h files
|
-
Property svn:eol-style set to
native
|
File size:
909 bytes
|
Line | |
---|
1 | #include "Image.h" |
---|
2 | #include <memory.h> |
---|
3 | #include <stdlib.h> |
---|
4 | |
---|
5 | Image::Image(const unsigned int width, const unsigned int height, |
---|
6 | const ImageFormat format, const Image::DataType type, void* data ) : |
---|
7 | _width(width), |
---|
8 | _height(height), |
---|
9 | _format(format), |
---|
10 | _dataType(type) |
---|
11 | { |
---|
12 | switch (type) |
---|
13 | { |
---|
14 | case IMG_UNSIGNED_BYTE : |
---|
15 | _dataTypeByteSize = 1; |
---|
16 | break; |
---|
17 | case IMG_FLOAT : |
---|
18 | _dataTypeByteSize = 4; |
---|
19 | break; |
---|
20 | } |
---|
21 | |
---|
22 | //_dataBuffer = aligned_malloc(width * height * comp * _dataTypeByteSize, 16); |
---|
23 | _dataBuffer = malloc(width * height * format * _dataTypeByteSize); |
---|
24 | |
---|
25 | if (data != 0) |
---|
26 | { |
---|
27 | memcpy(_dataBuffer, data, width *height * format * _dataTypeByteSize); |
---|
28 | } |
---|
29 | else |
---|
30 | { |
---|
31 | memset(_dataBuffer, 0, width * height * format * _dataTypeByteSize); |
---|
32 | } |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | Image::~Image() |
---|
37 | { |
---|
38 | //aligend_free(_dataBuffer); |
---|
39 | free(_dataBuffer); |
---|
40 | } |
---|
41 | |
---|
Note: See
TracBrowser
for help on using the repository browser.