about summary refs log tree commit diff stats
path: root/lunatic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lunatic.cpp')
-rw-r--r--lunatic.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/lunatic.cpp b/lunatic.cpp index 291bd09..58a0854 100644 --- a/lunatic.cpp +++ b/lunatic.cpp
@@ -65,9 +65,6 @@ int main(int argc, char** argv)
65 std::cout << "Generating tweet" << std::endl; 65 std::cout << "Generating tweet" << std::endl;
66 66
67 achievement ach = db.getRandomAchievement(); 67 achievement ach = db.getRandomAchievement();
68 std::string imageName = db.getRandomImageForGame(ach.gameId);
69 std::string imagePath = config["images"].as<std::string>()
70 + "/" + imageName;
71 68
72 Magick::Image moonColor; 69 Magick::Image moonColor;
73 moonColor.read("res/" + ach.color + ".png"); 70 moonColor.read("res/" + ach.color + ".png");
@@ -150,14 +147,25 @@ int main(int argc, char** argv)
150 shadow.negate(); 147 shadow.negate();
151 shadow.blur(0, 12); 148 shadow.blur(0, 12);
152 149
153 // Read the game image 150 // Read the game image, using a default if the game has no images
154 Magick::Image image; 151 Magick::Image image;
155 image.read(imagePath);
156 152
157 // Stretch and pixelate it 153 if (db.doesGameHaveImages(ach.gameId))
158 image.transform("1600x900!"); 154 {
159 image.scale("80x45"); 155 std::string imageName = db.getRandomImageForGame(ach.gameId);
160 image.scale("1600x900"); 156 std::string imagePath = config["images"].as<std::string>()
157 + "/" + imageName;
158
159 image.read(imagePath);
160
161 // Stretch and pixelate it
162 image.transform("1600x900!");
163 image.scale("80x45");
164 image.scale("1600x900");
165 } else {
166 image.read("res/default.png");
167 image.transform("1600x900!");
168 }
161 169
162 // Add the generated overlay to it 170 // Add the generated overlay to it
163 image.composite(shadow, 0, 0, Magick::OverCompositeOp); 171 image.composite(shadow, 0, 0, Magick::OverCompositeOp);