Advertisement
Ham62

ARGB 8bpp palette test.bas

Apr 10th, 2019
1,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define ALPHA &HC0
  2. #define RED   &H30
  3. #define GREEN &H0C
  4. #define BLUE  &H03
  5.  
  6. dim shared as integer xPos = 0, yPos = 0
  7.  
  8. sub plot8bpp(pixel as ubyte)
  9.     dim as integer pixel32
  10.    
  11.     dim as integer a = 3 - (pixel AND ALPHA) SHR 6
  12.     dim as integer r = (pixel AND RED) SHR 4
  13.     dim as integer g = (pixel AND GREEN) SHR 2
  14.     dim as integer b = (pixel AND BLUE)
  15.    
  16.     r *= 85 - a*21
  17.     g *= 85 - a*21
  18.     b *= 85 - a*21
  19.  
  20.     pixel32 = RGB(r, g, b)
  21.    
  22.     palette pixel, r, g, b
  23.    
  24.     line(xPos, yPos)-(xPos+10, yPos+10), pixel, BF
  25.     xPos += 10
  26.    
  27.     if xPos >= 160 then'640 then
  28.         xPos = 0
  29.         yPos += 10
  30.     end if
  31. end sub
  32.  
  33. screenres 640, 480, 8
  34.  
  35. #define _ARGB8(_a, _r, _g, _b) (_a SHL 6 OR _r SHL 4 OR _g SHL 2 OR _b)
  36. 'plot8bpp(_ARGB8(3, 3, 0, 3))
  37.  
  38. for x as integer = 0 to 255
  39.     plot8bpp(x)
  40.     'sleep 50,1
  41. next x
  42.  
  43. 'dim as any ptr pImage = ImageCreate(160, 160)
  44. 'get (0, 0)-(160, 160), pImage
  45.  
  46. 'dim as integer w, h, b, p, d, size
  47. 'ImageInfo pImage, w, h, b, p, d, size
  48. 'print w, h, size
  49. 'put (200, 200), pImage
  50. 'bsave "Palette.bmp", 0
  51. sleep
  52. 'sleep
  53.  
  54. 'ImageDestroy(pImage)
  55. 'screen 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement