summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-10-16 23:41:43 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-10-16 23:41:43 +0300
commit162619a426c9af15ac4868c9c7ce882f9932db38 (patch)
tree15887d14f9868a23ace02ba9e3bf7a529bd2699b /src/tile.cpp
parent2419d0029ac36952aaa74b685d529a3592adb6aa (diff)
downloadminetest-162619a426c9af15ac4868c9c7ce882f9932db38.tar.gz
minetest-162619a426c9af15ac4868c9c7ce882f9932db38.tar.bz2
minetest-162619a426c9af15ac4868c9c7ce882f9932db38.zip
Fix to-transparend conversion of backgrounds of sprite image files that don't have an alpha channel
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 4e441329a..e274d2d3e 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -1092,22 +1092,23 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
core::dimension2d<u32> dim = image->getDimension();
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
+ // Blit
+ image->copyTo(baseimg);
+
+ image->drop();
+
for(u32 y=0; y<dim.Height; y++)
for(u32 x=0; x<dim.Width; x++)
{
- video::SColor c = image->getPixel(x,y);
+ video::SColor c = baseimg->getPixel(x,y);
u32 r = c.getRed();
u32 g = c.getGreen();
u32 b = c.getBlue();
if(!(r == r1 && g == g1 && b == b1))
continue;
c.setAlpha(0);
- image->setPixel(x,y,c);
+ baseimg->setPixel(x,y,c);
}
- // Blit
- image->copyTo(baseimg);
-
- image->drop();
}
}
/*
@@ -1149,11 +1150,16 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
{
core::dimension2d<u32> dim = image->getDimension();
baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
+
+ // Blit
+ image->copyTo(baseimg);
+
+ image->drop();
for(u32 y=0; y<dim.Height; y++)
for(u32 x=0; x<dim.Width; x++)
{
- video::SColor c = image->getPixel(x,y);
+ video::SColor c = baseimg->getPixel(x,y);
u32 r = c.getRed();
u32 g = c.getGreen();
u32 b = c.getBlue();
@@ -1161,12 +1167,8 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg,
!(r == r2 && g == g2 && b == b2))
continue;
c.setAlpha(0);
- image->setPixel(x,y,c);
+ baseimg->setPixel(x,y,c);
}
- // Blit
- image->copyTo(baseimg);
-
- image->drop();
}
}
/*