mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
examples: fix wrong data size conversion.
pointer size becomes 32 to 64 bits up to machines. it has to be 32 bits.
This commit is contained in:
parent
2bd07c050c
commit
6fce96a124
2 changed files with 6 additions and 10 deletions
|
@ -27,8 +27,6 @@
|
||||||
/* Drawing Commands */
|
/* Drawing Commands */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
uint32_t *data = nullptr;
|
|
||||||
|
|
||||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
{
|
{
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
|
@ -87,8 +85,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
//Image
|
//Image
|
||||||
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw");
|
ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw");
|
||||||
if (!file.is_open()) return;
|
if (!file.is_open()) return;
|
||||||
data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
auto data = (uint32_t*) malloc(sizeof(uint32_t) * (200 * 300));
|
||||||
file.read(reinterpret_cast<char *>(data), sizeof (data) * 200 * 300);
|
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
auto image = tvg::Picture::gen();
|
auto image = tvg::Picture::gen();
|
||||||
|
@ -111,6 +109,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
mask4->fill(255, 255, 255, 70);
|
mask4->fill(255, 255, 255, 70);
|
||||||
image->composite(move(mask4), tvg::CompositeMethod::AlphaMask);
|
image->composite(move(mask4), tvg::CompositeMethod::AlphaMask);
|
||||||
if (canvas->push(move(image)) != tvg::Result::Success) return;
|
if (canvas->push(move(image)) != tvg::Result::Success) return;
|
||||||
|
|
||||||
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,8 +214,6 @@ int main(int argc, char **argv)
|
||||||
//Terminate ThorVG Engine
|
//Terminate ThorVG Engine
|
||||||
tvg::Initializer::term(tvg::CanvasEngine::Sw);
|
tvg::Initializer::term(tvg::CanvasEngine::Sw);
|
||||||
|
|
||||||
if (data) free(data);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
cout << "engine is not supported" << endl;
|
cout << "engine is not supported" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
/* Drawing Commands */
|
/* Drawing Commands */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
uint32_t *data = nullptr;
|
|
||||||
|
|
||||||
void tvgDrawCmds(tvg::Canvas* canvas)
|
void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
{
|
{
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
|
@ -44,8 +42,8 @@ void tvgDrawCmds(tvg::Canvas* canvas)
|
||||||
|
|
||||||
ifstream file(path);
|
ifstream file(path);
|
||||||
if (!file.is_open()) return ;
|
if (!file.is_open()) return ;
|
||||||
data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300));
|
auto data = (uint32_t*)malloc(sizeof(uint32_t) * (200*300));
|
||||||
file.read(reinterpret_cast<char *>(data), sizeof (data) * 200 * 300);
|
file.read(reinterpret_cast<char *>(data), sizeof (uint32_t) * 200 * 300);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
auto picture = tvg::Picture::gen();
|
auto picture = tvg::Picture::gen();
|
||||||
|
|
Loading…
Add table
Reference in a new issue