Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/CairoTextRenderer.cpp @ 804:61ba4b504e9a
PolylineSceneLayer now has one color per chain
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 28 May 2019 15:58:21 +0200 |
parents | 9e51fb773bbd |
children | 6e888cf6a48b |
comparison
equal
deleted
inserted
replaced
802:f38c1fc08655 | 804:61ba4b504e9a |
---|---|
46 { | 46 { |
47 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 47 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
48 } | 48 } |
49 | 49 |
50 const unsigned int width = source->GetWidth(); | 50 const unsigned int width = source->GetWidth(); |
51 const unsigned int red = layer.GetRed(); | 51 const Color& color = layer.GetColor(); |
52 const unsigned int green = layer.GetGreen(); | |
53 const unsigned int blue = layer.GetBlue(); | |
54 | 52 |
55 for (unsigned int y = 0; y < source->GetHeight(); y++) | 53 for (unsigned int y = 0; y < source->GetHeight(); y++) |
56 { | 54 { |
57 const uint8_t* p = reinterpret_cast<const uint8_t*>(source->GetConstRow(y)); | 55 const uint8_t* p = reinterpret_cast<const uint8_t*>(source->GetConstRow(y)); |
58 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | 56 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
60 for (unsigned int x = 0; x < width; x++) | 58 for (unsigned int x = 0; x < width; x++) |
61 { | 59 { |
62 unsigned int alpha = *p; | 60 unsigned int alpha = *p; |
63 | 61 |
64 // Premultiplied alpha | 62 // Premultiplied alpha |
65 q[0] = static_cast<uint8_t>((blue * alpha) / 255); | 63 q[0] = static_cast<uint8_t>((color.GetBlue() * alpha) / 255); |
66 q[1] = static_cast<uint8_t>((green * alpha) / 255); | 64 q[1] = static_cast<uint8_t>((color.GetGreen() * alpha) / 255); |
67 q[2] = static_cast<uint8_t>((red * alpha) / 255); | 65 q[2] = static_cast<uint8_t>((color.GetRed() * alpha) / 255); |
68 q[3] = *p; | 66 q[3] = *p; |
69 | 67 |
70 p++; | 68 p++; |
71 q += 4; | 69 q += 4; |
72 } | 70 } |
83 text_.GetHeight() != 0) | 81 text_.GetHeight() != 0) |
84 { | 82 { |
85 const TextSceneLayer& layer = GetLayer<TextSceneLayer>(); | 83 const TextSceneLayer& layer = GetLayer<TextSceneLayer>(); |
86 | 84 |
87 cairo_t* cr = GetCairoContext(); | 85 cairo_t* cr = GetCairoContext(); |
88 cairo_set_source_rgb(cr, layer.GetRedAsFloat(), layer.GetGreenAsFloat(), layer.GetBlueAsFloat()); | 86 cairo_set_source_rgb(cr, layer.GetColor().GetRedAsFloat(), |
87 layer.GetColor().GetGreenAsFloat(), | |
88 layer.GetColor().GetBlueAsFloat()); | |
89 | 89 |
90 double dx, dy; // In pixels | 90 double dx, dy; // In pixels |
91 ComputeAnchorTranslation(dx, dy, layer.GetAnchor(), text_.GetWidth(), | 91 ComputeAnchorTranslation(dx, dy, layer.GetAnchor(), text_.GetWidth(), |
92 text_.GetHeight(), layer.GetBorder()); | 92 text_.GetHeight(), layer.GetBorder()); |
93 | 93 |