testServer: loading of RGB image

This commit is contained in:
Matej Sekoranja
2014-09-23 13:47:33 +02:00
parent a22fb63af9
commit 45216ff0f0
3 changed files with 34 additions and 8 deletions

View File

@@ -757,8 +757,8 @@ void formatNTNDArray(std::ostream& /*o*/, PVStructurePtr const & pvStruct)
}
else if (cm == 2 && dims == 3)
{
cols = data[0]->getSubField<PVInt>("size")->get();
rows = data[1]->getSubField<PVInt>("size")->get();
cols = data[1]->getSubField<PVInt>("size")->get();
rows = data[2]->getSubField<PVInt>("size")->get();
imageSize = cols * rows * 3;
}
else

View File

@@ -117,21 +117,46 @@ void setNTNDArrayData(
imagePV->getSubField<PVInt>("uniqueId")->put(0);
PVStructureArray::shared_pointer pvAttributes = imagePV->getSubField<PVStructureArray>("attribute");
PVStructureArray::svector attributes(pvAttributes->reuse());
PVStructure::shared_pointer attribute =
getPVDataCreate()->createPVStructure(pvAttributes->getStructureArray()->getStructure());
bool addNew = false;
PVStructure::shared_pointer attribute;
// find ColorMode
for (PVStructureArray::const_svector::const_iterator iter = attributes.begin();
iter != attributes.end();
iter++)
{
PVStructure::shared_pointer fattribute = *iter;
PVString::shared_pointer pvName = fattribute->getSubField<PVString>("name");
if (pvName && pvName->get() == "ColorMode")
{
attribute = fattribute;
break;
}
}
if (!attribute)
{
attribute = getPVDataCreate()->createPVStructure(pvAttributes->getStructureArray()->getStructure());
addNew = true;
}
attribute->getSubField<PVString>("name")->put("ColorMode");
PVInt::shared_pointer pvColorMode = getPVDataCreate()->createPVScalar<PVInt>();
pvColorMode->put(colorMode);
attributes.push_back(attribute);
pvAttributes->replace(freeze(attributes));
if (addNew)
attributes.push_back(attribute);
attribute->getSubField<PVUnion>("value")->set(pvColorMode);
attribute->getSubField<PVString>("descriptor")->put("Color mode");
attribute->getSubField<PVInt>("sourceType")->put(0);
attribute->getSubField<PVString>("source")->put("");
pvAttributes->replace(freeze(attributes));
}
void initImage(

View File

@@ -1475,7 +1475,8 @@ public:
initImage(m_pvStructure, "", 0 /* NDColorModeMono=0 */, 2, dim, fileSize, 0);
}
PVByteArrayPtr value = std::tr1::dynamic_pointer_cast<PVByteArray>(m_pvStructure->getSubField("value"));
PVUnionPtr unionValue = m_pvStructure->getSubField<PVUnion>("value");
PVByteArrayPtr value = unionValue->select<PVByteArray>("byteValue");
PVByteArray::svector temp(value->reuse());
temp.resize(fileSize);
in.readsome((char*)temp.data(), fileSize);