本帖最后由 baitang36 于 2022-6-14 15:47 编辑
下面函数c:tt的作用是画一个图片,把tt.txt中的像素数据画到坐标0,0处。
现有程序大约需要十几秒时间,有时间玩的朋友优化一下,看看谁的程序最快。
像素数据是用高飞鸟的工具提取的。
- (defun c:tt(/ pt r x lst x1 x2)
- (setq f (open "c:/00/tt.txt" "R")))
- (setq t0 (getvar "TDUSRTIMER" ) )
- (while (setq s (read-line f))
- (setq k (read s))
- (if (and k (= (type k) (quote LIST)) (= (length k) 6))
- (progn
- (setq x (car k)
- y (cadr k)
- r (caddr k)
- g (cadddr k)
- b (car (cddddr k))
- c (lm:rgb->true r g b)
- )
- (entmake
- (list
- (cons 0 "LWPOLYLINE")
- (cons 100 "AcDbEntity")
- (cons 100 "AcDbPolyline")
- (cons 8 "Image2PL")
- (cons 90 2)
- (cons 43 1.0)
- (cons 420 c)
- (cons 10 (list x y))
- (cons 10 (list (1+ x) y))
- )))
- (close f)
- (princ "\n程序共用时" )
- (princ (* (- (getvar "TDUSRTIMER" ) t0 ) 86400 ) )
- (princ "秒" )
- (princ)
- )
- (defun LM:RGB->True ( r g b )
- (+
- (lsh (fix r) 16)
- (lsh (fix g) 8)
- (fix b)
- )
- )
|