2D image to 3D texture help

Blitz3D Forums/Blitz3D Programming/2D image to 3D texture help

Coders,
I have updated my SpriteControl quite heavily now and I am now using the function below to copy an existing 2d image into a texture.
What I need to know is how to write the correct pixel format into the texture depending on what 'texture flags' are being used.

To make things clearer, the CreateTexture function has these flags:

1: Color (default)
2: Alpha
4: Masked
8: Mipmapped
16: Clamp U
32: Clamp V
64: Spherical environment map
128: Cubic environment map
256: Store texture in vram
512: Force the use of high color textures



Here is the function I am using to copy an existing 2D image into a texture. To help you understand the function a little better, this just takes an existing 2D image, creates a 'padded' (rounded up to the nearest power of 2) texture and copies the 2d pixel info into the texture. After that, it gets scaled and thrown into a quad entity for displaying.
; Convert existing image to quad
Function ImageToSprite(img,texflags=5,par=-1)
	If par=1 par=spritepivot
	Local iw=ImageWidth(img) , ih=ImageHeight(img)
	Local tw=2 Shl (Len(Int(Bin(iw-1)))-1)
	Local th=2 Shl (Len(Int(Bin(ih-1)))-1)
	Local tex=CreateTexture(tw,th,texflags)
	Local ib=ImageBuffer(img) : LockBuffer ib
	Local tb=TextureBuffer(tex) : LockBuffer tb
	Local x,y
	For x=0 To iw-1
		For y=0 To ih-1
			rgbc=ReadPixelFast(x,y,ib) And $00ffffff
			If rgbc=((r Shl 16)+(g Shl 8)+b)
				WritePixelFast x,y,($00000000),tb
			Else
				WritePixelFast x,y,(rgbc Or $ff000000),tb
			EndIf
		Next
	Next
	UnlockBuffer ib : UnlockBuffer tb
	ScaleTexture tex,Float(tw)/Float(iw),Float(th)/Float(ih)
	Local sprite=CreateImage3D(iw,ih,par)
	EntityTexture sprite,tex
	EntityFX sprite,1+16 : EntityOrder sprite,-100
	ScaleEntity sprite,Float(iw)/2,Float(ih)/2,1
	Return sprite
End Function

Now, the bit I don't understand is the the difference between alpha and masked. The function DOES ignore black (like 2D DrawImage) if flag 4 is used and likewise, shows as solid if flag 1 is applied.

I'm guessing alpha should be ignored?