DGen/SDL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
scalebit.c File Reference
#include "scale2x.h"
#include "scale3x.h"
#include <assert.h>
#include <stdlib.h>

Macros

#define SSDST(bits, num)   (scale2x_uint##bits *)dst##num
#define SSSRC(bits, num)   (const scale2x_uint##bits *)src##num
#define SCDST(i)   (dst+(i)*dst_slice)
#define SCSRC(i)   (src+(i)*src_slice)
#define SCMID(i)   (mid[(i)])

Functions

static void stage_scale2x (void *dst0, void *dst1, const void *src0, const void *src1, const void *src2, unsigned pixel, unsigned pixel_per_row)
 Apply the Scale2x effect on a group of rows.
static void stage_scale2x3 (void *dst0, void *dst1, void *dst2, const void *src0, const void *src1, const void *src2, unsigned pixel, unsigned pixel_per_row)
 Apply the Scale2x3 effect on a group of rows.
static void stage_scale2x4 (void *dst0, void *dst1, void *dst2, void *dst3, const void *src0, const void *src1, const void *src2, unsigned pixel, unsigned pixel_per_row)
 Apply the Scale2x4 effect on a group of rows.
static void stage_scale3x (void *dst0, void *dst1, void *dst2, const void *src0, const void *src1, const void *src2, unsigned pixel, unsigned pixel_per_row)
 Apply the Scale3x effect on a group of rows.
static void stage_scale4x (void *dst0, void *dst1, void *dst2, void *dst3, const void *src0, const void *src1, const void *src2, const void *src3, unsigned pixel, unsigned pixel_per_row)
 Apply the Scale4x effect on a group of rows.
static void scale2x (void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale2x effect on a bitmap.
static void scale2x3 (void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale2x3 effect on a bitmap.
static void scale2x4 (void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale2x4 effect on a bitmap.
static void scale3x (void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale3x effect on a bitmap.
static void scale4x_buf (void *void_dst, unsigned dst_slice, void *void_mid, unsigned mid_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale4x effect on a bitmap.
static void scale4x (void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale4x effect on a bitmap.
int scale_precondition (unsigned scale, unsigned pixel, unsigned width, unsigned height)
 Check if the scale implementation is applicable at the given arguments.
void scale (unsigned scale, void *void_dst, unsigned dst_slice, const void *void_src, unsigned src_slice, unsigned pixel, unsigned width, unsigned height)
 Apply the Scale effect on a bitmap.

Macro Definition Documentation

#define SCDST (   i)    (dst+(i)*dst_slice)
#define SCMID (   i)    (mid[(i)])
#define SCSRC (   i)    (src+(i)*src_slice)
#define SSDST (   bits,
  num 
)    (scale2x_uint##bits *)dst##num
#define SSSRC (   bits,
  num 
)    (const scale2x_uint##bits *)src##num

Function Documentation

void scale ( unsigned  scale,
void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)

Apply the Scale effect on a bitmap.

This function is simply a common interface for scale2x(), scale3x() and scale4x().

Parameters:
scaleScale factor. 2, 203 (fox 2x3), 204 (for 2x4), 3 or 4.
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale2x ( void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale2x effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 2x2 times the size of the source bitmap.

Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale2x3 ( void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale2x3 effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 2x3 times the size of the source bitmap.

Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale2x4 ( void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale2x4 effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 2x4 times the size of the source bitmap.

Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale3x ( void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale3x effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 3x3 times the size of the source bitmap.

Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale4x ( void *  void_dst,
unsigned  dst_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale4x effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 4x4 times the size of the source bitmap.

Note:
This function operates like scale4x_buf() but the intermediate buffer is automatically allocated in the stack.
Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
static void scale4x_buf ( void *  void_dst,
unsigned  dst_slice,
void *  void_mid,
unsigned  mid_slice,
const void *  void_src,
unsigned  src_slice,
unsigned  pixel,
unsigned  width,
unsigned  height 
)
static

Apply the Scale4x effect on a bitmap.

The destination bitmap is filled with the scaled version of the source bitmap. The source bitmap isn't modified. The destination bitmap must be manually allocated before calling the function, note that the resulting size is exactly 4x4 times the size of the source bitmap.

Note:
This function requires also a small buffer bitmap used internally to store intermediate results. This bitmap must have at least an horizontal size in bytes of 2*width*pixel, and a vertical size of 6 rows. The memory of this buffer must not be allocated in video memory because it's also read and not only written. Generally a heap (malloc) or a stack (alloca) buffer is the best choice.
Parameters:
void_dstPointer at the first pixel of the destination bitmap.
dst_sliceSize in bytes of a destination bitmap row.
void_midPointer at the first pixel of the buffer bitmap.
mid_sliceSize in bytes of a buffer bitmap row.
void_srcPointer at the first pixel of the source bitmap.
src_sliceSize in bytes of a source bitmap row.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
int scale_precondition ( unsigned  scale,
unsigned  pixel,
unsigned  width,
unsigned  height 
)

Check if the scale implementation is applicable at the given arguments.

Parameters:
scaleScale factor. 2, 203 (fox 2x3), 204 (for 2x4), 3 or 4.
pixelBytes per pixel of the source and destination bitmap.
widthHorizontal size in pixels of the source bitmap.
heightVertical size in pixels of the source bitmap.
Returns:
  • -1 on precondition violated.
  • 0 on success.
static void stage_scale2x ( void *  dst0,
void *  dst1,
const void *  src0,
const void *  src1,
const void *  src2,
unsigned  pixel,
unsigned  pixel_per_row 
)
inlinestatic

Apply the Scale2x effect on a group of rows.

Used internally.

static void stage_scale2x3 ( void *  dst0,
void *  dst1,
void *  dst2,
const void *  src0,
const void *  src1,
const void *  src2,
unsigned  pixel,
unsigned  pixel_per_row 
)
inlinestatic

Apply the Scale2x3 effect on a group of rows.

Used internally.

static void stage_scale2x4 ( void *  dst0,
void *  dst1,
void *  dst2,
void *  dst3,
const void *  src0,
const void *  src1,
const void *  src2,
unsigned  pixel,
unsigned  pixel_per_row 
)
inlinestatic

Apply the Scale2x4 effect on a group of rows.

Used internally.

static void stage_scale3x ( void *  dst0,
void *  dst1,
void *  dst2,
const void *  src0,
const void *  src1,
const void *  src2,
unsigned  pixel,
unsigned  pixel_per_row 
)
inlinestatic

Apply the Scale3x effect on a group of rows.

Used internally.

static void stage_scale4x ( void *  dst0,
void *  dst1,
void *  dst2,
void *  dst3,
const void *  src0,
const void *  src1,
const void *  src2,
const void *  src3,
unsigned  pixel,
unsigned  pixel_per_row 
)
inlinestatic

Apply the Scale4x effect on a group of rows.

Used internally.