本文整理汇总了C++中safe_ptr::image_data方法的典型用法代码示例。如果您正苦于以下问题:C++ safe_ptr::image_data方法的具体用法?C++ safe_ptr::image_data怎么用?C++ safe_ptr::image_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_ptr
的用法示例。
在下文中一共展示了safe_ptr::image_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
virtual boost::unique_future<bool> send(const safe_ptr<core::read_frame>& frame) override
{
CASPAR_VERIFY(format_desc_.height * format_desc_.width * 4 == static_cast<unsigned>(frame->image_data().size()));
return executor_.begin_invoke([=]() -> bool
{
graph_->set_value("tick-time", tick_timer_.elapsed() * format_desc_.fps * 0.5);
tick_timer_.restart();
frame_timer_.restart();
// AUDIO
std::vector<int16_t, tbb::cache_aligned_allocator<int16_t>> audio_buffer;
if (core::needs_rearranging(
frame->multichannel_view(),
channel_layout_,
channel_layout_.num_channels))
{
core::audio_buffer downmixed;
downmixed.resize(
frame->multichannel_view().num_samples()
* channel_layout_.num_channels,
0);
auto dest_view = core::make_multichannel_view<int32_t>(
downmixed.begin(), downmixed.end(), channel_layout_);
core::rearrange_or_rearrange_and_mix(
frame->multichannel_view(),
dest_view,
core::default_mix_config_repository());
audio_buffer = core::audio_32_to_16(downmixed);
}
else
{
audio_buffer = core::audio_32_to_16(frame->audio_data());
}
airsend::add_audio(air_send_.get(), audio_buffer.data(), audio_buffer.size() / channel_layout_.num_channels);
// VIDEO
connected_ = airsend::add_frame_bgra(air_send_.get(), frame->image_data().begin());
graph_->set_text(print());
graph_->set_value("frame-time", frame_timer_.elapsed() * format_desc_.fps * 0.5);
return true;
});
}
示例2: send
virtual bool send(const safe_ptr<core::read_frame>& frame) override
{
auto format_desc = format_desc_;
boost::thread async([format_desc, frame]
{
try
{
auto filename = narrow(env::data_folder()) + boost::posix_time::to_iso_string(boost::posix_time::second_clock::local_time()) + ".png";
auto bitmap = std::shared_ptr<FIBITMAP>(FreeImage_Allocate(format_desc.width, format_desc.height, 32), FreeImage_Unload);
memcpy(FreeImage_GetBits(bitmap.get()), frame->image_data().begin(), frame->image_size());
FreeImage_FlipVertical(bitmap.get());
FreeImage_Save(FIF_PNG, bitmap.get(), filename.c_str(), 0);
}
catch(...)
{
CASPAR_LOG_CURRENT_EXCEPTION();
}
});
async.detach();
return false;
}