MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / Open

Method Open

src/TextReader.cpp:50–138  ·  view source on GitHub ↗

Open reader

Source from the content-addressed store, hash-verified

48
49// Open reader
50void TextReader::Open()
51{
52 // Open reader if not already open
53 if (!is_open)
54 {
55 // create image
56 image = std::make_shared<Magick::Image>(
57 Magick::Geometry(width,height), Magick::Color(background_color));
58
59 // Give image a transparent background color
60 image->backgroundColor(Magick::Color("none"));
61
62 // Set gravity (map between OpenShot and ImageMagick)
63 switch (gravity)
64 {
65 case GRAVITY_TOP_LEFT:
66 lines.push_back(Magick::DrawableGravity(Magick::NorthWestGravity));
67 break;
68 case GRAVITY_TOP:
69 lines.push_back(Magick::DrawableGravity(Magick::NorthGravity));
70 break;
71 case GRAVITY_TOP_RIGHT:
72 lines.push_back(Magick::DrawableGravity(Magick::NorthEastGravity));
73 break;
74 case GRAVITY_LEFT:
75 lines.push_back(Magick::DrawableGravity(Magick::WestGravity));
76 break;
77 case GRAVITY_CENTER:
78 lines.push_back(Magick::DrawableGravity(Magick::CenterGravity));
79 break;
80 case GRAVITY_RIGHT:
81 lines.push_back(Magick::DrawableGravity(Magick::EastGravity));
82 break;
83 case GRAVITY_BOTTOM_LEFT:
84 lines.push_back(Magick::DrawableGravity(Magick::SouthWestGravity));
85 break;
86 case GRAVITY_BOTTOM:
87 lines.push_back(Magick::DrawableGravity(Magick::SouthGravity));
88 break;
89 case GRAVITY_BOTTOM_RIGHT:
90 lines.push_back(Magick::DrawableGravity(Magick::SouthEastGravity));
91 break;
92 }
93
94 // Set stroke properties
95 lines.push_back(Magick::DrawableStrokeColor(Magick::Color("none")));
96 lines.push_back(Magick::DrawableStrokeWidth(0.0));
97 lines.push_back(Magick::DrawableFillColor(text_color));
98 lines.push_back(Magick::DrawableFont(font));
99 lines.push_back(Magick::DrawablePointSize(size));
100 lines.push_back(Magick::DrawableText(x_offset, y_offset, text));
101
102 if (!text_background_color.empty()) {
103 lines.push_back(Magick::DrawableTextUnderColor(Magick::Color(text_background_color)));
104 }
105
106 // Draw image
107 image->draw(lines);

Callers

nothing calls this directly

Calls 3

ColorClass · 0.85
ToDoubleMethod · 0.80
ReduceMethod · 0.80

Tested by

no test coverage detected