Try this code. You just need to call:
The source texture is the DECAL and the destination texture is where the decal is applied.
The optional rgb flags are used for masking the decal.
In the example below the decals background is masked out using 255,0,255
The two test images I used:


ApplyDecal source_texture , dest_texture [,r,g,b]Both 'texture' parameters should point to a loaded texture.
The source texture is the DECAL and the destination texture is where the decal is applied.
The optional rgb flags are used for masking the decal.
In the example below the decals background is masked out using 255,0,255
The two test images I used:


; Applying a DECAL to a texture ; Syntax Error Graphics3D 640,480 SetBuffer BackBuffer() cam=CreateCamera() : light=CreateLight() cube=CreateCube() : MoveEntity cube,0,0,4 cubetex=LoadTexture("wood.jpg") EntityTexture cube,cubetex decal=LoadTexture("decal.png") Repeat TurnEntity cube,0.5,0.6,0.7 If KeyHit(57) ApplyDecal decal,cubetex ,255,0,255 RenderWorld Text 10,10,"Press [SPACE] to apply the decal ..." Flip Until KeyHit(1) End ; Apply source texture to destination texture (with optional masking) Function ApplyDecal(sourceb,destb,maskR=0,maskG=0,maskB=0) Local gb=GraphicsBuffer() , rgb Local sb=TextureBuffer(sourceb) , db=TextureBuffer(destb) Local maxw=TextureWidth(sourceb) , maxh=TextureHeight(sourceb) If TextureWidth(destb)<maxw Then maxw=TextureWidth(destb) If TextureHeight(destb)<maxh Then maxh=TextureHeight(destb) LockBuffer sb : LockBuffer db For x=0 To maxw-1 For y=0 To maxh-1 rgb=ReadPixelFast(x,y,sb) And $00FFFFFF If Not rgb=((maskR Shl 16)+(maskG Shl 8)+maskB) WritePixelFast x,y,(rgb Or $FF000000),db EndIf Next Next UnlockBuffer sb : UnlockBuffer db SetBuffer gb End Function