Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 1613:1ec254a7c645
drawing texts on image from plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Sep 2015 17:12:25 +0200 |
parents | 96582230ddcb |
children | c40fe92a68e7 |
comparison
equal
deleted
inserted
replaced
1612:96582230ddcb | 1613:1ec254a7c645 |
---|---|
1180 | 1180 |
1181 *(p.target) = reinterpret_cast<OrthancPluginImage*>(target.release()); | 1181 *(p.target) = reinterpret_cast<OrthancPluginImage*>(target.release()); |
1182 } | 1182 } |
1183 | 1183 |
1184 | 1184 |
1185 | |
1186 void OrthancPlugins::GetFontInfo(const void* parameters) | |
1187 { | |
1188 const _OrthancPluginGetFontInfo& p = *reinterpret_cast<const _OrthancPluginGetFontInfo*>(parameters); | |
1189 | |
1190 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex); | |
1191 | |
1192 if (p.name != NULL) | |
1193 { | |
1194 *(p.name) = font.GetName().c_str(); | |
1195 } | |
1196 else if (p.size != NULL) | |
1197 { | |
1198 *(p.size) = font.GetSize(); | |
1199 } | |
1200 else | |
1201 { | |
1202 throw OrthancException(ErrorCode_InternalError); | |
1203 } | |
1204 } | |
1205 | |
1206 | |
1207 void OrthancPlugins::DrawText(const void* parameters) | |
1208 { | |
1209 const _OrthancPluginDrawText& p = *reinterpret_cast<const _OrthancPluginDrawText*>(parameters); | |
1210 | |
1211 ImageAccessor& target = *reinterpret_cast<ImageAccessor*>(p.image); | |
1212 const Font& font = Configuration::GetFontRegistry().GetFont(p.fontIndex); | |
1213 | |
1214 font.Draw(target, p.utf8Text, p.x, p.y, p.r, p.g, p.b); | |
1215 } | |
1216 | |
1217 | |
1185 bool OrthancPlugins::InvokeService(_OrthancPluginService service, | 1218 bool OrthancPlugins::InvokeService(_OrthancPluginService service, |
1186 const void* parameters) | 1219 const void* parameters) |
1187 { | 1220 { |
1188 VLOG(1) << "Calling plugin service: " << service; | 1221 VLOG(1) << "Calling plugin service: " << service; |
1189 | 1222 |
1567 | 1600 |
1568 case _OrthancPluginService_ConvertPixelFormat: | 1601 case _OrthancPluginService_ConvertPixelFormat: |
1569 ConvertPixelFormat(parameters); | 1602 ConvertPixelFormat(parameters); |
1570 return true; | 1603 return true; |
1571 | 1604 |
1605 case _OrthancPluginService_GetFontsCount: | |
1606 { | |
1607 const _OrthancPluginReturnSingleValue& p = | |
1608 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(parameters); | |
1609 *(p.resultUint32) = Configuration::GetFontRegistry().GetSize(); | |
1610 return true; | |
1611 } | |
1612 | |
1613 case _OrthancPluginService_GetFontInfo: | |
1614 GetFontInfo(parameters); | |
1615 return true; | |
1616 | |
1617 case _OrthancPluginService_DrawText: | |
1618 DrawText(parameters); | |
1619 return true; | |
1620 | |
1572 default: | 1621 default: |
1573 { | 1622 { |
1574 // This service is unknown to the Orthanc plugin engine | 1623 // This service is unknown to the Orthanc plugin engine |
1575 return false; | 1624 return false; |
1576 } | 1625 } |