You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Add a text background colored box option to the text reader
This commit is contained in:
@@ -45,6 +45,14 @@ TextReader::TextReader(int width, int height, int x_offset, int y_offset, Gravit
|
||||
Close();
|
||||
}
|
||||
|
||||
void TextReader::SetTextBackgroundColor(string color) {
|
||||
text_background_color = color;
|
||||
|
||||
// Open and Close the reader, to populate it's attributes (such as height, width, etc...) plus the text background color
|
||||
Open();
|
||||
Close();
|
||||
}
|
||||
|
||||
// Open reader
|
||||
void TextReader::Open()
|
||||
{
|
||||
@@ -97,6 +105,10 @@ void TextReader::Open()
|
||||
lines.push_back(Magick::DrawablePointSize(size));
|
||||
lines.push_back(Magick::DrawableText(x_offset, y_offset, text));
|
||||
|
||||
if (!text_background_color.empty()) {
|
||||
lines.push_back(Magick::DrawableTextUnderColor(Magick::Color(text_background_color)));
|
||||
}
|
||||
|
||||
// Draw image
|
||||
image->draw(lines);
|
||||
|
||||
@@ -190,6 +202,7 @@ Json::Value TextReader::JsonValue() {
|
||||
root["size"] = size;
|
||||
root["text_color"] = text_color;
|
||||
root["background_color"] = background_color;
|
||||
root["text_background_color"] = text_background_color;
|
||||
root["gravity"] = gravity;
|
||||
|
||||
// return JsonValue
|
||||
@@ -244,6 +257,8 @@ void TextReader::SetJsonValue(Json::Value root) {
|
||||
text_color = root["text_color"].asString();
|
||||
if (!root["background_color"].isNull())
|
||||
background_color = root["background_color"].asString();
|
||||
if (!root["text_background_color"].isNull())
|
||||
text_background_color = root["text_background_color"].asString();
|
||||
if (!root["gravity"].isNull())
|
||||
gravity = (GravityType) root["gravity"].asInt();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user