/*
width: is the new width
height: is the new height to resize to
array: the array to resize
curWidth: the current width of the array
*/
void Resize(int width, int height, vector<double> &array, int curWidth)
{
int curHeight = 0;
int difWidth = 0;
int difHeight = 0;
//if the width of the array is not a multiple of the passed width
//abort
if (array.size() % curWidth > 0) return;
//compute the current height
curHeight = int(array.size()) / curWidth;
//compute the differences
difWidth = width - curWidth;
difHeight = height - curHeight;
//abort if I am supposed to shrink the size
if (difWidth < 0) return;
if (difHeight < 0) return;
//resize the width
if (difWidth > 0)
{
int paddingL = 0;
int paddingR = 0;
//compute the padding for the size
paddingL = difWidth / 2;
paddingR = difWidth - paddingL;
//insert the padding
for (int y = 0; y < curHeight; y++)
{
vector<double>::iterator i(&array[y * curWidth]);
//pad the left side
array.insert(i, paddingL, array[0]);
//pad the right side
array.insert(i + paddingL, paddingR, array[(curWidth-1)+paddingL]);
}
}
//resize the height
if (difHeight > 0)
{
int paddingT = 0;
int paddingB = 0;
int y = 0;
//compute the padding for the size
paddingT = difHeight / 2;
paddingB = difHeight - paddingT;
//insert the padding on top
for (y = 0; y < paddingT; y++)
{
vector<double>::iterator i(&array[y * width]);
for (int x = 0; x < width; x++)
{
array.insert(i + x, *(i + 2 * x));
}
}
/*****************************************************/
//this is were the error is occurring
//pad the bottom
cout << "\nDEBUG: curHeight=" << (curHeight+paddingT) << "\n\n";
int row = (curHeight+paddingT) - 1;
row *= width;
/*for (y = height - paddingB; y < height; y++)
{
for (int x = 0; x < width; x++)
{
array.push_back(array[row + x]);
}
}*/
}
}
This is the error I get:
[edited by - bcome on November 7, 2003 9:43:24 PM]
[edited by - bcome on November 7, 2003 9:45:37 PM]
[edited by - bcome on November 7, 2003 9:47:02 PM]
[edited by - bcome on November 8, 2003 1:16:30 AM]
My program won't output to the screen.
The code:
It only seems to do that when when I try to double the size of the arrays height.
u r what u bcome
u r what u bcome
It seems your error doesn''t output to the boards.
(Ie, it displays a red x of not-foundness.)
(Ie, it displays a red x of not-foundness.)
It looks like you wrote past the end of an array somewhere. I''m too lazy to look at your code and tell you where the problem is, though.
quote:Original post by smart_idiot
It looks like you wrote past the end of an array somewhere. I'm too lazy to look at your code and tell you where the problem is, though.
Not nececisarally smart, I am using a vector.
quote:Original post by RuneLancer
It seems your error doesn't output to the boards.
(Ie, it displays a red x of not-foundness.)
Wierd, it was working earilier? EDIT: I probably saw the cache.
[edited by - bcome on November 8, 2003 1:17:19 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement