-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadImage.cpp
More file actions
38 lines (33 loc) · 994 Bytes
/
loadImage.cpp
File metadata and controls
38 lines (33 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <ImageIO/loadImage.h>
#include <ImageIO/loadJpeg.h>
#include <ImageIO/loadPng.h>
#include <stdexcept>
namespace ImageIO_NS
{
using ::imageview::PixelFormatGrayscale8;
using ::imageview::PixelFormatRGB24;
std::unique_ptr<IBitmap<PixelFormatGrayscale8>> loadImageGrayscale8(const std::filesystem::path& path)
{
if (path.extension() == ".png")
{
return loadPngGrayscale8(path);
}
if (path.extension() == ".jpg" or path.extension() == ".jpeg")
{
return loadJpegGrayscale8(path);
}
throw std::runtime_error("Unknown filename extension: " + path.string());
}
std::unique_ptr<IBitmap<PixelFormatRGB24>> loadImageRGB24(const std::filesystem::path& path)
{
if (path.extension() == ".png")
{
return loadPngRGB24(path);
}
if (path.extension() == ".jpg" or path.extension() == ".jpeg")
{
return loadJpegRGB24(path);
}
throw std::runtime_error("Unknown filename extension: " + path.string());
}
}