aboutsummaryrefslogtreecommitdiff
path: root/Plugins/fs2vf.c
blob: efd479a9c5b09bda1f6af4ce31bc212b09ab83e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// fs2vf.c
// put image data to vframe
//
// 1st argument is name of shared memory
// to struct vframeimage (see Patches\vframe.h)
//

#include <memory.h>
#include "plugin.h"
#include "sharemem.h"
#include "vframe.h"

void perform_effect(_frame f, _args a)
{
	HANDLE hlvframe=NULL, hl=NULL;
	LPVOID p=NULL;
	struct vframeimage *vfp=NULL;
	unsigned long c;

	if(!a.s) return;

	vfp = (struct vframeimage *)smopen(&hlvframe, a.s);
	if(vfp==NULL) return;

//	printf("name %s width %d height %d pf %d bits %s\n",
//	 a.s, vfp->f.width, vfp->f.height, vfp->f.pixelformat, vfp->bitsname);

	if(f.pixelformat != vfp->f.pixelformat)
	{
		printf("fs2vf: pixelformats are different. no resampling available.\n");
		return;
	}

	p = smopen(&hl, vfp->bitsname);
	if(p==NULL)
	{
		CloseHandle(hlvframe);
		return;
	}

	c = (f.height*f.lpitch < vfp->f.height*vfp->f.lpitch) ?
	 f.height*f.lpitch : vfp->f.height*vfp->f.lpitch;

	memcpy(p, f.bits, c);

	smfree(&hl, p);
	smfree(&hlvframe, vfp);
}