Thread: compiling error
View Single Post
Old Nov 3rd, 2006, 8:43 AM   #46
brad sue
Hobbyist Programmer
 
Join Date: Mar 2006
Posts: 120
Rep Power: 3 brad sue is on a distinguished road
    void Screen::shrink(int reduc)
    { 
         if((reduc<height)&&(reduc<width))
           {  
            height=height/reduc;
            width=width/reduc;
            
            char *newpixels=new char[height*width];
                //iterate the old block line by line
            for ( int i = 0; i < width; i++)
              {
               memcpy( newpixels + (i*width), pixels + (i*width),width);  //copy only the required amount of data
              }
               //delete the old data     
            delete []pixels;      
            pixels = newpixels;           
             } 
   }
brad sue is offline   Reply With Quote