Skip to content

Instantly share code, notes, and snippets.

@voidproc
Last active August 24, 2016 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voidproc/21c445757ea33e5d1d2350fd72731fe0 to your computer and use it in GitHub Desktop.
Save voidproc/21c445757ea33e5d1d2350fd72731fe0 to your computer and use it in GitHub Desktop.
Draw embedded Base64 image
#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