As it happens, I have need to do other sorts of pixel processing & don't need this in realtime, so East-Power-Soft's method works well for me. :) Thanks for the tips, though -- that's a nice r2t routine, hadn't seen it before, klepto.
ImaginaryHuman, I have no idea how to accomplish that in MaxGUI, that's why I was asking. :)
Here's what I ended up doing:
ImaginaryHuman, I have no idea how to accomplish that in MaxGUI, that's why I was asking. :)
Here's what I ended up doing:
' given two identical images, one drawn on white and one drawn on black, ' return a third image that is the true color plus the alpha mask. Function makeAlpha:TImage(img1:TImage, img2:TImage) i1:TPixmap = LockImage(img1) i2:TPixmap = LockImage(img2) For x = 0 To ImageWidth(img1) - 1 For y = 0 To ImageHeight(img1) - 1 rgba = ReadPixel(i1, x, y) rgba2 = ReadPixel(i2, x, y) If rgba <> rgba2 GetRGB(rgba, a, r, g, b) GetRGB(rgba2, a2, r2, g2, b2) newa = 255 - Abs(r - r2) newrgba = GenRgb(r2, g2, b2, newa) WritePixel(i1, x, y, newrgba) EndIf Next Next Return LoadImage(i1) End Function ' from archives Function GetRGB(argb:Int, a Var, r Var, g Var, b Var) a=(argb Shr 24) & $ff r=(argb Shr 16) & $ff g=(argb Shr 8) & $ff b=argb & $ff End Function ' from archives Function GenRgb(RED, green, blue, Alpha = 255) RGB = (Alpha Shl 24) | (RED Shl 16) | (Green Shl 8) | Blue Return rgb End Function