Last change
on this file since 2831 was
2831,
checked in by ldelgass, 12 years ago
|
Refactor texture classes, misc. cleanups, cut down on header pollution -- still
need to fix header deps in Makefile.in
|
-
Property svn:eol-style set to
native
|
File size:
955 bytes
|
Line | |
---|
1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | #include <memory.h> |
---|
3 | #include <stdlib.h> |
---|
4 | |
---|
5 | #include "Image.h" |
---|
6 | |
---|
7 | Image::Image(const unsigned int width, const unsigned int height, |
---|
8 | const ImageFormat format, const Image::DataType type, void *data) : |
---|
9 | _width(width), |
---|
10 | _height(height), |
---|
11 | _format(format), |
---|
12 | _dataType(type) |
---|
13 | { |
---|
14 | switch (type) { |
---|
15 | case IMG_UNSIGNED_BYTE: |
---|
16 | _dataTypeByteSize = 1; |
---|
17 | break; |
---|
18 | case IMG_FLOAT: |
---|
19 | _dataTypeByteSize = 4; |
---|
20 | break; |
---|
21 | } |
---|
22 | |
---|
23 | //_dataBuffer = aligned_malloc(width * height * comp * _dataTypeByteSize, 16); |
---|
24 | _dataBuffer = malloc(width * height * format * _dataTypeByteSize); |
---|
25 | |
---|
26 | if (data != NULL) { |
---|
27 | memcpy(_dataBuffer, data, width *height * format * _dataTypeByteSize); |
---|
28 | } else { |
---|
29 | memset(_dataBuffer, 0, width * height * format * _dataTypeByteSize); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | Image::~Image() |
---|
34 | { |
---|
35 | //aligend_free(_dataBuffer); |
---|
36 | free(_dataBuffer); |
---|
37 | } |
---|
38 | |
---|
Note: See
TracBrowser
for help on using the repository browser.