1 /*
2 * OpenBOR - http://www.chronocrash.com
3 * -----------------------------------------------------------------------
4 * All rights reserved, see LICENSE in OpenBOR root for details.
5 *
6 * Copyright (c) 2004 - 2012 OpenBOR Team
7 */
8
9 /**
10 * Scales images by 2x using nearest neighbor filtering. Replaces the old
11 * "Simple 2x" filter used in OpenBOR before October 2012, which was licensed
12 * under the GPL.
13 */
14
15 #include "gfx.h"
16 #include "types.h"
17
Simple2x(u8 * srcPtr,u32 srcPitch,u8 * deltaPtr,u8 * dstPtr,u32 dstPitch,int width,int height)18 void Simple2x(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height)
19 {
20 u16 *srcPixels;
21 u16 *dstTop, *dstBottom;
22 int x, y;
23
24 for (y = 0; y < height; y++)
25 {
26 srcPixels = (u16 *)(srcPtr + y * srcPitch);
27 dstTop = (u16 *)dstPtr;
28 dstBottom = (u16 *)(dstPtr + dstPitch);
29 for(x = 0; x < width; x++)
30 {
31 *dstTop++ = *srcPixels;
32 *dstTop++ = *srcPixels;
33 *dstBottom++ = *srcPixels;
34 *dstBottom++ = *srcPixels;
35 srcPixels++;
36 }
37 dstPtr += dstPitch << 1;
38 }
39 }
40
Simple2x32(u8 * srcPtr,u32 srcPitch,u8 * deltaPtr,u8 * dstPtr,u32 dstPitch,int width,int height)41 void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height)
42 {
43 u32 *srcPixels;
44 u32 *dstTop, *dstBottom;
45 int x, y;
46
47 for (y = 0; y < height; y++)
48 {
49 srcPixels = (u32 *)(srcPtr + y * srcPitch);
50 dstTop = (u32 *)dstPtr;
51 dstBottom = (u32 *)(dstPtr + dstPitch);
52 for(x = 0; x < width; x++)
53 {
54 *dstTop++ = *srcPixels;
55 *dstTop++ = *srcPixels;
56 *dstBottom++ = *srcPixels;
57 *dstBottom++ = *srcPixels;
58 srcPixels++;
59 }
60 dstPtr += dstPitch << 1;
61 }
62 }
63
64