@nathanwheeler27
Here is my follow up to @Lee_Mac solution to fill DCL image_tile or image button.
There are three functions BMPINIT, BMPDRAW and BMPGENERATE.
First one creates raster of hatch elements where each hatch rectangle mimics a pixel. You can use any size you want, resulting icons (image tiles ) are of rectangular shape.
Use command BMP draw to change color of individual "pixel" and draw your icon.
To change color just change current system color.
Command BMPGENERATE creates text file and renders the supplied ACI color list representation of a
bitmap image on the DCL image tile or image_button tile with the given key.
Generated code looks like this:
(setq back_img
'(
001 005 192 192 192 192 192 005
001 005 192 192 004 004 192 005
001 005 192 004 004 004 192 005
001 005 004 004 004 004 192 005
001 005 004 004 004 004 192 005
001 005 192 004 004 004 192 005
001 005 192 192 004 004 192 005
001 005 192 192 192 192 192 005
)
)
: image
{
key = "back_img";
width = 1.33;
aspect_ratio = 1.0;
fixed_width = true;
fixed_height = true;
color = -15;
}
First section is a definition of a variable that holds image definition. Second part is one that goes into DCL file.
Change image to image_button if needed. This would be a definition of an 8×8 px icon that looks like this

Included is @Lee_Mac 's function DisplayBitmap that you include inside your lisp file.
To populate DCL image tile after you load DCL you just have to do this:
.....
(new_dialog "band_beams" dcl_id_band_beams)
(DisplayBitmap "back_img" back_img)
.....
(action_tile "back_img" "(back)")
.....
(start_dialog)
.....
Always work inside a new dwg file. Work seequence is BMPINIT, BMPDRAW, BMPGENERATE.
Here is the code:
;;--------------------=={ Display Bitmap }==------------------;;
;; ;;
;; Renders the supplied ACI colour list representation of a ;;
;; Bitmap image on the DCL image tile or image_button tile ;;
;; with the given key. ;;
;;------------------------------------------------------------;;
;; Author: Lee Mac, Copyright © 2012 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
(defun DisplayBitmap ( key lst / i j s x y )
(setq s (fix (sqrt (length lst))))
(repeat
(setq i s)
(setq j 1)
(repeat s
(setq x (cons j x)
y (cons i y)
j (1+ j)
)
)
(setq i (1- i))
)
(start_image key)
(fill_image 0 0 (dimx_tile key) (dimy_tile key) -15)
(mapcar 'vector_image x y x y lst)
(end_image)
)
;hak_vz
;16.11.2020
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/dcl-button-images/td-p/9863170
(defun c:bmpinit( / lst)
(setq bitmap_size (getint "Bitmap square size 16 24 32 48 >")); this is global variable
(setvar 'CECOLOR "7")
(setvar 'cmdecho 0)
(command "rectangle" '(0 0) '(2 2))
(setq lst (entlast))
(command "-bhatch" "p" "solid" "s" lst "" "")
(entdel lst)
(command "-array" (entlast) "" "R" bitmap_size bitmap_size 2.1 2.1 )
(command "zoom" "w" '(0 0) (list (* 2.1 bitmap_size)(* 2.1 bitmap_size)))
(command "zoom" "s" 0.85x)
(setvar 'cmdecho 1)
(princ)
)
(defun c:bmpdraw ( / e *error*)
(defun *error* () (princ))
(while(setq e (car(entsel "\nSelect object to change color >")))
(cond ((and e)
(vlax-put (vlax-ename->vla-object e) 'Color (atoi(getvar 'cecolor)))
(sssetfirst nil nil)
)
)
)
(princ)
)
(defun c:bmpgenerate ( / chunks ss i clr clr_list out f file1 row erow str)
(defun transp ( m )(apply 'mapcar (cons 'list m)))
(defun chunks (lst n / sub ret)
(while lst
(while (< (length sub) n)(setq sub (cons (car lst) sub) lst (cdr lst)))
(setq ret (cons (reverse sub) ret) sub nil)
)
(reverse ret)
)
(setq ss (ssget "_W" '(0 0)(list (* 2.1 bitmap_size)(* 2.1 bitmap_size))'((0 . "HATCH"))) i 0)
(while (< i (* bitmap_size bitmap_size))
(setq clr (vlax-get (vlax-ename->vla-object (ssname ss i)) 'Color))
(if (= clr 7) (setq clr -15))
(setq clr_list (cons clr clr_list) i(+ i 1))
)
(setq
tilename (getstring "\nName of image tile > ")
f (getfiled "Output file:" (getvar "dwgprefix") "txt" 3)
out f
clr_list (reverse(transp(chunks clr_list bitmap_size)))
)
(cond
((and f)
(setq file1 (open f "w"))
(write-line (strcat "(setq " tilename) file1)
(write-line (strcat " '(") file1)
(foreach row clr_list
(setq row (mapcar 'itoa row) erow nil)
(foreach str row
(if (= (strlen str) 1) (setq erow (cons (strcat "00" str) erow)))
(if (= (strlen str) 2) (setq erow (cons (strcat "0" str) erow)))
(if (= (strlen str) 3) (setq erow (cons str erow)))
)
(setq str (car erow))
(foreach itm (cdr erow) (setq str (strcat str " " itm)))
(write-line (strcat " " str) file1)
)
(write-line " )" file1)
(write-line ")" file1)
(write-line " " file1)
(write-line " " file1)
(write-line ": image" file1)
(write-line "{" file1)
(write-line (strcat "key = \"" tilename "\";") file1)
(write-line (strcat "width = " (rtos (/ bitmap_size 6.0) 2 2) ";") file1)
(write-line "aspect_ratio = 1.0;" file1)
(write-line "fixed_width = true;" file1)
(write-line "fixed_height = true;" file1)
(write-line "color = -15;" file1)
(write-line "}" file1)
(write-line " " file1)
(close file1)
(startapp "explorer" out)
)
)
(princ)
)
(princ "\nUse commands BMPINIT, BMPDRAW and BMPGENERATE to creatre DCL bitmap image")
(princ)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.