Advertisement
GenesisFan64

GimpLayerToImage

Dec 21st, 2022 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. (define (create-sprite-sheet img drawable)
  2. (let *
  3. (
  4. (anImage 0)
  5. (numlayers 0)
  6. (layers 0)
  7. (imgh 0)
  8. (idx 0)
  9. (layr 0)
  10. (yoff 0)
  11. )
  12.  
  13. (set! anImage (car (gimp-image-duplicate img)))
  14. (set! numlayers (car (gimp-image-get-layers anImage)))
  15. (set! layers (cadr(gimp-image-get-layers anImage)))
  16. (set! imgh (car (gimp-image-height anImage)))
  17.  
  18. (while (< idx numlayers)
  19. (set! layr (aref layers (- (- numlayers 1) idx)))
  20. (gimp-layer-translate layr 0 yoff)
  21. (set! yoff (+ imgh yoff))
  22. (set! idx (+ idx 1))
  23. )
  24.  
  25. (gimp-image-resize-to-layers anImage)
  26. (gimp-image-merge-visible-layers anImage EXPAND-AS-NECESSARY)
  27. (gimp-display-new anImage)
  28. )
  29.  
  30. )
  31.  
  32. (script-fu-register "create-sprite-sheet"
  33. _"<Toolbox>/Xtns/Sprite-Sheet/Create From Layers / Y down"
  34. "Creates a new image from current image, then offsets each layer of new image, and finally merges all visible layers to create a spritesheet"
  35. "Brian.Schultheiss@airegear.com"
  36. "Brian.Schultheiss@airegear.com"
  37. "2009"
  38. "INDEXED* RGB* GRAY*"
  39. SF-IMAGE "Image to use" 0
  40. SF-DRAWABLE "Layer to use" 0
  41. )
  42.  
  43.  
  44. (define (create-sprite-sheet-x img drawable)
  45. (let *
  46. (
  47. (anImage 0)
  48. (numlayers 0)
  49. (layers 0)
  50. (imgw 0)
  51. (idx 0)
  52. (layr 0)
  53. (xoff 0)
  54. )
  55.  
  56. (set! anImage (car (gimp-image-duplicate img)))
  57. (set! numlayers (car (gimp-image-get-layers anImage)))
  58. (set! layers (cadr(gimp-image-get-layers anImage)))
  59. (set! imgw (car (gimp-image-width anImage)))
  60.  
  61. (while (< idx numlayers)
  62. (set! layr (aref layers (- (- numlayers 1) idx)))
  63. (gimp-layer-translate layr xoff 0)
  64. (set! xoff (+ imgw xoff))
  65. (set! idx (+ idx 1))
  66. )
  67.  
  68. (gimp-image-resize-to-layers anImage)
  69. (gimp-image-merge-visible-layers anImage EXPAND-AS-NECESSARY)
  70. (gimp-display-new anImage)
  71. )
  72.  
  73. )
  74.  
  75. (script-fu-register "create-sprite-sheet-x"
  76. _"<Toolbox>/Xtns/Sprite-Sheet/Create From Layers / X right"
  77. "Creates a new image from current image, then offsets each layer of new image, and finally merges all visible layers to create a spritesheet"
  78. "Brian.Schultheiss@airegear.com"
  79. "Brian.Schultheiss@airegear.com"
  80. "2009"
  81. "INDEXED* RGB* GRAY*"
  82. SF-IMAGE "Image to use" 0
  83. SF-DRAWABLE "Layer to use" 0
  84. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement