File: graph_copy_bright.c

package info (click to toggle)
xsystem35 1.7.3-pre5-8
  • links: PTS
  • area: main
  • in suites:
  • size: 7,372 kB
  • sloc: ansic: 51,007; sh: 12,049; asm: 863; makefile: 412; xml: 281; perl: 142
file content (78 lines) | stat: -rw-r--r-- 1,611 bytes parent folder | download | duplicates (4)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// surfaceΰ뤵 lv/255 ܤƥԡ

#include <string.h>

#include "portab.h"
#include "surface.h"
#include "ngraph.h"
#include "ags.h"

void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) {
	int x, y;
	BYTE *sp, *dp;
	
	if (!gr_clip(src, &sx, &sy, &width, &height, dst, &dx, &dy)) return;
	
	sp = GETOFFSET_PIXEL(src, sx, sy);
	dp = GETOFFSET_PIXEL(dst, dx, dy);
	
	if (sp == NULL || dp == NULL) return;
	
	switch(dst->depth) {
	case 15:
	{
		WORD *yls, *yld;
		
		for (y = 0; y < height; y++) {
			yls = (WORD *)(sp + y * src->bytes_per_line);
			yld = (WORD *)(dp + y * dst->bytes_per_line);
			
			for (x = 0; x < width; x++) {
				*yld = ALPHALEVEL15(*yls, lv);
				yls++; yld++;
			}
		}
		break;
	}
	case 16:
		if (nact->mmx_is_ok) {
//		if (0) {
#ifdef ENABLE_MMX
			int alpha;
			lv = 255 - lv;
			alpha = lv | lv << 8 | lv << 16 | lv << 24;
			ablend16_dpd(dp, 0, sp, alpha, width, height, dst->bytes_per_line, src->bytes_per_line);
#endif
		} else {
			WORD *yls, *yld;
			
			for (y = 0; y < height; y++) {
				yls = (WORD *)(sp + y * src->bytes_per_line);
				yld = (WORD *)(dp + y * dst->bytes_per_line);
				
				for (x = 0; x < width; x++) {
					*yld = ALPHALEVEL16(*yls, lv);
					yls++; yld++;
				}
			}
		}
		break;
	case 24:
	case 32:
	{
		DWORD *yls, *yld;
		
		for (y = 0; y < height; y++) {
			yls = (DWORD *)(sp + y * src->bytes_per_line);
			yld = (DWORD *)(dp + y * dst->bytes_per_line);
			
			for (x = 0; x < width; x++) {
				*yld = ALPHALEVEL24(*yls, lv);
				yls++; yld++;
			}
		}
		break;
	}
	}
}