Author Topic: dcl_PictureBox_LoadPictureFile no longer shows images  (Read 1170 times)

Ingo P

  • Member
  • *
  • Posts: 9
    • darkeldar.de
dcl_PictureBox_LoadPictureFile no longer shows images
« on: November 27, 2012, 10:22:41 AM »
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:
  1. (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 )
  2.   (dcl_Control_SetValue BitmapAuswahl_BitmapBrowser_sliderBitmapBrowse x:bitmapwahl_selected)
  3.   (setq p-3 (car (nth (p:rem+ (- x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  4.         p-2 (car (nth (p:rem+ (- x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  5.         p-1 (car (nth (p:rem+ (- x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  6.         p0  (car (nth (p:rem+ (+ x:bitmapwahl_selected 0) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  7.         p+1 (car (nth (p:rem+ (+ x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  8.         p+2 (car (nth (p:rem+ (+ x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  9.         p+3 (car (nth (p:rem+ (+ x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs)))
  10.   (setq s-3 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  11.         s-2 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  12.         s-1 (cadddr (nth (p:rem+ (- x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  13.         s0  (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 0) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  14.         s+1 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 1) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  15.         s+2 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 2) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs))
  16.         s+3 (cadddr (nth (p:rem+ (+ x:bitmapwahl_selected 3) (length x:bitmapwahl_kv_pairs)) x:bitmapwahl_kv_pairs)))
  17.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_imgMainImage p0 'T)
  18.   (cond (s0
  19.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgMainImage (car s0))
  20.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgMainImage (cadr s0)))
  21.         ('T
  22.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgMainImage "")
  23.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgMainImage "")
  24.          ))
  25.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img-2 p-2 'T)
  26.   (cond (s-2
  27.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-2 (car s-2))
  28.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-2 (cadr s-2)))
  29.         ('T
  30.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-2 "")
  31.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-2 "")
  32.          ))
  33.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img-1 p-1 'T)
  34.   (cond (s-1
  35.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-1 (car s-1))
  36.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-1 (cadr s-1)))
  37.         ('T
  38.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img-1 "")
  39.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img-1 "")
  40.          ))
  41.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_imgSelected p0 'T)
  42.   (cond (s0
  43.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgSelected (car s0))
  44.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgSelected (cadr s0)))
  45.         ('T
  46.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_imgSelected "")
  47.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_imgSelected "")
  48.          ))
  49.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img+1 p+1 'T)
  50.   (cond (s+1
  51.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+1 (car s+1))
  52.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+1 (cadr s+1)))
  53.         ('T
  54.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+1 "")
  55.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+1 "")
  56.          ))
  57.   (dcl_PictureBox_LoadPictureFile BitmapAuswahl_BitmapBrowser_img+2 p+2 'T)
  58.   (cond (s+2
  59.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+2 (car s+2))
  60.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+2 (cadr s+2)))
  61.         ('T
  62.          (dcl_Control_SetToolTipTitle BitmapAuswahl_BitmapBrowser_img+2 "")
  63.          (dcl_Control_SetToolTipMainText BitmapAuswahl_BitmapBrowser_img+2 "")
  64.          ))
  65.   )
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
  1. (list
  2. (list "01.png" "01" "hlp_01" (list "Typ 1" ""))
  3. (list "02.png" "02" "hlp_02" (list "Typ 2" ""))
  4. (list "03.png" "03" "hlp_03" (list "Typ 3" ""))
  5. (list "04.png" "04" "hlp_04" (list "Typ 4" ""))
  6. (list "05.png" "05" "hlp_05" (list "Typ 5" ""))
  7. )

Functions not included in source
  1. (defun p:dcl_Project_Load (pname / s)
  2.   (if (setq s (findfile (strcat pname ".odcl")))
  3.     (dcl_Project_Load s); 'T)
  4.     'nil)
  5. )
  6.  
  7. (defun p:zei (s / ) (princ)) ; opens application help file on selected topic
  8.  
  9. (DEFUN p:GET-ACAD-WINDOW (Pos / app w h x y) ; Based on http://www.opendcl.com/forum/index.php?topic=952.msg4779#msg4779
  10.    (COND ((MEMBER Pos '(0 1 2 3 4 5 6 7 8 9)) ; achk
  11.           (SETQ app (VLAX-GET-ACAD-OBJECT)
  12.                 w   (VLA-GET-WIDTH app)
  13.                 h   (VLA-GET-HEIGHT app)
  14.                 x   (VLA-GET-WINDOWLEFT app)
  15.                 y   (VLA-GET-WINDOWTOP app)
  16.           )
  17.           (COND ((= Pos 0) (LIST w h))
  18.                 ((= Pos 1) (LIST x y))
  19.                 ((= Pos 2) (LIST x (+ y (/ h 2))))
  20.                 ((= Pos 3) (LIST x (+ y h)))
  21.                 ((= Pos 4) (LIST (+ x (/ w 2)) y))
  22.                 ((= Pos 5) (LIST (+ x (/ w 2)) (+ y (/ h 2))))
  23.                 ((= Pos 6) (LIST (+ x (/ w 2)) (+ y h)))
  24.                 ((= Pos 7) (LIST (+ x w) y))
  25.                 ((= Pos 8) (LIST (+ x w) (+ y (/ h 2))))
  26.                 ((= Pos 9) (LIST (+ x w) (+ y h)))
  27.                 ('T 'NIL)
  28.           )
  29.          )
  30.    )
  31. )
  32. ;**********************************************************
  33. (defun p:dcl_Form_Center (form / p x y)
  34.   (cond (form
  35.          (setq x (dcl_control_getwidth form)
  36.                y (dcl_control_getheight form)
  37.                p (p:GET-ACAD-WINDOW 5)
  38.                x (- (car  p) (* 0.5 x))
  39.                y (- (cadr p) (* 0.5 y)))
  40.          (dcl_Control_SetPos form x y)
  41.          ))
  42. )
  43.  
  44.  
Attached:
Dialog working
Dialog broken
Full code (missing functions should all be in code above)
odcl-file
« Last Edit: November 27, 2012, 10:26:26 AM by Ingo P »

roy_043

  • Full Member
  • ***
  • Posts: 155
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #1 on: November 29, 2012, 02:48:02 AM »
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

  • Member
  • *
  • Posts: 9
    • darkeldar.de
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #2 on: November 29, 2012, 04:44:08 AM »
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

  • Full Member
  • ***
  • Posts: 155
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #3 on: November 30, 2012, 05:16:43 AM »
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.
« Last Edit: November 30, 2012, 07:45:36 AM by roy_043 »

roy_043

  • Full Member
  • ***
  • Posts: 155
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #4 on: November 30, 2012, 07:43:31 AM »
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

  • Member
  • *
  • Posts: 9
    • darkeldar.de
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #5 on: December 03, 2012, 03:04:41 AM »
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

  • Administrator
  • Hero Member
  • *****
  • Posts: 2463
    • Outside The Box
Re: dcl_PictureBox_LoadPictureFile no longer shows images
« Reply #6 on: December 05, 2012, 06:56:34 PM »
I am not able to reproduce the problem. I've added a comment to your bug report with additional information and followups.