1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
void doublesize(pixel image[],int height,int width,int& nw,int& nh)
{
nw=width*2;
nh=height*2;
pixel* doubleimage=new pixel[nw*nh];
for (int i=0; i<nh; i++)
for (int j=0; j<nw; j++)
doubleimage[i*nw+j] = image[(i/2)*width+(j/2)];
delete[] image; //I'm assuming readfile() is using new. If it isn't, this may not work
image = doubleimage;
}
void main()
{
int height,width,numLevels;
pixel* image;
pixel* nimage;
int nw,nh;
image=readfile(height,width,numLevels);
doublesize(image,height,width,nw,nh);
//now image points to the doublesized image, which replaced the original
}
|