Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning
Last active December 11, 2015 06:30
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 ChunChunMorning/63933cb4eb39159b6a26 to your computer and use it in GitHub Desktop.
Save ChunChunMorning/63933cb4eb39159b6a26 to your computer and use it in GitHub Desktop.
Siv3Dで画像連結ソフトを作る
# include <Siv3D.hpp>
Image createImage(const Array<Image>& images)
{
int width = 0;
int height = 0;
for (const auto& image : images)
{
width += image.width;
height = Max<unsigned>(height, image.height);
}
return Image(width, height);
}
void overwriteImages(Image& output, const Array<Image>& images)
{
int pos = 0;
for (const auto& image : images)
{
image.overwrite(output, { pos, 0 });
pos += image.width;
}
}
void Main()
{
Image output;
Array<Image> images;
Texture texture(output);
while (System::Update())
{
ClearPrint();
Println(images.size());
if (Dragdrop::HasItems())
{
const Array<FilePath> filePaths = Dragdrop::GetFilePaths();
for (const auto& filePath : filePaths)
{
Image image(filePath);
if (!image.isEmpty)
{
images.push_back(image);
}
}
output = createImage(images);
overwriteImages(output, images);
texture = Texture(output);
}
if (Input::KeyEnter.clicked)
{
output.save(L"Image/output.png");
System::ExploreFolder(L"Image");
}
texture.draw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment