mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-25 23:59:12 +00:00
png_loader: added open from memory
Added PngLoader::open(const char* data, uint32_t size, bool copy) Changed variables visibility to private
This commit is contained in:
parent
1507438ecc
commit
1e1f232016
2 changed files with 19 additions and 5 deletions
|
@ -51,6 +51,18 @@ bool PngLoader::open(const string& path)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool PngLoader::open(const char* data, uint32_t size, bool copy)
|
||||
{
|
||||
image->opaque = NULL;
|
||||
|
||||
if (!png_image_begin_read_from_memory(image, data, size)) return false;
|
||||
|
||||
vw = w = image->width;
|
||||
vh = h = image->height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PngLoader::read()
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
@ -76,4 +88,4 @@ bool PngLoader::close()
|
|||
const uint32_t* PngLoader::pixels()
|
||||
{
|
||||
return this->content;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,18 +28,20 @@
|
|||
class PngLoader : public Loader
|
||||
{
|
||||
public:
|
||||
png_imagep image = nullptr;
|
||||
const uint32_t* content = nullptr;
|
||||
|
||||
PngLoader();
|
||||
~PngLoader();
|
||||
|
||||
using Loader::open;
|
||||
bool open(const string& path) override;
|
||||
bool open(const char* data, uint32_t size, bool copy) override;
|
||||
bool read() override;
|
||||
bool close() override;
|
||||
|
||||
const uint32_t* pixels() override;
|
||||
|
||||
private:
|
||||
png_imagep image = nullptr;
|
||||
const uint32_t* content = nullptr;
|
||||
};
|
||||
|
||||
#endif //_TVG_PNG_LOADER_H_
|
||||
#endif //_TVG_PNG_LOADER_H_
|
||||
|
|
Loading…
Add table
Reference in a new issue