Skip to content

Instantly share code, notes, and snippets.

@Reputeless
Created October 24, 2014 06:06
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 Reputeless/1d343e2976d59b5e7ff0 to your computer and use it in GitHub Desktop.
Save Reputeless/1d343e2976d59b5e7ff0 to your computer and use it in GitHub Desktop.
# 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