Here's my take on it, although I didn't bother to make it a function or put it in a class or anything. I'm sure the scaling algorithm could be better still...and I think I miss-used the size_t type, but I'm still in the process of learning myself
EDIT: I decided to put it in function form like you did, so I'm replacing the old code with the new code. I'm just not sure it's a good idea to be passing and returning a vector this way...I believe I read that it's more efficient to pass/return an iterator instead.
Code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> Enlarge(const vector<string> &inImage, int scaleFactor)
{
vector<string> outImage;
size_t inWidth = inImage[0].length(); // first string determines width of image
size_t inHeight = inImage.size();
size_t outWidth = inWidth * scaleFactor;
size_t outHeight = inHeight * scaleFactor;
double step = 1.0 / scaleFactor;
for (size_t y = 0; y != outHeight; ++y)
{
string temp;
size_t yIndex = static_cast<size_t>(step * y);
for (size_t x = 0; x != outWidth; ++x)
{
size_t xIndex = static_cast<size_t>(step * x);
temp += inImage[yIndex][xIndex];
}
outImage.push_back(temp);
}
return outImage;
}
int main()
{
char *data[] = {"abc", "def", "ghi"};
size_t dataSize = sizeof(data) / sizeof(char *);
vector<string> image(data, data + dataSize);
vector<string> scaledImage;
scaledImage = Enlarge(image, 3);
// Output both image and scaledImage vectors
copy(image.begin(), image.end(), ostream_iterator<string>(cout, "\n"));
cout << endl;
copy(scaledImage.begin(), scaledImage.end(), ostream_iterator<string>(cout, "\n"));
return 0;
}