Mask Weirdness Readpixel vs Readpixelfast

Blitz3D Forums/Blitz3D Programming/Mask Weirdness Readpixel vs Readpixelfast

_Skully(Posted 2009) [#1]
The code
Function ImageHasAlpha(image, frame, mask)
	Local x,y,iw,ih
	iw=ImageWidth(image)
	ih=ImageWidth(image)
	For x=0 To iw-1
		For y=0 To ih-1
			If ReadPixel(x,y,ImageBuffer(image,frame))=mask Then
				Return True
			EndIf
		Next
	Next
	Return False
End Function


works.. but the code...

Function ImageHasAlpha(image, frame, mask)
	Local x,y,iw,ih
	iw=ImageWidth(image)
	ih=ImageWidth(image)
	LockBuffer ImageBuffer(image,frame)
	For x=0 To iw-1
		For y=0 To ih-1
			If ReadPixelfast(x,y,ImageBuffer(image,frame))=mask Then
				UnlockBuffer ImageBuffer(image)
				Return True
			EndIf
		Next
	Next
	UnlockBuffer ImageBuffer(image,frame)
	Return False
End Function


Doesn't. Is there a difference between what readpixelfast returns and what readpixel returns?


_Skully(Posted 2009) [#2]
Ugh.. just noticed the problem with using imagewidth with an anim image.


_Skully(Posted 2009) [#3]
Fixed... sorry for the post..

Function ImageHasAlpha(image, frame, mask)
	Local x,y
	LockBuffer ImageBuffer(image,frame)
	For x=0 To TileSizeX-1
		For y=0 To TileSizeY-1
			If ReadPixelFast(x,y,ImageBuffer(image,frame))=mask Then
				UnlockBuffer ImageBuffer(image,frame)
				Return True
			EndIf
		Next
	Next
	UnlockBuffer ImageBuffer(image,frame)
	Return False
End Function



GIB3D(Posted 2009) [#4]
Don't know if you noticed this too but you put ImageWidth for both
iw=ImageWidth(image)
ih=ImageWidth(image)



_Skully(Posted 2009) [#5]
Ya it was messed... sleepy coding! lol

thanks.


_PJ_(Posted 2009) [#6]
*Orders Red Bull, coffee and pro-plus for Skully*