/** * 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. * \param void_dst Pointer at the first pixel of the destination bitmap. * \param dst_slice Size in bytes of a destination bitmap row. * \param void_src Pointer at the first pixel of the source bitmap. * \param src_slice Size in bytes of a source bitmap row. * \param pixel Bytes per pixel of the source and destination bitmap. * \param width Horizontal size in pixels of the source bitmap. * \param height Vertical 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) { unsigned mid_slice; void* mid; mid_slice = 2 * pixel * width; /* required space for 1 row buffer */ mid_slice = (mid_slice + 0x7) & ~0x7; /* align to 8 bytes */ #if HAVE_ALLOCA mid = alloca(6 * mid_slice); /* allocate space for 6 row buffers */ assert(mid != 0); /* alloca should never fails */ #else mid = malloc(6 * mid_slice); /* allocate space for 6 row buffers */ if (!mid) return; #endif scale4x_buf(void_dst, dst_slice, mid, mid_slice, void_src, src_slice, pixel, width, height); #if !HAVE_ALLOCA free(mid); #endif }
/** * 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. * \param void_dst Pointer at the first pixel of the destination bitmap. * \param dst_slice Size in bytes of a destination bitmap row. * \param void_src Pointer at the first pixel of the source bitmap. * \param src_slice Size in bytes of a source bitmap row. * \param pixel Bytes per pixel of the source and destination bitmap. * \param width Horizontal size in pixels of the source bitmap. * \param height Vertical 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) { unsigned mid_slice; void* mid; mid_slice = 2 * pixel * width; /* required space for 1 row buffer */ mid_slice = (mid_slice + 0x7) & ~0x7; /* align to 8 bytes */ mid = alloca(6 * mid_slice); /* allocate space for 6 row buffers */ scale4x_buf(void_dst, dst_slice, mid, mid_slice, void_src, src_slice, pixel, width, height); }