mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
common picture: fix invalid size returns from raw image.
picture/raw should update the size if the raw image with size values are entered.
This commit is contained in:
parent
64b25bb35b
commit
8e2765be39
3 changed files with 6 additions and 4 deletions
|
@ -195,6 +195,8 @@ struct Picture::Impl
|
||||||
if (loader) loader->close();
|
if (loader) loader->close();
|
||||||
loader = LoaderMgr::loader(data, w, h, copy);
|
loader = LoaderMgr::loader(data, w, h, copy);
|
||||||
if (!loader) return Result::NonSupport;
|
if (!loader) return Result::NonSupport;
|
||||||
|
this->w = loader->w;
|
||||||
|
this->h = loader->h;
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,10 +45,10 @@ bool RawLoader::open(const uint32_t* data, uint32_t w, uint32_t h, bool copy)
|
||||||
{
|
{
|
||||||
if (!data || w == 0 || h == 0) return false;
|
if (!data || w == 0 || h == 0) return false;
|
||||||
|
|
||||||
vw = w;
|
this->w = vw = w;
|
||||||
vh = h;
|
this->h = vh = h;
|
||||||
|
|
||||||
this->copy = copy;
|
this->copy = copy;
|
||||||
|
|
||||||
if (copy) {
|
if (copy) {
|
||||||
content = (uint32_t*)malloc(sizeof(uint32_t) * vw * vh);
|
content = (uint32_t*)malloc(sizeof(uint32_t) * vw * vh);
|
||||||
if (!content) return false;
|
if (!content) return false;
|
||||||
|
|
|
@ -63,7 +63,7 @@ TEST_CASE("Load SVG Data", "[tvgPicture]")
|
||||||
REQUIRE(h == Approx(1000).epsilon(0.0000001));
|
REQUIRE(h == Approx(1000).epsilon(0.0000001));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Load Raw Data", "[tvgPicture]")
|
TEST_CASE("Load RAW Data", "[tvgPicture]")
|
||||||
{
|
{
|
||||||
auto picture = Picture::gen();
|
auto picture = Picture::gen();
|
||||||
REQUIRE(picture);
|
REQUIRE(picture);
|
||||||
|
|
Loading…
Add table
Reference in a new issue