diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2012-09-13 20:40:07 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2012-09-13 20:40:07 +0200 |
commit | 87c87c2c06aaea40784ea4de11d4619b54fb8be2 (patch) | |
tree | 765c830e0f43246714a0ff86493a688cf20045e8 /src/common/test/image_test.cpp | |
parent | 34d7dcf3be24de04b2b9c64edb2666439b353a5b (diff) | |
download | colobot-87c87c2c06aaea40784ea4de11d4619b54fb8be2.tar.gz colobot-87c87c2c06aaea40784ea4de11d4619b54fb8be2.tar.bz2 colobot-87c87c2c06aaea40784ea4de11d4619b54fb8be2.zip |
Image pixel read/write
Diffstat (limited to 'src/common/test/image_test.cpp')
-rw-r--r-- | src/common/test/image_test.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp index 0ad1ee2..a98c9cc 100644 --- a/src/common/test/image_test.cpp +++ b/src/common/test/image_test.cpp @@ -22,6 +22,29 @@ int main(int argc, char *argv[]) printf("Error loading '%s': %s\n", err.c_str()); return 1; } + Gfx::Color color; + std::string str; + + color = image.GetPixel(Math::IntPoint(0, 0)); + str = color.ToString(); + printf("pixel @ (0,0): %s\n", str.c_str()); + + color = image.GetPixel(Math::IntPoint(0, 1)); + str = color.ToString(); + printf("pixel @ (0,1): %s\n", str.c_str()); + + color = image.GetPixel(Math::IntPoint(1, 0)); + str = color.ToString(); + printf("pixel @ (1,0): %s\n", str.c_str()); + + color = image.GetPixel(Math::IntPoint(1, 1)); + str = color.ToString(); + printf("pixel @ (1,1): %s\n", str.c_str()); + + image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f)); + image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f)); + image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f)); + image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f)); if (! image.SavePNG(argv[2])) { |