-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale2xrows.h
36 lines (30 loc) · 1.16 KB
/
scale2xrows.h
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
/* this function feeds all rows of the bitmap to the row processing function */
static void SCALE2XFUNC(SDL_Surface* src, SDL_Surface* dest, int x, int y)
{
PIXEL* srcpix = src->pixels;
PIXEL* destpix = dest->pixels;
int srcpitch = src->pitch / sizeof(PIXEL);
int destpitch = dest->pitch / sizeof(PIXEL);
int w = src->w, h = src->h;
PIXEL *dest0, *dest1, *src0, *src1, *src2;
/* set up destination line pointers */
dest0 = destpix + y*destpitch + x;
dest1 = dest0 + destpitch;
/* set up source line pointers */
/* since there's no line above, we reuse this first line */
src0 = src1 = srcpix; src2 = srcpix + srcpitch;
/* all but the last row */
for (h--; h > 0; h--) {
SCALE2XROWFUNC(dest0, dest1, src0, src1, src2, w);
/* move both destination line pointers down 2 rows */
dest0 = dest1 + destpitch;
dest1 = dest0 + destpitch;
/* shift all source lines down */
src0 = src1;
src1 = src2;
src2 += srcpitch;
}
/* last row - since there is no line below, we reuse this last line */
SCALE2XROWFUNC(dest0, dest1, src0, src1, src1, w);
return;
}