Save alpha channel from buffer to file?
Blitz3D Forums/Blitz3D Programming/Save alpha channel from buffer to file?
| ||
I know itīs not possible with SaveBuffer (only 24bit .bmp) but there has to be a way, right? Graphics3D 800,500,0,2 cam=CreateCamera() CameraClsColor cam,128,128,128 PositionEntity cam,0,0,-5 cube=CreateCube() tex=CreateTexture(256,256,1+2+8) For y=95 To 159 For x=95 To 159 WritePixel(x,y,0 Shl 24,TextureBuffer(tex)) Next Next EntityTexture cube,tex Repeat TurnEntity cube,.1,.1,.1 RenderWorld Delay 10 Flip Until KeyHit(1) End thx, chi |
| ||
Maybe you could save a black&white bitmap that contains only the alpha channel. Or you could save the data to a file, and then import it as 'raw' format. |
| ||
Yeah I think Warner's on the right track... some form of: (sorry, only pseudo code cos I dont have Blitz handy at the mo) Function SaveAlpha(Buffer,FilePath$) Local OriginalBuffer=GraphicsBuffer() SetBuffer Buffer Local W=GraphicsWidth() Local H=GraphicsHeight() Local X,Y,C,A Local File=WriteFile(FilePath$) ;Maybe necessary to ensure the dimensions of the buffer are kept WriteInt File,X WriteInt File,Y For X=0 to W-1 For Y=0 to H-1 C=ReadPixelFast(X,Y) A=GetAlpha(C); This would be some kinda Hex-fiddling to get just the a from the aRGB :) WriteInt File,A Next Next CloseFile File SetBuffer OriginalBuffer End Function |
| ||
If the question is about saving a texture with alpha then try Save tga. I just noticed this is entry #1 in the code archives, from 2001. |
| ||
yeah, thank you! SaveTga is working for me ;) donīt know why i couldnīt find this c.a.entry by myself?? thx 4 help, chi |