-
-
Save Reputeless/1d343e2976d59b5e7ff0 to your computer and use it in GitHub Desktop.
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> | |
ImageFormat GetFormatFromFileName(const FilePath& fileName) | |
{ | |
const String extension = FileSystem::Extension(fileName); | |
if (extension == L"dds") | |
{ | |
return ImageFormat::DDS; | |
} | |
else if (extension == L"png") | |
{ | |
return ImageFormat::PNG; | |
} | |
else if (extension == L"jpg" || extension == L"jpeg") | |
{ | |
return ImageFormat::JPEG; | |
} | |
else if (extension == L"jp2") | |
{ | |
return ImageFormat::JPEG2000; | |
} | |
else if (extension == L"bmp") | |
{ | |
return ImageFormat::BMP; | |
} | |
else if (extension == L"webp") | |
{ | |
return ImageFormat::WebP; | |
} | |
else if (extension == L"gif") | |
{ | |
return ImageFormat::GIF; | |
} | |
else if (extension == L"tif" || extension == L"tiff") | |
{ | |
return ImageFormat::TIFF; | |
} | |
else if (extension == L"tga") | |
{ | |
return ImageFormat::TGA; | |
} | |
else if (extension == L"ppm") | |
{ | |
return ImageFormat::PPM; | |
} | |
return ImageFormat::Unknown; | |
} | |
void Main() | |
{ | |
if (GetFormatFromFileName(L"test.abc") == ImageFormat::Unknown) | |
{ | |
Println(L"無効な拡張子"); | |
} | |
WaitKey(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment