Thank you. I have tried various things now and the following code seems to work, but I don't know why. If someone knows it would be nice if he can post it here :-)
If horz=1 And verz=0 Then pix = ReadPixelFast(x-1,y,ImageBuffer(img)) : WritePixelFast(w-x,y,pix,ImageBuffer(newimage)) If horz=0 And verz=1 Then pix = ReadPixelFast(x,y-1,ImageBuffer(img)) : WritePixelFast(x,h-y,pix,ImageBuffer(newimage)) If horz=1 And verz=1 Then pix = ReadPixelFast(x-1,y-1,ImageBuffer(img)) : WritePixelFast(w-x,h-y,pix,ImageBuffer(newimage))