I tried to change my constructor but it fails.Then I tried this
void Screen::shrink(int reduc)
{
if((reduc<height)&&(reduc<width))
{
int newrow,newcol;
newrow=height/reduc;
newcol=width/reduc;
char *newpixels=new char[newrow*newcol];
//iterate the old block line by line
for ( int i = 0; i < newrow; i++)
{
memcpy( newpixels + (i*newcol), pixels + (i*width), newcol); //copy only the required amount of data
}
//delete the old data
delete []pixels;
pixels = newpixels;
}
} I dont see my mistake but it does not work. My problem is that I still fail to keep track of the old data and save them in newpixels.
See where I am wrong in my code?