Last active
December 11, 2015 06:30
-
-
Save ChunChunMorning/63933cb4eb39159b6a26 to your computer and use it in GitHub Desktop.
Siv3Dで画像連結ソフトを作る
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> | |
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