So I have started to make a painting program in Blitz using pixmaps, but I quickly came across a problem: pixmaps don't work with alpha.
In this piece of jumble I've put together, the gradient should get more transparent on the right, and more solid on the left. Also, try painting: the brush is solid, but it should be soft.
You can see, on mouse over, that I have encoded the pixels correctly (the first two letters of the hex value are for alpha), yet it doesn't draw correctly. And yes, the format is RGBA8888 and yes, ALPHABLEND is on.
In this piece of jumble I've put together, the gradient should get more transparent on the right, and more solid on the left. Also, try painting: the brush is solid, but it should be soft.
You can see, on mouse over, that I have encoded the pixels correctly (the first two letters of the hex value are for alpha), yet it doesn't draw correctly. And yes, the format is RGBA8888 and yes, ALPHABLEND is on.
SuperStrict Framework brl.blitz Import brl.glmax2d Import brl.retro Import brl.polledinput Import brl.keycodes Graphics 800, 600 SetBlend(ALPHABLEND) SetColor(255, 255, 255) SetAlpha(1) SetClsColor(255, 200, 200) Global pix:TPixmap = CreatePixmap(256, 256, PF_RGBA8888) ClearPixels(pix, $BBBBBBBB) For Local xx:Int = 0 To 255 For Local yy:Int = 0 To 255 WritePixel(pix, xx, yy, MakeCol(xx, 0, yy, 255)) Next Next While Not AppTerminate() Cls If MouseX() >= 20 And MouseX() < 276 And MouseY() >= 20 And MouseY() < 276 DrawText(Hex:String(ReadPixel(pix, MouseX() - 20, MouseY() - 20)), 310, 40) If MouseDown(MOUSE_LEFT) DrawBrush() DrawPixmap(pix, 20, 20) Flip Wend Function MakeCol:Int(a:Byte, r:Byte, g:Byte, b:Byte) Local n:Int Local m:Byte ptr = VarPtr n m[0] = b m[1] = g m[2] = r m[3] = a Return n EndFunction Function DrawBrush() Local rx:Int = MouseX() - 20 Local ry:Int = MouseY() - 20 For Local aa:Int = 0 To 360 Step 2 For Local d:Int = 0 To 17 writepix(pix, rx + Ceil(d * Cos(aa)), ry + Ceil(d * Sin(aa)), MakeCol(Ceil(255 - (255 / 17) * d), 0, 255, 0)) Next Next End Function Function writepix(pixmap:TPixmap, x:Int, y:Int, argb:Int) If x >= 0 And x < pixmap.width And y >= 0 And y < pixmap.height And pixmap <> Null WritePixel(pixmap, x, y, argb) EndFunction