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:
Hermet Park 2021-07-03 16:09:56 +09:00 committed by Hermet Park
parent 64b25bb35b
commit 8e2765be39
3 changed files with 6 additions and 4 deletions

View file

@ -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;
} }

View file

@ -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;

View file

@ -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);