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:
Hermet Park 2023-08-01 11:04:52 +09:00
parent 9af89f9f18
commit c0cb8c0ce8
4 changed files with 18 additions and 29 deletions

View file

@ -1307,17 +1307,6 @@ public:
*/
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.
*

View file

@ -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
{
if (!triangles && triangleCnt > 0) return Result::InvalidArguments;

View file

@ -318,6 +318,22 @@ struct Picture::Impl
load();
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_

View file

@ -26,6 +26,7 @@
#include "tvgTvgSaver.h"
#include "tvgLzw.h"
#include "tvgShapeImpl.h"
#include "tvgPictureImpl.h"
#ifdef _WIN32
#include <malloc.h>
@ -607,7 +608,7 @@ TvgBinCounter TvgSaver::serializePicture(const Picture* picture, const Matrix* p
//Case - Bitmap Image:
uint32_t w, h;
auto pixels = picture->data(&w, &h);
auto pixels = P(picture)->data(&w, &h);
if (!pixels) return 0;
writeTag(TVG_TAG_CLASS_PICTURE);