How do I saving the results of a pixelated render to an image file?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By grymjack

I rendered a large coordinate text file (16M lines) into a pixelated picture. How do I go about saving the results to an image file? I created it on a black background TextureRec using the code below:

func _draw():
	var f = File.new()
	f.open(file, File.READ)
	#for loop in range(0,1000000):
	while not f.eof_reached():
		var line = f.get_line()
		if (line == null):
			f.close()
			print('done')
			return
		
		var xcoord = (int(line.get_slice(",", 0))/40)
		var ycoord = (int(line.get_slice(",", 1))/40)

		var point = PoolVector2Array([Vector2(xcoord, ycoord)])
		var color = PoolColorArray([Color(255, 0, 0)])
		draw_primitive(point, color, PoolVector2Array())

	f.close()
	print('done')
	return