mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-26 16:16:46 +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;
|
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()
|
bool PngLoader::read()
|
||||||
{
|
{
|
||||||
png_bytep buffer;
|
png_bytep buffer;
|
||||||
|
|
|
@ -28,18 +28,20 @@
|
||||||
class PngLoader : public Loader
|
class PngLoader : public Loader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
png_imagep image = nullptr;
|
|
||||||
const uint32_t* content = nullptr;
|
|
||||||
|
|
||||||
PngLoader();
|
PngLoader();
|
||||||
~PngLoader();
|
~PngLoader();
|
||||||
|
|
||||||
using Loader::open;
|
using Loader::open;
|
||||||
bool open(const string& path) override;
|
bool open(const string& path) override;
|
||||||
|
bool open(const char* data, uint32_t size, bool copy) override;
|
||||||
bool read() override;
|
bool read() override;
|
||||||
bool close() override;
|
bool close() override;
|
||||||
|
|
||||||
const uint32_t* pixels() 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