Well, you can set the screen size on the window view, and the full screen view. Though, if you want to have the size change at anytim through the game, you could get the size of the screen on the right and bottom, and just add/subtract from there. Such as :
text screen width()/2,screen height()/2,"Hello"
If that's not what you meant, then to keep the image from leaving the view, just do this:
if sprite x(1)>screen width()-5 then sprite 1,screen width()-5,sprite y(1), sprite image(1)
if sprite y(1)>screen height()-5 then sprite 1,sprite x(1),screen height()-5,sprite image(1)
if sprite x(1)<5 then sprite 1,5,sprite y(1),sprite image(1)
if sprite y(1)<5 then sprite 1,sprite x(1),5,sprite image(1)
Hope any of these were what you meant.