本文整理汇总了C++中DynamicArray::data方法的典型用法代码示例。如果您正苦于以下问题:C++ DynamicArray::data方法的具体用法?C++ DynamicArray::data怎么用?C++ DynamicArray::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicArray
的用法示例。
在下文中一共展示了DynamicArray::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storeImage
void storeImage(const FilePath& filename, DynamicArray<unsigned char> data,
unsigned int width, unsigned int height)
{
constexpr int CHANNEL_COUNT = 3;
OutFileStream file(filename.c_str(), OutFileStream::binary);
if (!file.is_open())
throw InvalidArgumentException("Cannot open output file: " + filename.toString());
// Image is vertically flipped
DynamicArray<unsigned char> data_flip(data.size());
const unsigned int line_size = width * CHANNEL_COUNT;
// Vertically flip lines
for (unsigned int i = 0; i < height; ++i)
{
std::memcpy(
data_flip.data() + i * line_size,
data.data() + (height - i - 1) * line_size,
line_size
);
}
// Write function
stbi_write_func* func = [] (void* context, void* data, int size) {
reinterpret_cast<OutFileStream*>(context)->write(reinterpret_cast<const char*>(data), size);
};
// Copy data
if (!stbi_write_png_to_func(func, &file, width, height, CHANNEL_COUNT, data_flip.data(), 0))
throw RuntimeException("Unable to write a picture");
}
示例2: handle_write
void UDPServer::handle_write(boost::asio::ip::udp::endpoint ep, DynamicArray<char> arr, const boost::system::error_code& error, size_t bytes_transferred) {
if (error == boost::system::errc::success) {
this->OnSend(ep, arr.data(), bytes_transferred);
}
}
示例3: handle_read
void UDPServer::handle_read(boost::asio::ip::udp::endpoint* ep, DynamicArray<char> arr, const boost::system::error_code& error, size_t bytes_transferred) {
this->start_read();
if (error == boost::system::errc::success) {
/* A message has been succesfully received, call any handlers. */
this->OnReceive(*ep, arr.data(), bytes_transferred);
}
}
示例4: async_send
void UDPServer::async_send(boost::asio::ip::udp::endpoint& ep, DynamicArray<char>& arr) {
this->getUDPSocket().async_send_to(boost::asio::buffer(arr.data(), arr.size()), ep,
std::bind(&UDPServer::handle_write, this, ep, arr, std::placeholders::_1, std::placeholders::_2));
}