working texturing
This commit is contained in:
parent
0c8748befe
commit
2b71d39a9b
10 changed files with 90 additions and 76 deletions
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
image read(std::string const& uri,uint32_t flags = 0);
|
||||
|
||||
bool write(const std::string& uri,uint32_t flags = 0);
|
||||
bool write(const std::string &uri, const image &img, uint32_t flags = 0);
|
||||
|
||||
~image_io();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ struct image_io::impl
|
|||
|
||||
image read_impl(const std::string& uri,uint32_t flags)
|
||||
{
|
||||
int x,y,n;
|
||||
int x{ 0 }, y{ 0 }, n{ 0 };
|
||||
auto data = stbi_load(uri.c_str(), &x, &y, &n, 4);
|
||||
|
||||
if (data) {
|
||||
|
@ -37,10 +37,14 @@ struct image_io::impl
|
|||
return image();
|
||||
}
|
||||
|
||||
bool write(const std::string& uri, uint32_t flags)
|
||||
bool write(const std::string& uri, const image& img, uint32_t flags)
|
||||
{
|
||||
auto res = stbi_write_png(uri.c_str(),img.size().width,img.size().height,
|
||||
image::components(img.layout()),
|
||||
img.data(),
|
||||
img.size().width * image::components(img.layout()));
|
||||
|
||||
return false;
|
||||
return 0 == res;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -57,9 +61,9 @@ image image_io::read(const std::string &uri, uint32_t flags)
|
|||
return _impl->read_impl(uri,flags);
|
||||
}
|
||||
|
||||
bool image_io::write(const std::string &uri, uint32_t flags)
|
||||
bool image_io::write(const std::string &uri, const image& img, uint32_t flags)
|
||||
{
|
||||
return _impl->write(uri,flags);
|
||||
return _impl->write(uri,img,flags);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue