dcl_PictureBox_LoadPictureFile no longer shows images

Started by Ingo P, November 27, 2012, 09:22:41 AM

Previous topic - Next topic

Ingo P

Hi

I'm having trouble with a little application i wrote.
It's a small dialog, that lets you browse by images a return a value to lisp associated with that image.
After a few calls to the dialog and each time paging through the images the dialog stops showing the images.

However the browsing itself still works (Return-Value and Tooltip are shown)

Does anybody have an idea to solve this issue?

Edit 1:
ODCL-Runtime in use is 7.0.0.9 an AutoCAD 2012 Architecture (D A CH)
Other CAD-Systems will be tested tomorrow, but testing an older runtime is not possible/desired since the application has to run on AutoCAD 2013 and BricsCAD V13.


Paging-function:
Code (autolisp) Select
(defun p:BitmapAuswahl_BitmapBrowser_update (/ p-3 p-2 p-1 p0 p+1 p+2 p+3 s-3 s-2 s-1 s0 s+1 s+2 s+3 )
  (dcl_Control_SetValue BitmapAuswahl_BitmapBrowser_sliderBitmapBrowse x:bitmapwahl_selected)
  (setq p-3 (car (nth (p:rem+ (- x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p-2 (car (nth (p:rem+ (- x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p-1 (car (nth (p:rem+ (- x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p0  (car (nth (p:rem+ (+ x:bitmapwahl_selected 0) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p+1 (car (nth (p:rem+ (+ x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p+2 (car (nth (p:rem+ (+ x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
p+3 (car (nth (p:rem+ (+ x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs)))
  (setq s-3 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s-2 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s-1 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s0  (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 0) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s+1 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s+2 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
s+3 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs)))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_imgMainImage p0 'T)
  (cond (s0
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgMainImage (car s0))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgMainImage (cadr s0)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgMainImage "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgMainImage "")
))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img-2 p-2 'T)
  (cond (s-2
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-2 (car s-2))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-2 (cadr s-2)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-2 "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-2 "")
))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img-1 p-1 'T)
  (cond (s-1
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-1 (car s-1))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-1 (cadr s-1)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-1 "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-1 "")
))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_imgSelected p0 'T)
  (cond (s0
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgSelected (car s0))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgSelected (cadr s0)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgSelected "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgSelected "")
))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img+1 p+1 'T)
  (cond (s+1
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+1 (car s+1))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+1 (cadr s+1)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+1 "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+1 "")
))
  (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img+2 p+2 'T)
  (cond (s+2
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+2 (car s+2))
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+2 (cadr s+2)))
('T
(dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+2 "")
(dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+2 "")
))
  )

x:bitmapwahl_selected is a list of lists containig the image file name, return value, help string (for use in help calls) and a list of strings containig the tooltip headline and text
Code (autolisp) Select
(list
(list "01.png" "01" "hlp_01" (list "Typ 1" ""))
(list "02.png" "02" "hlp_02" (list "Typ 2" ""))
(list "03.png" "03" "hlp_03" (list "Typ 3" ""))
(list "04.png" "04" "hlp_04" (list "Typ 4" ""))
(list "05.png" "05" "hlp_05" (list "Typ 5" ""))
)


Functions not included in source
Code (autolisp) Select

(defun p:dcl_Project_Load (pname / s)
  (if (setq s (findfile (strcat pname ".odcl")))
    (dcl_Project_Load s); 'T)
    'nil)
)

(defun p:zei (s / ) (princ)) ; opens application help file on selected topic

(DEFUN p:GET-ACAD-WINDOW (Pos / app w h x y) ; Based on http://www.opendcl.com/forum/index.php?topic=952.msg4779#msg4779
   (COND ((MEMBER Pos '(0 1 2 3 4 5 6 7 8 9)) ; achk
          (SETQ app (VLAX-GET-ACAD-OBJECT)
                w   (VLA-GET-WIDTH app)
                h   (VLA-GET-HEIGHT app)
                x   (VLA-GET-WINDOWLEFT app)
                y   (VLA-GET-WINDOWTOP app)
          )
          (COND ((= Pos 0) (LIST w h))
                ((= Pos 1) (LIST x y))
                ((= Pos 2) (LIST x (+ y (/ h 2))))
                ((= Pos 3) (LIST x (+ y h)))
                ((= Pos 4) (LIST (+ x (/ w 2)) y))
                ((= Pos 5) (LIST (+ x (/ w 2)) (+ y (/ h 2))))
                ((= Pos 6) (LIST (+ x (/ w 2)) (+ y h)))
                ((= Pos 7) (LIST (+ x w) y))
                ((= Pos 8) (LIST (+ x w) (+ y (/ h 2))))
                ((= Pos 9) (LIST (+ x w) (+ y h)))
                ('T 'NIL)
          )
         )
   )
)
;**********************************************************
(defun p:dcl_Form_Center (form / p x y)
  (cond (form
         (setq x (dcl_control_getwidth form)
               y (dcl_control_getheight form)
               p (p:GET-ACAD-WINDOW 5)
               x (- (car  p) (* 0.5 x))
               y (- (cadr p) (* 0.5 y)))
         (dcl_Control_SetPos form x y)
         ))
)


Attached:
Dialog working
Dialog broken
Full code (missing functions should all be in code above)
odcl-file

roy_043

Dear Ingo,

Your example is a bit complex, some functions are still missing and you haven't supplied any images. This makes it hard for others to test and debug your problem. I have gone ahead and created a much smaller example. I haven't been able to reproduce your problem, but I am not using AC...

Try if you have the same issues with my example.

Regards, Roy.

My configuration:
Windows XP
Bricscad 13.1.11
ODCL 7.0.0.9

Instructions:
- Put all files from the zip in a single folder.
- Open a dwg in that folder.
- Load the lsp.
- Type BITMAPTEST to run the test function.
- Use the Next button to cycle through the images.



Ingo P

My brain near end of working hours...

I have tried your sample and it works fine.
Mine however still does have its bogus.

Attached is a reduced and semi-automated version
Just like yours there just has to be a drawing in the folder and the program "BitmapTest" must be called.

After several full rotations only white image fields are shown.

Regards Ingo

Configuration used to test:
Windows 7 32bit
OpenDCL 7.0.0.9
AutoCAD 2012 Architecture (D A CH)   &    BricsCAD 13.1.11

roy_043

#3
Ingo, if I use my code with some of your images I can reproduce your problem. This suggests that the problem is perhaps caused by the image files. I've tried reducing the color depth of your images, but that does not solve the problem.

Instructions:
- Put all files from the zip in a single folder.
- Open a dwg in that folder.
- Load the lsp.
- Type BITMAPTEST1, BITMAPTEST2 or BITMAPTEST3 to run one of the test functions.
- Use the Auto button to cycle through the images (100 times a different image will be shown).

Results:

Note: restart the CAD-program before each test!

BITMAPTEST1
- Uses my very small png files.
- Memory consumption before loading the lsp: 120.000kB
- The sequence is shown correctly.
- Memory consumption after running the lsp: 137.000kB

BITMAPTEST2
- Uses Ingo's large png files.
- Memory consumption before loading the lsp: 120.000kB
- The sequence stops displaying when the counter hits ca. 40.
- Memory consumption after running the lsp: 144.000kB

BITMAPTEST3
- Uses Ingo's png files with a reduced color depth.
- Memory consumption before loading the lsp: 120.000kB
- The sequence stops displaying when the counter hits ca. 40.
- Memory consumption after running the lsp: 139.000kB

Edit: removed attachment. Use BitmapTest3.zip from my next post.

roy_043

If I turn your png-files into bmp-files the problem does not occur. This supports my assumption that the png-files cause the problem. The disadvantage of bmp-files is that there is no compression. This means that one of your 70kB png-files will become a 2404kB bmp-file unless you reduce the color depth. ODCL does not support the JPEG-format, I don't know if any of the other supported image formats has a form of compression.

BITMAPTEST2A
- Uses Ingo's large png-files converted to bmp-files.
- Memory consumption before loading the lsp: 112.000kB
- The sequence is shown correctly, but there appears to be a gradual slowing down.
- Memory consumption after running the lsp: 52.000kB

Ingo P

I don't know how to thank you roy.

I tried nearly every change of the images but not converting them back to BMP.

For now we will change all the images to BMP and switch the search order from PNG>BMP to BMP>PNG.
The size is quite an issue, but not that big because we deliver as ZIP and BMP becomes nearly as small as PNG in ZIP.

I think I will open a ticket for bugfix/feature to officially report this bug.

If you should come to the area Frankfurt/Heidelberg in Germany give me a note and i will invite you to a coffee or so.

Regards
Ingo

owenwengerd

I am not able to reproduce the problem. I've added a comment to your bug report with additional information and followups.
Owen Wengerd (Outside The Box) / ManuSoft