Code Select
(constant 'TEMP_DIR (if (= ostype Win32) "C:\temp" "/tmp"))
i already mentioned this in previous topic
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
(define (remove-all root, x full)
(dolist (x (directory root))
(set 'full (append root "/" x))
(if (directory? full)
(if (and (!= x "..") (!= x "."))
(begin
(remove-all full)
(remove-dir full)))
(delete-file full))))
(remove-all "c:\temp")
(remove-dir "c:\temp")
(define (remove-all dir)
(set 'fnames (list dir))
(set 'dirs '())
(while (not (empty? fnames))
(set 'fname (pop fnames))
(if (directory? fname)
(begin
(dolist (x (directory fname))
(if (and (!= x ".") (!= x ".."))
(push (append fname "/" x) fnames)))
(if (!= fname dir) (push fname dirs)))
(delete-file fname)))
(dolist (x dirs) (remove-dir x)))
;; bgra -> rgba
(define (swaprb32 data)
(join (map (lambda (x) (select x 2 1 0 3)) (explode data 4)) ""))
;; bgr -> rgb
(define (swaprb24 data)
(join (map reverse (explode data 3)) ""))
;; testing
(print "test-rgba: ")
(set 'testdata (dup "bgra" (* 512 512))) ; data from file
(set 'testres (dup "rgba" (* 512 512))) ; what i want to get
(print (time (set 'res (swaprb32 testdata))) " ")
(println (= res testres))
(print "test-rgb: ")
(set 'testdata (dup "bgr" (* 512 512)))
(set 'testres (dup "rgb" (* 512 512)))
(print (time (set 'res (swaprb24 testdata))) " ")
(println (= res testres))