void AnimatedImageComponent::load(const AnimationDef* def) { mFrames.clear(); assert(def->frameCount >= 1); for(size_t i = 0; i < def->frameCount; i++) { if(def->frames[i].path != NULL && !ResourceManager::getInstance()->fileExists(def->frames[i].path)) { LOG(LogError) << "Missing animation frame " << i << " (\"" << def->frames[i].path << "\")"; continue; } auto img = std::unique_ptr<ImageComponent>(new ImageComponent(mWindow)); img->setResize(mSize.x(), mSize.y()); img->setImage(std::string(def->frames[i].path), false); mFrames.push_back(ImageFrame(std::move(img), def->frames[i].time)); } mLoop = def->loop; mCurrentFrame = 0; mFrameAccumulator = 0; mEnabled = true; }
std::shared_ptr<Perevod::ImageFrame> ImageSocketTCPImpl::parse_frame(const unsigned char *data, size_t *offset) { uint32_t x, y; std::memcpy(&x, data + *offset, sizeof(uint32_t)); *offset += sizeof(uint32_t); std::memcpy(&y, data + *offset, sizeof(uint32_t)); *offset += sizeof(uint32_t); uint32_t width, height; std::memcpy(&width, data + *offset, sizeof(uint32_t)); *offset += sizeof(uint32_t); std::memcpy(&height, data + *offset, sizeof(uint32_t)); *offset += sizeof(uint32_t); PEREVOD_DEBUG_LOG("received : " + x + ", " + y + ", " + width + ", " + height); uint32_t data_size; std::memcpy(&data_size, data + *offset, sizeof(uint32_t)); PEREVOD_DEBUG_LOG("received data size : " + data_size); *offset += sizeof(uint32_t); unsigned char *image_data = (unsigned char *)data + *offset; *offset += data_size; return std::make_shared<Perevod::ImageFrame>(ImageFrame(x, y, width, height, image_data, data_size)); }
ImageFrame KinectComp::GetImage() { if (mpKinect == NULL) { PrintMessage(DEBUG_MESSAGE("Can't get a handle of Kinect API").c_str()); return ImageFrame(0, 0); } ImageFrame image; if (mpKinect->GetImage(image) != API_SUCCESS) { PrintMessage(DEBUG_MESSAGE("Can't get image").c_str()); image.width = 0; image.height = 0; image.data = NULL; } return image; }