Can't see how that works correctly since it reads before the first pixel?
Here are some other possibilites. May still need some work though.
Here are some other possibilites. May still need some work though.
Function FlipImg2(infile$,outfile$,horz, verz) Local image,w,h,himg,vimg,ibuf,hbuf,vbuf,centre image=LoadImage(infile) w = ImageWidth(image) h = ImageHeight(image) himg = CreateImage(w,1) vimg = CreateImage(1,h) ibuf = ImageBuffer(image) hbuf = ImageBuffer(himg) vbuf = ImageBuffer(vimg) If horz Then centre = (w-1)/2 For x=0 To centre CopyRect x,0,1,h, 0,0,ibuf,vbuf CopyRect w-x-1,0,1,h, x,0,ibuf,ibuf CopyRect 0,0,1,h, w-x-1,0,vbuf,ibuf Next EndIf If verz Then centre = (h-1)/2 For y=0 To centre CopyRect 0,y,w,1, 0,0,ibuf,hbuf CopyRect 0,h-y-1,w,1, 0,y,ibuf,ibuf CopyRect 0,0,w,1, 0,h-y-1,hbuf,ibuf Next EndIf SaveBuffer (ibuf,outfile$) FreeImage himg FreeImage vimg Freeimage image End Function ; or a simpler version, but slower here for large images due to use of copyimage. Function FlipImg2a(infile$,outfile$,horz, verz) Local image,w,h,himg,vimg,ibuf,hbuf,vbuf image=LoadImage(infile) w = ImageWidth(image) h = ImageHeight(image) tempimage = CopyImage(image) ibuf = ImageBuffer(image) tbuf = ImageBuffer(tempimage) If horz Then For x=0 To w-1 CopyRect x,0,1,h, w-x-1,0,ibuf,tbuf Next EndIf If verz Then For y=0 To h-1 CopyRect 0,y,w,1, 0,h-y-1,tbuf,ibuf Next EndIf If verz Then SaveBuffer (ibuf,outfile$) Else SaveBuffer(tbuf,outfile$) Freeimage image Freeimage tempimage End Function ; the little used copypixelfast. Function FlipImg4(infile$,outfile$,horz, verz) Local img,w,h,newimage,ibuf,nbuf img=LoadImage(infile$) ibuf = ImageBuffer(img) w = ImageWidth(img) h = ImageHeight(img) newimage = CreateImage(w,h) nbuf=ImageBuffer(newimage) LockBuffer ibuf LockBuffer nbuf h=h-1 : w=w-1 If horz=1 And verz=0 Then For y=0 To h : For x=0 To w : CopyPixelFast x,y,ibuf,w-x,y,nbuf : Next : Next If horz=0 And verz=1 Then For y=0 To h : For x=0 To w : CopyPixelFast x,y,ibuf,x,h-y,nbuf : Next : Next If horz=1 And verz=1 Then For y=0 To h : For x=0 To w : CopyPixelFast x,y,ibuf,w-x,h-y,nbuf : Next : Next UnlockBuffer nbuf UnlockBuffer ibuf SaveBuffer (ImageBuffer(newimage),outfile$) FreeImage img Freeimage newimage