CADWarrior Posted February 19, 2013 Posted February 19, 2013 In the interest of keeping this Post as short as possible. I am trying to make a program that converts a BMP to a list of coordinates with color. ((X,Y)(R,G,B)) ((125,365)(125,255,100)) ((126,365)(125,240,101)) ((127,365)(105,230,101)) ((128,365)(125,240,101)) Ok now the issue at hand. I put the BMP into autocad and use the follow (setq image (vla-get-ImageFile (vlax-ename->vla-object (car (entsel "\nSelect Image:"))))) (setq txt (open image "r")) (setq linetxt nil) (setq count 1) (while (/= (setq line(read-line txt)) "EOF") (setq linetxt (append linetxt (list line))) ) This works fine until nth 807 which is returned as nil for some unknown reason. Line 806 in the array (nth 806 linetxt) "Dzzz''zzzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\000\000zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" (it ends before a Hexidecmal char called SUB but should continue on) Line 806 in notepad++ (actual it wont let me paste all of this line here for some reason NUL is where it stops) Dzzz''zzzzzzzyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz NUL..................More stuff about another 300 characters Line 807 in the array (nth 807 linetxt) nil Line 807 in notepad++ ^^_^^]pz^ There are about 4200 lines of code. The lisp fills the rest of the lines with nil and doesnt find the EOF so the program thinks it a never ending file and will go into a infinity loop. Any help you guys can supply would be great. Sadly I could do this in C, C++, and VB all day long just cant seem to catch a break in Vlisp Would attach the BMP but it wont let me. It says its an invalid file type. Quote
SLW210 Posted February 19, 2013 Posted February 19, 2013 BMP can be placed in a ZIP file and uploaded. Quote
CADWarrior Posted February 19, 2013 Author Posted February 19, 2013 Oh ok thanks for the heads up SLW210 attached zip file grrr.zip Quote
Lee Mac Posted February 19, 2013 Posted February 19, 2013 I recommend using the ADO Stream object to read the bitmap file as a list of byte values; this is the method I have used in the past to convert bitmap files to a list of ACI colour values for use in DCL interfaces. Quote
CADWarrior Posted February 20, 2013 Author Posted February 20, 2013 (edited) I recommend using the ADO Stream object to read the bitmap file as a list of byte values; this is the method I have used in the past to convert bitmap files to a list of ACI colour values for use in DCL interfaces. Thanks for the heads up Lee. Took me a min to figure out how to use the Stream correctly but I came up with this (vl-load-com) (setq image (vla-get-ImageFile (vlax-ename->vla-object (car (entsel "\nSelect Image:"))))) (setq stream (vlax-get-or-create-object "ADODB.stream")) (vlax-put-property stream 'type 1) (vlax-invoke stream 'open) (vlax-invoke stream 'loadfromfile image) (vlax-put-property stream 'position 0) (setq text (vlax-safearray->list (vlax-variant-value (vlax-invoke-method stream 'read (vlax-get stream 'size))))) (vlax-invoke stream 'close) (setq hexlist nil) (foreach byte text (setq hex (DecToHex (- byte 256))) (setq hexlist (append hexlist (list hex))) ) This program is slow and cumbersome can anyone think of a way to speed this up a bit? Or atleast to tell the user his system is working and it hasnt bombed yet. Right now takes about 2 sec on a 100x87 (8700 pixels) pixel bitmap...... was planning on going to 1440x900 (1,296,000 pixels) a quick estimate it would take around ((1296000/8700)*2)=~5min Edit: OK i lied takes about 7.1 sec for the 100x87 added time stamps at the start and end. Edit2: Was looking at starting larger photos but the issue is they take a while to process is there a way to know what list item the following is on? (setq text (vlax-safearray->list (vlax-variant-value (vlax-invoke-method stream 'read (vlax-get stream 'size))))) The image size is currently 1,827,038 bytes. It took 218.0710 sec I would like to show the user that its doing something Edited February 20, 2013 by CADWarrior Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.