GetImage() will grab contents from the screen back buffer to an image. There is no need to GetImage on an image as it is already an image. Just use the rendered image for your sprite instead. You also do not need to use Render() on a render image as draw calls will be instantaneous. However, if you want sprites or text to appear on the rendered image, then you need to use DrawSprite and DrawText as they do not automatically appear on the image.
Here is an example of your code using a render image. You can find another example in the help files. file:///C:/Program%20Files%20(x86)/The%20Game%20Creators/AGK2/Tier%201/Help/Reference/Core/SetRenderToImage.htm
SetWindowTitle( "test" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
width=getmaxdevicewidth()
height=getmaxdeviceheight()
x1=0
x2=width
y1=1
y2=1
red=128:green=128:blue=255
createtext(1,"File")
createtext(2,"Edit")
settextsize(1,34)
settextsize(2,34)
settextcolor(1,255,255,255,255)
settextvisible(1,1)
//swap()
createrenderimage(1,width,60,0,0) //create an image to render to
setrendertoimage(1,0)
setvirtualresolution(width,60) //Make sure virtual resolution matches image size
for i=1 to 60
drawline(x1,y1,x2,y2,makecolor(red,green,blue),makecolor(red,green,blue))
inc y1,1
inc y2,1
dec red,2
dec green,1
dec blue,1
next i
SetRenderToScreen()
SetVirtualResolution(1024,768) //set virtual resolution back to screen
settextposition(1,20,15)
settextposition(2,50+gettexttotalwidth(1),15)
createsprite(2,1) //create the sprite from the rendered image.
do
Print( ScreenFPS() )
Sync()
loop