makeicons.bmx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. SuperStrict
  2. Framework brl.glmax2d
  3. Import brl.pngloader
  4. Local sizes:Int[] = [24, 48, 64]
  5. Local pixmaps:TPixmap[] = New TPixmap[sizes.length]
  6. For Local i:Int = 0 Until sizes.length
  7. pixmaps[i] = BuildIcons(sizes[i])
  8. Select sizes[i]
  9. Case 24
  10. SavePixmapPNG pixmaps[i],"../toolbar.png"
  11. Default
  12. SavePixmapPNG pixmaps[i],"../toolbar_" + sizes[i] + ".png"
  13. End Select
  14. Next
  15. Graphics 640,480,0
  16. Local img:TImage[] = New TImage[sizes.length]
  17. For Local i:Int = 0 Until sizes.length
  18. img[i] = LoadImage(pixmaps[i])
  19. 'DrawPixmap p,0,0
  20. DrawImage img[i],50,100 + i * 80
  21. Next
  22. Flip
  23. WaitKey
  24. Function BuildIcons:TPixmap(sz:Int)
  25. Local actions:String[] = GetActions()
  26. Local n:Int = actions.length
  27. Local p:TPixmap
  28. Local xOffset:Int = 0
  29. For Local i:Int = 0 Until actions.length
  30. Local t$ = actions[i]
  31. If t<>" "
  32. Local q:TPixmap=LoadPixmap( sz + "/" + t+".png" )
  33. If Not p
  34. Local rgb:Int=0'q.readpixel( 0,0 )
  35. p=TPixmap.Create( n*sz,sz,PF_RGBA8888 )
  36. For Local y:Int = 0 Until sz
  37. For Local x:Int = 0 Until n*sz
  38. p.WritePixel x,y,rgb
  39. Next
  40. Next
  41. EndIf
  42. If q.width>sz Or q.height>sz
  43. q=ResizePixmap( q,sz,sz )
  44. EndIf
  45. Local cx:Int = (sz-q.width)/2
  46. Local cy:Int = (sz-q.height)/2
  47. p.paste q,xOffset+cx,cy
  48. EndIf
  49. xOffset:+sz
  50. Next
  51. Return p
  52. End Function
  53. Function GetActions:String[]()
  54. Return [ "New","Open","Close","Save"," ", ..
  55. "Cut","Copy","Paste","Find"," ", ..
  56. "Build","Build-Run","Step","Step-In","Step-Out","Stop"," ", ..
  57. "Home","Back","Forward", ..
  58. "Go" ..
  59. ]
  60. End Function