from devil import *

def Run():

	ilInit()
	main = ilGenImage()
	ilBindImage(main)

	if not ilLoad(IL_TYPE_UNKNOWN, "test.tga"):
		print "load failure: test.tga"
		return

	ilConvertImage(IL_BGRA, IL_UNSIGNED_BYTE)
		
	sub = ilGenImage()
	ilBindImage(sub)
	ilTexImage((32, 32, 1))
	
	sub_data = ilGetData()

	ilBindImage(main)
	ilCopyPixels((0, 10, 0), (32, 32, 1), IL_BGRA, IL_UNSIGNED_BYTE, sub_data)

	ilBindImage(sub)
	ilEnable(IL_FILE_OVERWRITE)
	ilSave(IL_TGA, "sub.jpg")

	ilDeleteImage(main)
	
Run()