Copying from one image to another

BlitzMax Forums/BlitzMax Beginners Area/Copying from one image to another

You can either
a) convert them both to pixmaps and use the pixmap paste method
b) draw them both to backbuffer and grabimage
c) Try this code...
Graphics 800,600,0
SeedRnd MilliSecs()
Global background:TImage=LoadImage("pic2.png")
Global image1:Timage=LoadImage("i1.png")  '512*512
Global image2:TImage=LoadImage("oval.png")
'Global image3:Timage=LoadImage("clogo1.png")
While Not KeyHit(key_escape)
        Cls
	Global start_func:Int
	Global end_func:Int
	Local red,green,blue:Int
'	GetMaskColor(red,green,blue)
	argb:Int=intcolor(255,0,255)
	start_func=MilliSecs()
	drawbuffer(image1,image2,Rand(0,700),Rand(0,500),argb)
	end_func=MilliSecs()
	DrawImage background,0,0
	DrawImage image1,0,0
	DrawText end_func-start_func,600,0
	Flip
Wend
WaitKey()
Function drawbuffer(imagea:TImage,imageb:TImage,x:Int,y:Int,argb:Int)
  If x + ImageWidth(imageb) > ImageWidth(imagea) Or y + ImageHeight(imageb) > ImageHeight(imagea) RuntimeError("Imagea to big to fit in imageb")
'  start_func=MilliSecs()
  mypixmap2:TPixmap=LockImage(imageb)
  UnlockImage(imageb)
  mypixmap1:TPixmap=LockImage(imagea)
  Local mypixelptr2:Int Ptr = Int Ptr(mypixmap2.pixelptr(0,0))
  Local mypixelptr2backup:Int Ptr = mypixelptr2
  Local mypixelptr1:Int Ptr = Int Ptr(mypixmap1.pixelptr(x,y))
  Local mypixelptr1backup:Int Ptr = mypixelptr1
  For my_x=0 To ((mypixmap2.width)*(mypixmap2.height))
     If mypixelptr2[0] <> argb   mypixelptr1[0]=mypixelptr2[0]
'        If Var mypixelptr2<>0 MemCopy (Byte Ptr(mypixelptr1),Byte Ptr(mypixelptr2),4)
'         If Var mypixelptr2 <> 0 mypixelptr1[0]=mypixelptr2[0]
'    EndIf
     mypixelptr1:+1
     mypixelptr2:+1
     If mypixelptr2 = mypixelptr2backup+(mypixmap2.pitch/4)
         mypixelptr1 = mypixelptr1backup+(mypixmap1.pitch/4)
         mypixelptr1backup=mypixelptr1
         mypixelptr2backup=mypixelptr2
     EndIf
  Next
  UnlockImage(imagea)
'  end_func=MilliSecs()
End Function
Function IntColor(R,G,B,A=255)
'returns argb value from red, green, blue.
     Return A Shl 24 | R Shl 16 | G Shl 8 | B Shl 0
End Function