Realtime pixmap writing

BlitzMax Forums/BlitzMax Beginners Area/Realtime pixmap writing

Curtastic(Posted 2007) [#1]
I want to rewrite an image every loop, and keep drawing it. It was easy to do it Blitz3D with imagebuffers but with pixmaps on my computer after like 5 seconds it starts leaving trails and flickering. I realize I am creating the image in the loop, I need a fresh image every frame. Am I doing something wrong?
Graphics 555,555

Local pixmap:TPixmap
Local image:timage

Repeat
	
	image=CreateImage(111,111)
	
	a:+2
	x=50+Cos(a)*40
	y=50+Sin(a)*40
	
	pixmap=LockImage(image)
		For f=1 To 10
			WritePixel pixmap,x+f,y+f,$FF0000FF
		Next
		For f=1 To 10
			WritePixel pixmap,x+Cos(a)*f,y+Sin(a)*f,$FFFF0000
		Next
	UnlockImage image
	
	SetColor 255,255,255
	DrawImage image,22,22
	DrawPixmap pixmap,222,222
	
	Flip
	Cls
	If KeyHit(key_escape) Then End
Forever


And if I comment out the DrawPixmap (I don't need it anyways) the same problem happens with drawimage just not as bad.


Perturbatio(Posted 2007) [#2]
Graphics 555,555

Local pixmap:TPixmap
Local image:timage =CreateImage(111,111)
Repeat
	

	
	a:+2
	x=50+Cos(a)*40
	y=50+Sin(a)*40
	
	pixmap=LockImage(image)
		ClearPixels(pixmap)
		For f=1 To 10
			WritePixel pixmap,x+f,y+f,$FF0000FF
		Next
		For f=1 To 10
			WritePixel pixmap,x+Cos(a)*f,y+Sin(a)*f,$FFFF0000
		Next
	UnlockImage image
	
	SetColor 255,255,255
	DrawImage image,22,22
	DrawPixmap pixmap,222,222
	
	Flip
	Cls
	 
	If KeyHit(key_escape) Then End
Forever


Use ClearPixels, I presume that when you're re-creating the image, it's sometimes using memory that was previously used, and since you're not overwriting all of it, you get ghost images.


Curtastic(Posted 2007) [#3]
Oh cool thanks! I didn't have clearpixels() because I apparently forgot to sync mods