items draw rework, npc trade fix

This commit is contained in:
Henrique Santiago
2012-05-13 12:05:17 -03:00
parent 7b512bfa9f
commit 1203756baf
13 changed files with 165 additions and 46 deletions

View File

@@ -13,7 +13,7 @@ SET(BUILD_REVISION "custom" CACHE "Git revision string (intended for releases)"
# set debug as default build type
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF()
# setup compiler options

View File

@@ -83,3 +83,23 @@ void Image::overwriteMask(const Color& maskedColor, const Color& insideColor, co
a = writeColor.a();
}
}
void Image::append(const Point& dest, const ImagePtr& other)
{
if(!other)
return;
uint8* otherPixels = other->getPixelData();
for(int p = 0; p < other->getPixelCount(); ++p) {
int x = p % other->getWidth();
int y = p / other->getWidth();
int pos = ((dest.y + y) * m_size.width() + (dest.x + x)) * 4;
if(otherPixels[p*4+3] == 0xFF) {
m_pixels[pos+0] = otherPixels[p*4+0];
m_pixels[pos+1] = otherPixels[p*4+1];
m_pixels[pos+2] = otherPixels[p*4+2];
m_pixels[pos+3] = otherPixels[p*4+3];
}
}
}

View File

@@ -35,6 +35,7 @@ public:
static ImagePtr loadPNG(const std::string& file);
void overwriteMask(const Color& maskedColor, const Color& insideColor = Color::white, const Color& outsideColor = Color::alpha);
void append(const Point& dest, const ImagePtr &other);
std::vector<uint8>& getPixels() { return m_pixels; }
uint8* getPixelData() { return &m_pixels[0]; }
@@ -43,6 +44,7 @@ public:
int getWidth() { return m_size.width(); }
int getHeight() { return m_size.height(); }
int getBpp() { return m_bpp; }
uint8* getPixel(int x, int y) { return &m_pixels[(y * m_size.width() + x) * 4]; }
private:
std::vector<uint8> m_pixels;

View File

@@ -142,6 +142,7 @@ void Texture::generateMipmaps()
//FIXME: disabled because mipmaps size needs to be in base of 2,
// and the current algorithmn does not support that
//generateSoftwareMipmaps(getPixels());
logTraceError("non power of 2.");
}
}