Mercurial > hg > dmlib
annotate dmscaledblit.h @ 100:f16d102dbbac
Add a function for setting bitmapped font palette.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 20:33:01 +0300 |
parents | 0430f484641b |
children | 79dac918c81e |
rev | line source |
---|---|
0 | 1 /* |
2 * DMLib | |
87 | 3 * -- Scaled sprite / surface blitting function template |
0 | 4 * Programmed and designed by Matti 'ccr' Hamalainen |
5 * (C) Copyright 2011-2012 Tecnic Software productions (TNSP) | |
6 */ | |
7 | |
85 | 8 int DM_BLITFUNC_NAME (SDL_Surface *src, |
0 | 9 const int x0, const int y0, |
10 const int dwidth, const int dheight, | |
16
d9251dd496ce
Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
11 SDL_Surface *dst |
85 | 12 #ifdef DM_BLITFUNC_ARGS |
13 DM_BLITFUNC_ARGS | |
16
d9251dd496ce
Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
14 #endif |
d9251dd496ce
Add new scaled blit template parameters in order to implement global alpha.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
15 ) |
0 | 16 { |
17 int yc; | |
18 DMFixedPoint32 xv, yv, dx, dy; | |
19 DMQValue xr, yr; | |
20 | |
85 | 21 #ifdef DM_BLITFUNC_VARS |
22 DM_BLITFUNC_VARS | |
0 | 23 #endif |
24 | |
25 // Clip coordinates | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
26 if (dmScaledClipCoord(&xr, x0, src->w, dwidth, |
0 | 27 dst->clip_rect.x, dst->clip_rect.x + dst->clip_rect.w) |
28 || | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
29 dmScaledClipCoord(&yr, y0, src->h, dheight, |
0 | 30 dst->clip_rect.y, dst->clip_rect.y + dst->clip_rect.h)) |
31 return -1; | |
32 | |
85 | 33 #ifdef DM_BLITFUNC_INIT |
34 DM_BLITFUNC_INIT | |
0 | 35 #endif |
36 | |
37 // Calculate "final" initial source bitmap offsets | |
38 FP_CONV(dy, yr.voffs); | |
39 FP_MUL_R(yv, dy, yr.vdelta); | |
40 | |
41 FP_CONV(dx, xr.voffs); | |
42 FP_MUL_R(dx, dx, xr.vdelta); | |
43 | |
44 // Take pitch into account | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
45 const int dstadd = xr.vadd - dst->clip_rect.w + dst->clip_rect.x + (dst->pitch / DM_BLITFUNC_DST_BYTES); |
0 | 46 |
47 // Blit scaled | |
85 | 48 DM_BLITFUNC_DST_TYPE * dp = ((DM_BLITFUNC_DST_TYPE *) dst->pixels) + (yr.v0 * dst->pitch) / DM_BLITFUNC_DST_BYTES + xr.v0; |
0 | 49 for (yc = yr.v0; yc < yr.v1; yc++) |
50 { | |
85 | 51 const DM_BLITFUNC_SRC_TYPE * sp = ((DM_BLITFUNC_SRC_TYPE *) src->pixels) + (FP_GETH(yv) * src->pitch) / DM_BLITFUNC_SRC_BYTES; |
0 | 52 int xc; |
53 | |
85 | 54 #ifdef DM_BLITFUNC_INNER_INIT |
87 | 55 DM_BLITFUNC_INNER_INIT |
0 | 56 #endif |
57 | |
58 for (xv.dw = dx.dw, xc = xr.v0; xc < xr.v1; xc++) | |
59 { | |
85 | 60 DM_BLITFUNC_INNER |
0 | 61 FP_ADD(xv, xr.vdelta); |
62 } | |
63 FP_ADD(yv, yr.vdelta); | |
95
0430f484641b
Add unscaled blitting functions.
Matti Hamalainen <ccr@tnsp.org>
parents:
87
diff
changeset
|
64 dp += dstadd; |
0 | 65 } |
66 | |
85 | 67 #ifdef DM_BLITFUNC_FINISH |
68 DM_BLITFUNC_FINISH | |
0 | 69 #endif |
70 | |
71 return 0; | |
72 } | |
73 | |
74 | |
85 | 75 #undef DM_BLITFUNC_NAME |
76 #undef DM_BLITFUNC_ARGS | |
77 #undef DM_BLITFUNC_SRC_BYTES | |
78 #undef DM_BLITFUNC_DST_BYTES | |
79 #undef DM_BLITFUNC_SRC_TYPE | |
80 #undef DM_BLITFUNC_DST_TYPE | |
81 #undef DM_BLITFUNC_VARS | |
82 #undef DM_BLITFUNC_INIT | |
83 #undef DM_BLITFUNC_INNER_INIT | |
84 #undef DM_BLITFUNC_INNER | |
85 #undef DM_BLITFUNC_FINISH |