1 Star 0 Fork 1

defeng2020/wdf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pasteboard_client_adapter_impl.cpp 1.90 KB
一键复制 编辑 原始数据 按行查看 历史
defeng2020 提交于 2023-02-04 19:40 +08:00 . add pasteboard_client_adapter_impl.cpp.
bool PasteDataRecordAdapterImpl::SetImgData(std::shared_ptr<ClipBoardImageData> imageData)
{
WVLOG_E("wdfv7 SetImgData");
if (imageData == nullptr) {
WVLOG_E("imageData is null");
return false;
}
// Media::InitializationOptions opts;
// opts.size.width = imageData->width;
// opts.size.height = imageData->height;
// opts.pixelFormat = ClipboardToImageColorType(imageData->colorType);
// // opts.alphaType = ClipboardToImageAlphaType(imageData->alphaType);
// opts.alphaType = Media::AlphaType::IMAGE_ALPHA_TYPE_PREMUL;;
// // info.colorSpace = Media::ColorSpace::SRGB;
// WVLOG_E("wdfv6 SetImgData %{public}d %{public}d",opts.pixelFormat, opts.alphaType);
// std::unique_ptr<Media::PixelMap> pixelMap =
// Media::PixelMap::Create(imageData->data, static_cast<uint32_t>(imageData->dataSize), opts);
// if (pixelMap == nullptr) {
// WVLOG_E("create pixel map failed");
// return false;
// }
Media::InitializationOptions opt;
opt.size.width = imageData->width;
opt.size.height = imageData->height;
opt.pixelFormat = ClipboardToImageColorType(imageData->colorType);
opt.alphaType = ClipboardToImageAlphaType(imageData->alphaType);
opt.editable = true;
std::unique_ptr<Media::PixelMap> pixelMap = Media::PixelMap::Create(opt);
if (pixelMap == nullptr) {
return false;
}
// uint8_t *data = static_cast<uint8_t *>(imageData->data);
uint64_t stride = static_cast<uint64_t>(imageData->width) << 2;
uint64_t bufferSize = stride * static_cast<uint64_t>(imageData->height);
pixelMap->WritePixels(reinterpret_cast<const uint8_t *>(imageData->data), bufferSize);
std::shared_ptr<Media::PixelMap> pixelMapIn = move(pixelMap);
if (!builder_) {
return false;
}
record_ = builder_->SetPixelMap(pixelMapIn).Build();
return true;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/defeng2020/wdf.git
git@gitee.com:defeng2020/wdf.git
defeng2020
wdf
wdf
master

搜索帮助