summaryrefslogtreecommitdiff
path: root/FrameRender/P_Image.c
blob: b95bbd702fe25081d5a923d452fb03e167781e4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "P_Image.h"
#include "PixelCallback.h"
#include <stdlib.h>
#include <string.h>

void Image_callback(Image* self, struct PixelContext* fc) {
	if (0 <= fc->x && fc->x < self->img.width * self->scale &&
	    0 <= fc->y && fc->y < self->img.height * self->scale)
	{
		ARGB_mergeARGB(&fc->pixel, *RGBImage_at(self->img, fc->y / self->scale, fc->x / self->scale));
	}
}

PixelCallback* Image_setup(Image obj) {
	PixelCallback* pca = malloc(sizeof(struct PixelCallback));

	pca->callback = (PixelCallback_callback)Image_callback;
	pca->callback_self = malloc(sizeof(obj));
	memcpy(pca->callback_self, &obj, sizeof(obj));

	return pca;
}