From 534630bdcce44381bb726c5981c5a827bacc615a Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 1 Jan 2017 22:42:37 +0100 Subject: [PATCH] Changed: Implement CBitmap::setPixelColor --HG-- branch : develop --- code/nel/include/nel/misc/bitmap.h | 8 +++++++- code/nel/src/misc/bitmap.cpp | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/bitmap.h b/code/nel/include/nel/misc/bitmap.h index f96cd39b9..7e5994152 100644 --- a/code/nel/include/nel/misc/bitmap.h +++ b/code/nel/include/nel/misc/bitmap.h @@ -636,11 +636,17 @@ public: - /** Get the pixel at the given coorrdinate. + /** Get the pixel at the given coordinate. * Works in RGBA and DXTC modes. * Outside of the bitmap it returns Black (or if mipmap is not found) */ CRGBA getPixelColor(sint x, sint y, uint32 numMipMap = 0) const; + + /** Set the pixel at the given coordinate. + * Works in RGBA mode only. + */ + void setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap = 0); + /** * Horizontal flip (all the columns are flipped) * Works only with RGBA, and DXTC formats (only if w/h is a power of 2) diff --git a/code/nel/src/misc/bitmap.cpp b/code/nel/src/misc/bitmap.cpp index 0f92920f5..47bdf3886 100644 --- a/code/nel/src/misc/bitmap.cpp +++ b/code/nel/src/misc/bitmap.cpp @@ -4510,6 +4510,20 @@ CRGBA CBitmap::getPixelColor(sint x, sint y, uint32 numMipMap /*=0*/) const return CRGBA::Black; } +//----------------------------------------------- +void CBitmap::setPixelColor(sint x, sint y, CRGBA c, uint32 numMipMap) +{ + nlassert(PixelFormat == RGBA); + + uint w = getWidth(numMipMap); + uint h = getHeight(numMipMap); + + if (w == 0 || x < 0 || y < 0 || x >= (sint)w || y >= (sint)h) return; + + uint8 *pix = &getPixels(numMipMap)[(x + y * w) << 2]; + + memcpy(pix, &c, sizeof(CRGBA)); +} //----------------------------------------------- void CBitmap::swap(CBitmap &other)