Mirai's Miscellaneous Misadventures
M53 / core / images.c
1
2
3
4#include "../mimimi.h"
5
6void mimimi_stamp(struct mimimi_image *target, int x1, int y1,
7 struct mimimi_image *source)
8{
9 int x, y;
10 int x0, y0;
11 int x2, y2;
12 int width, height;
13 unsigned char color;
14
15 x0 = 0;
16 y0 = 0;
17
18 if (x1 < 0)
19 x0 = -x1;
20 if (y1 < 0)
21 y0 = -y1;
22
23 width = source->width;
24 height = source->height;
25
26 if (width + x1 > target->width)
27 width = target->width - x1;
28 if (height + y1 > target->height)
29 height = target->height - y1;
30
31 for (y = y0; y < height; y++) {
32 for (x = x0; x < width; x++) {
33 color = source->colors[x + y * source->width];
34 if (color == 0)
35 continue;
36 x2 = x + x1;
37 y2 = y + y1;
38 target->colors[x2 + y2 * target->width] = color;
39 }
40 }
41}