Last active
August 24, 2016 03:32
-
-
Save voidproc/21c445757ea33e5d1d2350fd72731fe0 to your computer and use it in GitHub Desktop.
Draw embedded Base64 image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Siv3D.hpp> | |
//#define ENCODE_IMAGES | |
String encodeFile(const FilePath& filepath) | |
{ | |
return Base64::Encode(BinaryReader(filepath).readWhole()); | |
} | |
void Main() | |
{ | |
#ifdef ENCODE_IMAGES | |
TextWriter writer(L"encodedImages.txt"); | |
for (auto& file : Array<String>{ L"1.png", L"2.png", L"3.png" }) | |
if (FileSystem::Exists(file)) | |
writer.writeln(encodeFile(file)); | |
return; | |
#endif | |
// Base64 でエンコードされた PNG 画像 | |
const String encodedImage = L"iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgAgMAAADf85YXAAAACVBMVEXf/+8kSwCfv399yLhfAAAAnUlEQVQoz7XRQQrCUAwE0Al0BHddmPsETzCFfOhxFDyCB/b/Fu2v3eosH9lMBod42SUxYpfhl+ABWFINrMxASqBzaOACoFEYyFMFK40agmQFCnr24GFJzB3ACpGQYoWsYOENvAOGdM0FxEgLi8+FXGCYKrADbHCp4OiBQumB97DEbYO1S0jTYy0HVMIklXf9cxHgoVwe9JcZjmN/5wXZ+S43N2BYQwAAAABJRU5ErkJggg=="; | |
const Texture texture(Base64::Decode(encodedImage)); | |
Window::Resize(768, 512); | |
Graphics2D::SetSamplerState(SamplerState::ClampPoint); | |
while (System::Update()) | |
{ | |
for (int i : step(5)) | |
{ | |
for (int j : step(3)) | |
{ | |
texture.scale(4).draw(j * 256, (i-1) * 128 + System::FrameCount() % 128); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment