CP - Alien Breed Remake - 7

Miscellaneous Forums/Blitz Showcase/CP - Alien Breed Remake - 7

OK, Just written this little proggy to split the tiles into 2 files... It worked first time would you believe it!

Anyway... Got to create transparant versions of a few more tiles before these files will be 100%, but it works really well this!! Sorry... just really impressed with myself!

img=LoadImage("gfx/tiles.png")
maxtile=(ImageWidth(img)/32)*ImageHeight(img)/32
FreeImage img
tiles = LoadAnimImage("gfx/tiles.png",32,32,0,maxtile)

Global gotr=0
Global gotg=0
Global gotb=0

Function GetRGB(buffer,x,y)
	argb=ReadPixelFast(x,y,buffer)
	gotr=(ARGB Shr 16) And $ff 
	gotg=(ARGB Shr 8) And $ff 
	gotb=ARGB And $ff
End Function

SetBuffer BackBuffer()

Dim tile(maxtile-1)
For n=0 To maxtile-1
	mag=0
	blk=0
	DrawBlock tiles,0,0,n
	LockBuffer BackBuffer()
	For x=0 To 31
		For y=0 To 31
		GetRGB(BackBuffer(),x,y)
		If gotr=255 And gotg=0 And gotb=255 Then tile(n)=1:mag=mag+1
		If gotr=0 And gotg=0 And gotb=0 Then blk=blk+1
		Next
	Next
	
	If mag=1024 Then tile(n)=-1
	If blk=1024 Then tile(n)=-1

	UnlockBuffer BackBuffer()
	Cls:Text 0,50,"Processing tile:"+n:Flip
Next

i1=0
i2=0
For n=0 To maxtile-1
	If tile(n)=0 Then i1=i1+1
	If tile(n)=1 Then i2=i2+1
Next

i1=(i1/15)*32
i2=(i2/15)*32

image1 = CreateImage(480,i1+32)
image2 = CreateImage(480,i2+32)

x1=0:y1=0
x2=0:y2=0

Cls:Text 0,50,"Creating Image files":Flip

For n=0 To maxtile-1
	If tile(n)=0
		SetBuffer(ImageBuffer(image1))
		DrawBlock tiles,x1*32,y1*32,n
		x1=x1+1
		If x1=15 Then y1=y1+1:x1=0
	EndIf
	
	If tile(n)=1
		SetBuffer(ImageBuffer(image2))
		DrawBlock tiles,x2*32,y2*32,n
		x2=x2+1
		If x2=15 Then y2=y2+1:x2=0
	EndIf
Next

SetBuffer BackBuffer()

Cls:Text 0,50,"Saving Image files":Flip

SaveImage (image1,"image1.bmp")
SaveImage (image2,"image2.bmp")