Thread: compiling error
View Single Post
Old Nov 2nd, 2006, 3:51 PM   #39
brad sue
Hobbyist Programmer
 
Join Date: Mar 2006
Posts: 120
Rep Power: 3 brad sue is on a distinguished road
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?
brad sue is offline   Reply With Quote