Advertisement
jargon

Sample.bas

Aug 23rd, 2022
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. Function alpha22( ByVal source_pixel As ulong, ByVal destination_pixel As ulong, ByVal parameter As Any Ptr ) As ulong
  2.  
  3. dim as ulong rgba1,rgba2,rgba3
  4. dim as ulong r1,g1,b1,a1
  5. dim as ulong r2,g2,b2,a2
  6. dim as ulong r3,g3,b3,a3
  7.  
  8. /'
  9. Dim threshold As ulong = &HFF
  10. select case parameter
  11. case 0
  12. case else
  13. threshold = *CPtr(ULong Ptr, parameter)
  14. end select
  15. '/
  16.  
  17. rgba1=source_pixel
  18. rgba2=destination_pixel
  19.  
  20. a1=(rgba1 shr 24) and &HFF
  21. a2=(rgba2 shr 24) and &HFF
  22.  
  23. r1=(rgba1 shr 16) and &HFF
  24. r2=(rgba2 shr 16) and &HFF
  25.  
  26. g1=(rgba1 shr 8) and &HFF
  27. g2=(rgba2 shr 8) and &HFF
  28.  
  29. b1=rgba1 and &HFF
  30. b2=rgba2 and &HFF
  31.  
  32. r3=(r1 * a1 + r2 * a2) / &HFF / 2
  33. g3=(g1 * a1 + g2 * a2) / &HFF / 2
  34. b3=(b1 * a1 + b2 * a2) / &HFF / 2
  35. a3=(a1 + a2) / 2
  36.  
  37. rgba3=rgba(r3,g3,b3,a3)
  38.  
  39. function = rgba3
  40. exit function
  41.  
  42. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement