d2dlib icon indicating copy to clipboard operation
d2dlib copied to clipboard

Effects

Open kennetherland opened this issue 3 years ago • 2 comments

Got it working if you are interested:

#include "stdafx.h"
#include "Effect.h"
#include "d2d1effects.h"
#include "d2d1_1.h";

HANDLE CreateEffect(HANDLE ctx, REFCLSID effect)
{
	RetrieveContext(ctx);

	ID2D1HwndRenderTarget* renderTarget = (ID2D1HwndRenderTarget*) context->renderTarget;
	ID2D1Effect* compositeEffect;
	ID2D1DeviceContext* deviceContext;
	HRESULT hr;

	hr = renderTarget->QueryInterface(&deviceContext);

	hr = deviceContext->CreateEffect(effect, &compositeEffect);

	return (HANDLE)compositeEffect;
}

void SetInput(HANDLE d2dEffect, INT index, HANDLE d2dbitmap, BOOL invalidate)
{
	ID2D1Effect* effect = reinterpret_cast<ID2D1Effect*>(d2dEffect);
	ID2D1Bitmap* bitmap = reinterpret_cast<ID2D1Bitmap*>(d2dbitmap);

	effect->SetInput(index, bitmap, invalidate);
}

kennetherland avatar Nov 14 '21 00:11 kennetherland

@kennetherland Thanks so much! It would be great if you could consider making a PR for this.

#60

jingwood avatar Nov 28 '21 12:11 jingwood