使用WIC将QImage编码为png
Encode QImage to png using WIC?
我正在尝试测试WIC和QT的编码函数之间的性能。但我找不到一种使用WIC将QImage(QT对象)编码为PNG的方法。
WIC的编码器需要从IStream初始化,IStream应该提供与图像文件相同的数据。但我有点像位图。
有人能帮我吗?如有任何意见,我们将不胜感激。
这很容易做到。我不知道如何使用编码器。IWICBitmapFrameEncode.WritePixels
是我应该放置原始像素的位置:
factory = CreateComObject(CLSID_WICImagingFactory);
IWICBitmapEncoder pngEncoder = factory.CreateEncoder(GUID_ContainerFormatPng, null);
pngEncoder.Initialize(targetStream, WICBitmapEncoderNoCache);
IPropertyBag2 propertyBag;
IWICBitmapFrameEncode frame = pngEncoder.CreateNewFrame(ref propertyBag);
frame.Initialize(propertyBag);
//Set the size of the image
frame.SetSize(640, 480);
//Request the encoder use this format.
Guid format = GUID_WICPixelFormat32bppPBGRA;
//If the encoder doesn't support that format, it will set format to the closest it does support
frame.SetPixelFormat(ref format);
//if the frame encoder doesn't support the pixel format we want to give it
//then we just cannot proceed
Assert(format == GUID_WICPixelFormat32bppPBGRA);
frame.WritePixels(
lineCount,
stride,
bufferSize,
pointerToPixelData);
frame.Commit();
pngEncoder.Commit();
相关文章:
- 如何确定我已使用非编码文件到达 EOF?
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 在卡萨布兰卡形成编码参数的列表
- 在CToolBar对象中使用PNG时出现问题
- 使用C++进行游程编码
- 如何将不同的可执行文件合并到一个窗口框架中进行编码?像浏览器一样
- 使用已使用 java 编码的 openssl 解码数据
- boost 是否有按特殊类型值编码状态"compact optional"?
- 如何在CPP的给定目录中列出UTF编码的文件名?
- 如何使用 C++将 ISO-2022-KR 编码转换为 UTF-8 编码?
- 从存储为 Windows 资源 (c++) 的 png 中获取 png 文件数据
- 绝对编码器十六进制输入
- 使用 stbi_write_png,如何将 0 和 1 的矩形字节数组转换为单色 png 文件?
- 防止C++中的硬编码数字
- 将C++ std::string 转换为 UTF-16-LE 编码的字符串
- 使用文件内容作为硬编码字符串
- 运行长度编码程序 c++ 的问题
- 以C++为单位进行运行长度编码
- 使用WIC将QImage编码为png
- 使用libpng快速编码位图缓冲区到PNG