mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
#pragma once
|
|
#include "pch.h"
|
|
#include "EffectRendererBase.h"
|
|
|
|
|
|
class WICBitmapEffectRenderer : public EffectRendererBase {
|
|
public:
|
|
WICBitmapEffectRenderer(
|
|
D2DContext& d2dContext,
|
|
const std::wstring_view& effectsJson,
|
|
const SIZE& srcSize,
|
|
const RECT& hostClient
|
|
): EffectRendererBase(d2dContext, effectsJson, srcSize, hostClient) {
|
|
assert(srcSize.cx > 0 && srcSize.cy > 0);
|
|
|
|
Debug::ThrowIfComFailed(
|
|
d2dContext.GetD2DDC()->CreateEffect(CLSID_D2D1BitmapSource, &_d2dSourceEffect),
|
|
L"´´½¨ D2D1BitmapSource ʧ°Ü"
|
|
);
|
|
_outputEffect = _d2dSourceEffect;
|
|
|
|
_Init(effectsJson, srcSize);
|
|
}
|
|
|
|
void SetInput(ComPtr<IUnknown> inputImg) override {
|
|
ComPtr<IWICBitmapSource> wicBitmap;
|
|
Debug::ThrowIfComFailed(
|
|
inputImg.As<IWICBitmapSource>(&wicBitmap),
|
|
L"»ñÈ¡ÊäÈëͼÏñʧ°Ü"
|
|
);
|
|
|
|
Debug::ThrowIfComFailed(
|
|
_d2dSourceEffect->SetValue(D2D1_BITMAPSOURCE_PROP_WIC_BITMAP_SOURCE, wicBitmap.Get()),
|
|
L"ÉèÖà D2D1BitmapSource Դʧ°Ü"
|
|
);
|
|
}
|
|
|
|
protected:
|
|
void _PushAsOutputEffect(ComPtr<ID2D1Effect> effect) override {
|
|
effect->SetInputEffect(0, _outputEffect.Get());
|
|
_outputEffect = effect;
|
|
}
|
|
|
|
ComPtr<ID2D1Image> _GetOutputImg() override {
|
|
ComPtr<ID2D1Image> outputImg = nullptr;
|
|
_outputEffect->GetOutput(&outputImg);
|
|
|
|
return outputImg;
|
|
}
|
|
|
|
private:
|
|
ComPtr<ID2D1Effect> _d2dSourceEffect = nullptr;
|
|
ComPtr<ID2D1Effect> _outputEffect = nullptr;
|
|
};
|