Image Pasting

BlitzMax Forums/BlitzMax Programming/Image Pasting

jamesmintram(Posted 2006) [#1]
Hi, i was wondering if it were posssible to draw one image onto into another keeping transparent pixels transparent and other attributes like scale, alpha etc


TartanTangerine (was Indiepath)(Posted 2006) [#2]
Hi James,

Only with a render to texture function, since images are actually textures in BMAX you would have to set the target image as the Rendertarget and render the source image to it.

This is possible in BMAX and technically it's quite simple, I have a module in progess to do such a thing but since Mark changed a lot of core stuff in version 1.14 I've put the project on hold. Maybe some other time.


Scott Shaver(Posted 2006) [#3]
this might help

	Function InsertImage(src:TImage,destx:Int,desty:Int,srcFrame:Int,dest:TImage,transColor:Int=$FF000000)
		Local dmap:TPixmap = LockImage(dest)
		Local smap:TPixmap = LockImage(src,srcFrame)
		For Local y:Int =0 To ImageHeight(src)-1
			For Local x:Int=0 To ImageWidth(src)-1
				Local color:Int = ReadPixel(smap,x,y)
				color=(color & ($FFFFFF:Int)) | $FF000000:Int
				If color<>transColor Then
					WritePixel(dmap,x+destx,y+desty,color)
				EndIf
			Next
		Next
		UnlockImage(src,srcFrame)
		UnlockImage(dest)
	End Function




jamesmintram(Posted 2006) [#4]
Ok, thanks for that!