Programming Tips - C/C++: How to double the width and height of an image (without using a library)

Date: 2015aug19 Language: C/C++ Q. C/C++: How to double the width and height of an image (without using a library) A.
// Helper inline void doubleRow(const int *src, int *dest, const int wSrc) { for (int y = 0, y2 = 0; y < wSrc; y++, y2 += 2) { dest[y2] = dest[y2+1] = src[y]; } } // Parameters: // src = from bitmap // dest = to bitmap // wSrc = width of the source (in pixels) // hSrc = height of the source (in pixels) // strideSrc = stride of the source (in pixels) // strideDest = stride of the destination (in pixels) void resizeDouble(const int *src, int *dest, const int wSrc, const int hSrc, const int strideSrc, int const strideDest) { for (int x = 0; x < hSrc; x++) { doubleRow(src, dest, wSrc); dest = &dest[strideDest]; doubleRow(src, dest, wSrc); dest = &dest[strideDest]; src = &src[strideSrc]; } }