mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
apis: remove a beta api.
- const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const Returning pixel data is not guaranteed as the picture may contain vector resources. Remove it unless it's absolutely necessary. @Issue: https://github.com/thorvg/thorvg/issues/1372
This commit is contained in:
parent
9af89f9f18
commit
c0cb8c0ce8
4 changed files with 18 additions and 29 deletions
11
inc/thorvg.h
11
inc/thorvg.h
|
@ -1307,17 +1307,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Result size(float* w, float* h) const noexcept;
|
Result size(float* w, float* h) const noexcept;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Gets the pixels information of the picture.
|
|
||||||
*
|
|
||||||
* @note The data must be pre-multiplied by the alpha channels.
|
|
||||||
*
|
|
||||||
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
||||||
*
|
|
||||||
* @BETA_API
|
|
||||||
*/
|
|
||||||
const uint32_t* data(uint32_t* w, uint32_t* h) const noexcept;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Loads a raw data from a memory block with a given size.
|
* @brief Loads a raw data from a memory block with a given size.
|
||||||
*
|
*
|
||||||
|
|
|
@ -97,23 +97,6 @@ Result Picture::size(float* w, float* h) const noexcept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const noexcept
|
|
||||||
{
|
|
||||||
//Try it, If not loaded yet.
|
|
||||||
pImpl->load();
|
|
||||||
|
|
||||||
if (pImpl->loader) {
|
|
||||||
if (w) *w = static_cast<uint32_t>(pImpl->loader->w);
|
|
||||||
if (h) *h = static_cast<uint32_t>(pImpl->loader->h);
|
|
||||||
} else {
|
|
||||||
if (w) *w = 0;
|
|
||||||
if (h) *h = 0;
|
|
||||||
}
|
|
||||||
if (pImpl->surface) return pImpl->surface->buf32;
|
|
||||||
else return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Result Picture::mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept
|
Result Picture::mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept
|
||||||
{
|
{
|
||||||
if (!triangles && triangleCnt > 0) return Result::InvalidArguments;
|
if (!triangles && triangleCnt > 0) return Result::InvalidArguments;
|
||||||
|
|
|
@ -318,6 +318,22 @@ struct Picture::Impl
|
||||||
load();
|
load();
|
||||||
return new PictureIterator(paint);
|
return new PictureIterator(paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t* data(uint32_t* w, uint32_t* h)
|
||||||
|
{
|
||||||
|
//Try it, If not loaded yet.
|
||||||
|
load();
|
||||||
|
|
||||||
|
if (loader) {
|
||||||
|
if (w) *w = static_cast<uint32_t>(loader->w);
|
||||||
|
if (h) *h = static_cast<uint32_t>(loader->h);
|
||||||
|
} else {
|
||||||
|
if (w) *w = 0;
|
||||||
|
if (h) *h = 0;
|
||||||
|
}
|
||||||
|
if (surface) return surface->buf32;
|
||||||
|
else return nullptr;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_TVG_PICTURE_IMPL_H_
|
#endif //_TVG_PICTURE_IMPL_H_
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "tvgTvgSaver.h"
|
#include "tvgTvgSaver.h"
|
||||||
#include "tvgLzw.h"
|
#include "tvgLzw.h"
|
||||||
#include "tvgShapeImpl.h"
|
#include "tvgShapeImpl.h"
|
||||||
|
#include "tvgPictureImpl.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
@ -607,7 +608,7 @@ TvgBinCounter TvgSaver::serializePicture(const Picture* picture, const Matrix* p
|
||||||
|
|
||||||
//Case - Bitmap Image:
|
//Case - Bitmap Image:
|
||||||
uint32_t w, h;
|
uint32_t w, h;
|
||||||
auto pixels = picture->data(&w, &h);
|
auto pixels = P(picture)->data(&w, &h);
|
||||||
if (!pixels) return 0;
|
if (!pixels) return 0;
|
||||||
|
|
||||||
writeTag(TVG_TAG_CLASS_PICTURE);
|
writeTag(TVG_TAG_CLASS_PICTURE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue