WIC と QT のエンコード機能の間のパフォーマンスをテストしようとしています。しかし、WIC を使用して QImage (QT オブジェクト) から PNG にエンコードする方法が見つかりません。
WIC のエンコーダーは、画像ファイルと同じデータを提供する 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();