makeicons.bmx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. 'attention: place all icons replacing other ones (eg toggle states)
  55. 'at the end of the file. Allows constant values to access
  56. 'toolbar indices _and_ iconStrip indices with the same value
  57. Return [ "NewFile","OpenFile","CloseDocument","Save"," ", ..
  58. "Cut","Copy","Paste","Search"," ", ..
  59. "Build","Build-Run","StepOver","StepIn","StepOut","Stop"," ", ..
  60. "Home","StepBackwards","StepForward", ..
  61. " ", "LockOpen", "LockGoto", ..
  62. "Go", "LockClosed" ..
  63. ]
  64. End Function