;;;
;;; BMP from MNR, extract bitmap utility.
;;; by Matthew S Rothgery, 3-18-2004
;;;
;;; Saves individual .BMP files read from the
;;; current menu's .MNR file, in the same directory.
;;;
(defun c:BMPfromMNR(/ *error* fileMNR fileBMP ct offset byte)
(defun *error*(s)
(if fileBMP(setq fileBMP(close fileBMP)))
(if fileMNR(setq fileMNR(close fileMNR)))
(princ)
)
(setq fileMNR (open(findfile(strcat(getvar"MENUNAME")".MNR"))"r")
ct 1
offset 0
byte '(0 0)
)
(while(setq char(read-char fileMNR))
(cond((equal byte '(66 77))
(setq fileBMP(strcat(getvar"MENUNAME")"_BMP_EXTRACT"(itoa
ct)".BMP"))
(prompt(strcat "\n\nCreating file:\n" fileBMP "\n"))
(setq ct (1+ ct)
fileBMP (open fileBMP "w")
byte (list char)
offset 6
)
(while(<(length byte)4)
(setq byte(append byte(list(read-char fileMNR))))
)
(write-char 66 fileBMP)
(write-char 77 fileBMP)
(foreach c byte(write-char(+ 256 c)fileBMP))
(setq byte(apply'+(mapcar'* byte'(1 256 65536 16777216))))
)
((not fileBMP)(setq byte(list(cadr byte)char)))
((not(numberp byte)))
((< offset byte)
(write-char(+ 256 char)fileBMP)
(setq offset(1+ offset))
(prompt(strcat"\r"(itoa offset)))
)
((= offset byte)
(write-char 256 fileBMP)
(setq fileBMP(close fileBMP))
(setq byte(list 0 char)offset(1+ offset))
(prompt(strcat"\r"(itoa offset)" bytes"))
)
)
)
(*error*())
)