6 #include <doocs/EqData.h>
9 #include <ChimeraTK/MappedImage.h>
18 const std::string& path,
const std::string& registerPathName,
size_t numberOfBytes,
size_t wordOffsetInRegister,
19 AccessModeFlags flags)
21 std::move(backend), path, registerPathName, numberOfBytes, wordOffsetInRegister, std::move(flags)) {
25 throw ChimeraTK::logic_error(std::string(
"DOOCS data type ") +
27 " not supported by DoocsBackendImageRegisterAccessor.");
29 if(wordOffsetInRegister > 0) {
30 throw ChimeraTK::logic_error(
31 "DoocsBackendImageRegisterAccessor does not support nonzero offset, register:" + registerPathName);
45 if(!hasNewData)
return;
57 auto sharedThis = boost::static_pointer_cast<NDRegisterAccessor<uint8_t>>(this->shared_from_this());
58 OneDRegisterAccessor<uint8_t> abstractAcc(sharedThis);
68 switch(h->image_format) {
69 case TTF2_IMAGE_FORMAT_GRAY:
71 return ImgFormat::Gray8;
73 else if(h->bpp == 2) {
74 return ImgFormat::Gray16;
77 return ImgFormat::Unset;
79 case TTF2_IMAGE_FORMAT_RGB:
80 return ImgFormat::RGB24;
81 case TTF2_IMAGE_FORMAT_RGBA:
82 return ImgFormat::RGBA32;
84 return ImgFormat::Unset;
90 if(imgFormat == ImgFormat::Unset) {
91 throw logic_error(
"MappedDoocsImgIn: unsupported image input");
95 unsigned useLines = h->height;
96 unsigned bytesPerLine = h->width * h->bpp;
97 if(lengthForShape(h->width, h->height, imgFormat) > capacity()) {
99 useLines = (capacity() -
sizeof(ImgHeader)) / bytesPerLine;
101 setShape(h->width, useLines, imgFormat);
103 auto* hOut = this->header();
104 hOut->effBitsPerPixel = h->ebitpp;
105 hOut->frame = h->frame;
106 hOut->x_start = h->x_start;
107 hOut->y_start = h->y_start;
108 hOut->scale_x = h->scale_x;
109 hOut->scale_y = h->scale_y;
111 memcpy(imgBody(), body, useLines * bytesPerLine);
113 memset(imgBody() + useLines * bytesPerLine, 0, capacity() -
sizeof(ImgHeader) - useLines * bytesPerLine);