retrun "jumps" up to a line above

Hi
I have this weird problem in my code.
The code looks like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
template<typename T>
Image<T> Image<T>::rotate(float deg)const{
   
    ...code that works fine ...

    Image<T> rotated_img(newW,newH,channels);
    for(uint16_t x = 0;x<newW;x++)for(uint16_t y = 0;y<newH;y++){
        oldx = (x-newW/2.0)*cos(deg) + (y-newH/2.0)*sin(deg) + width/2.0;
        oldy = (y-newH/2.0)*cos(deg) - (x-newW/2.0)*sin(deg) + height/2.0;
        for(int c = 0;c<channels;c++){
            T p = getInterpolatedPixel(oldx,oldy,c,LINEAR,ZERO_PADDING);
            rotated_img.setPixel(x,y,c,p);
        }
    }


    return rotated_img;

The code is correct. But when the debugger stops at the return statement and I tell the debugger to run next line it jumps up to "Image<T> rotated_img(newW,newH,channels);" and returns and empty image. (The image is correct after the for loops but not after the return)

*Edit: I using newest version of MinGW and Code::Blocks*
Last edited on
Do you have a copy constructor for Image<T>?
Yes:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<typename T>
Image<T>::Image(const Image<T>& img):
    width(img.width),
    height(img.height),
    channels(img.channels),
    data(0)
{
    data = new T*[channels]();
    for(int i = 0;i<channels;i++){
        data[i] = new T[width*height]();
        for(int j = 0;j<channels;j++){
            data[i][j]= img.data[i][j];
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
template<typename T>
Image<T>::Image(const Image<T>& img):
    width(img.width),
    height(img.height),
    channels(img.channels),
    data(0)
{
    data = new T*[channels]();
    for(int i = 0;i<channels;i++){
        data[i] = new T[width*height]();
        for(int j = 0;j<width*height;j++){
            data[i][j]= img.data[i][j];
        }
    }
}
OMG, that embarrassing, I should have noticed that.

Thank you very much
Topic archived. No new replies allowed.