Although I already posted this some time ago:
If it looks kind of akward, exchange ARGB_Blue and ARGB_Red (dunno why I switched them ... had something to do with false coloring).
The alpha-param is used to set the alpha of the "to-draw"-image. Light-param is used to make the image a bit darker (eg. 0.5 = 50% lightness).
The Image you draw onto the other one is alpha blended but to enable alpha in the image you draw to (so the newspaper) you will have to uncomment the variable in the code and add a calculation the same way it is done for r/g/b ... and finally in the write command you have to exchange 255 with the sourceA-calculation.
bye
MB
Function ARGB_Alpha:Int(ARGB:Int) Return Int((ARGB & $FF000000:Int) / $1000000:Int) End Function Function ARGB_Red:Int(ARGB:Int) Return Int((ARGB & $00FF0000:Int) / $10000:Int) End Function Function ARGB_Green:Int(ARGB:Int) Return Int((ARGB & $0000FF00:Int) / $100:Int) End Function Function ARGB_Blue:Int(ARGB:Int) Return (ARGB & $000000FF:Int) End Function Function ARGB_Color:Int(alpha:Int,red:Int,green:Int,blue:Int) Return (Int(alpha*$1000000)+Int(blue*$10000)+Int(green*$100)+Int(RED)) End Function Function DrawOnPixmap(image:TImage, framenr:Int = 0, Pixmap:TPixmap, x:Int, y:Int, alpha:Float = 1.0, light:Float = 1.0) Local TempPix:TPixmap = Null If framenr = 0 Then TempPix = LockImage(image) If framenr > 0 Then TempPix = LockImage(image, Framenr) 'TempPix.convert(image.pixmaps[0].format) For Local i:Int = 0 To ImageWidth(image) - 1 For Local j:Int = 0 To ImageHeight(image)-1 If x+1 < pixmap.width And y+j < pixmap.height Local sourcepixel:Int = ReadPixel(TempPix, i,j) Local destpixel:Int = ReadPixel(pixmap, x+i,y+j) ' Local destA:Int = ARGB_Alpha(destpixel) Local sourceA:Int = ARGB_Alpha(sourcepixel) If sourceA = -1 Then sourceA = 255 * alpha Else sourceA = SourceA * alpha If sourceA <> - 1 Then If sourceA < - 1 Then sourceA = -sourceA Local destR:Int = ARGB_Blue(destpixel) Local destG:Int = ARGB_Green(destpixel) Local destB:Int = ARGB_Red(destpixel) Local SourceR:Int = ARGB_Blue(Sourcepixel) Local SourceG:Int = ARGB_Green(Sourcepixel) Local SourceB:Int = ARGB_Red(Sourcepixel) sourceR = Int(Float(sourceA / 255.0) * Float(sourceR * light)) + Int(Float((255 - sourceA) / 255.0) * Float(destR)) sourceG = Int(Float(sourceA / 255.0) * Float(sourceG * light)) + Int(Float((255 - sourceA) / 255.0) * Float(destG)) sourceB = Int(Float(sourceA / 255.0) * Float(sourceB * light)) + Int(Float((255 - sourceA) / 255.0) * Float(destB)) sourcepixel = ARGB_Color(255, sourceR, sourceG, sourceB) EndIf If sourceA <> 0 Then WritePixel(Pixmap, x + i, y + j, sourcepixel) EndIf Next Next If framenr = 0 UnlockImage(image) If framenr > 0 UnlockImage(image, framenr) End Function
If it looks kind of akward, exchange ARGB_Blue and ARGB_Red (dunno why I switched them ... had something to do with false coloring).
The alpha-param is used to set the alpha of the "to-draw"-image. Light-param is used to make the image a bit darker (eg. 0.5 = 50% lightness).
The Image you draw onto the other one is alpha blended but to enable alpha in the image you draw to (so the newspaper) you will have to uncomment the variable in the code and add a calculation the same way it is done for r/g/b ... and finally in the write command you have to exchange 255 with the sourceA-calculation.
bye
MB