how to display bmp images in autolisp?

how to display bmp images in autolisp?

pemattosarq
Explorer Explorer
253 Views
2 Replies
Message 1 of 3

how to display bmp images in autolisp?

pemattosarq
Explorer
Explorer

I'm creating a menu via Autolisp, where the user can choose the line color and background color of the hatch, and I'm using sld images to display these "colors", however AutoCAD transforms RGB MSlide colors into ACI. Is it possible to use .bmp images? I'm trying but it doesn't appear. Could someone make a simple script showing how to display a .bmp image in a menu via Autolisp?

 

in the image you can see that color 4 appears as gray in the menu;

 

 

Screenshot_1.png

0 Likes
254 Views
2 Replies
Replies (2)
Message 2 of 3

paullimapa
Mentor
Mentor

Unfortunately, image files like bitmaps (bmp) are NOT supported but only vector or slide (sld) files are supported in dcl image & image button tiles.

Perhaps you can utilize the built-in Autolisp function acad_truecolordlg to open a a color selection window and then you can pass that result back to your code:

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-E6FF435F-9E66-4F37-8770-2E3FB87B8E0B

(setq col (acad_truecolordlg '(62 . 7)))

 The above line of code will bring up the following color selection window:

paullimapa_0-1755840513170.png

If an AutoCAD Color Index (0 to 256) is selected like Magenta which is Color 6:

paullimapa_2-1755840812883.png

AutoCAD returns a list containing a single item: ((62 . 6))

Use the following to get the AutoCAD Color Index:

(cdr (car col))

AutoCAD returns: 6

If a True Color selection is made:

paullimapa_1-1755840697336.png

AutoCAD returns a list containing two items: ((62 . 112) (420 . 3329361))

You'll need to convert the 420 pair color number to RGB by using something like Lee Mac's LM:OLE->RGB conversion function:

https://www.lee-mac.com/colourconversion.html

;; OLE -> RGB  -  Lee Mac
;; Args: c - [int] OLE Colour

(defun LM:OLE->RGB ( c )
    (mapcar '(lambda ( x ) (lsh (lsh (fix c) x) -24)) '(24 16 8))
)

The following line of code coverts col to RGB:

(setq rgb (reverse (LM:OLE->RGB (cdr (cadr col)))))

AutoCAD returns: (50 205 81)


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 3

Sea-Haven
Mentor
Mentor

Your already using a custom dcl to show the hatch patterns, which I take it are Slides, the make the color question slides as well, just set your Solid hatch to correct color and make a sld, not tested very much. Just made a couple of slides and used vslide.

0 Likes