mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
example: refactoring
This commit is contained in:
parent
702f452c6c
commit
cfacdd705f
2 changed files with 7 additions and 13 deletions
|
@ -5,8 +5,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;
|
||||||
|
@ -219,8 +217,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;
|
||||||
|
@ -87,13 +85,15 @@ 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 (uint32_t) * 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();
|
||||||
if (image->load(data, 200, 300, true) != tvg::Result::Success) return;
|
if (image->load(data, 200, 300, true) != tvg::Result::Success) return;
|
||||||
image->translate(500, 400);
|
image->translate(500, 400);
|
||||||
|
free(data);
|
||||||
|
|
||||||
|
|
||||||
//Mask4
|
//Mask4
|
||||||
auto mask4 = tvg::Shape::gen();
|
auto mask4 = tvg::Shape::gen();
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue