Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning ChunChunMorning/Main.cpp
Last active Dec 11, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.