diff options
| author | Comment <tim@gray.(none)> | 2013-07-26 22:46:00 +0100 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-07-26 22:46:00 +0100 |
| commit | 3d7eea02aa7a155b84c8c74ecbfd55a1941a9297 (patch) | |
| tree | d49d6ac97a0df08f5ea7e6c6c291acca0f65cd12 /rotord/Pixels.cpp | |
| parent | 7092eaaae3e844a68804b8a6b6825381e9a81443 (diff) | |
tidy files
Diffstat (limited to 'rotord/Pixels.cpp')
| -rw-r--r-- | rotord/Pixels.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/rotord/Pixels.cpp b/rotord/Pixels.cpp deleted file mode 100644 index 78f4bbb..0000000 --- a/rotord/Pixels.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include "Pixels.h" -Pixels::Pixels(){ - pixels=nullptr; - pixelsOwner=false; -} -Pixels::~Pixels(){ - clear(); -} -void Pixels::allocate(int w, int h, int _channels){ - if (w < 0 || h < 0) { - return; - } - - //we check if we are already allocated at the right size - if(bAllocated && w == width && h == height && channels ==_channels){ - return; //we don't need to allocate - } - - //we do need to allocate, clear the data - clear(); - - channels = _channels; - width= w; - height = h; - - pixels = new uint8_t[w * h * channels]; - bAllocated = true; - pixelsOwner = true; -} -void Pixels::clear(){ - if(pixels){ - if(pixelsOwner) delete[] pixels; - pixels = nullptr; - } - - width = 0; - height = 0; - channels = 0; - bAllocated = false; -} -bool Pixels::isAllocated() const{ - return bAllocated; -} - -void Pixels::setFromExternalPixels(uint8_t * newPixels,int w, int h, int _channels){ - clear(); - channels = _channels; - width= w; - height = h; - - pixels = newPixels; - pixelsOwner = false; - bAllocated = true; -} - -uint8_t * Pixels::getPixels(){ - return &pixels[0]; -} - -int Pixels::getWidth() const{ - return width; -} - -int Pixels::getHeight() const{ - return height; -} - -int Pixels::getBytesPerPixel() const{ - return channels; -} - -int Pixels::getNumChannels() const{ - return channels; -} - -void Pixels::swap(Pixels & pix){ - std::swap(pixels,pix.pixels); - std::swap(width, pix.width); - std::swap(height,pix.height); - std::swap(channels,pix.channels); - std::swap(pixelsOwner, pix.pixelsOwner); - std::swap(bAllocated, pix.bAllocated); -} - -void Pixels::set(uint8_t val){ - int size = width * height * channels; - for(int i = 0; i < size; i++){ - pixels[i] = val; - } -}
\ No newline at end of file |
