本文整理汇总了C++中FlexImage::getPixelCode方法的典型用法代码示例。如果您正苦于以下问题:C++ FlexImage::getPixelCode方法的具体用法?C++ FlexImage::getPixelCode怎么用?C++ FlexImage::getPixelCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexImage
的用法示例。
在下文中一共展示了FlexImage::getPixelCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
bool DepthImageConverter::accept(yarp::os::Things& thing)
{
FlexImage* img = thing.cast_as< FlexImage >();
if(img == NULL) {
printf("DepthImageConverter: expected type FlexImage but got wrong data type!\n");
return false;
}
if( img->getPixelCode() == VOCAB_PIXEL_MONO_FLOAT)
{
return true;
}
printf("DepthImageConverter: expected %s, got %s, not doing any convertion!\n", yarp::os::Vocab::decode(VOCAB_PIXEL_MONO_FLOAT).c_str(), yarp::os::Vocab::decode(img->getPixelCode()).c_str() );
return false;
}
示例2: read
bool Image::read(yarp::os::ConnectionReader& connection) {
// auto-convert text mode interaction
connection.convertTextMode();
ImageNetworkHeader header;
bool ok = connection.expectBlock((char*)&header,sizeof(header));
if (!ok) return false;
imgPixelCode = header.id;
int q = getQuantum();
if (q==0) {
//q = YARP_IMAGE_ALIGN;
setQuantum(header.quantum);
q = getQuantum();
}
if (q!=header.quantum) {
if ((header.depth*header.width)%header.quantum==0 &&
(header.depth*header.width)%q==0) {
header.quantum = q;
}
}
if (getPixelCode()!=header.id||q!=header.quantum) {
// we're trying to read an incompatible image type
// rather than just fail, we'll read it (inefficiently)
FlexImage flex;
flex.setPixelCode(header.id);
flex.setQuantum(header.quantum);
flex.resize(header.width,header.height);
if (header.width!=0&&header.height!=0) {
unsigned char *mem = flex.getRawImage();
yAssert(mem!=NULL);
if (flex.getRawImageSize()!=header.imgSize) {
printf("There is a problem reading an image\n");
printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
(int)header.width, (int)header.height,
(int)header.id,
(int)header.quantum, (int)header.imgSize);
printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
flex.width(), flex.height(), flex.getPixelCode(),
flex.getQuantum(),
flex.getRawImageSize());
}
yAssert(flex.getRawImageSize()==header.imgSize);
ok = connection.expectBlock((char *)flex.getRawImage(),
flex.getRawImageSize());
if (!ok) return false;
}
copy(flex);
} else {
yAssert(getPixelCode()==header.id);
resize(header.width,header.height);
unsigned char *mem = getRawImage();
if (header.width!=0&&header.height!=0) {
yAssert(mem!=NULL);
if (getRawImageSize()!=header.imgSize) {
printf("There is a problem reading an image\n");
printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
(int)header.width, (int)header.height,
(int)header.id,
(int)header.quantum, (int)header.imgSize);
printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
width(), height(), getPixelCode(), getQuantum(), getRawImageSize());
}
yAssert(getRawImageSize()==header.imgSize);
ok = connection.expectBlock((char *)getRawImage(),
getRawImageSize());
if (!ok) return false;
}
}
return !connection.isError();
}