Announcement

Collapse
No announcement yet.

Loading and displaying images...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Loading and displaying images...

    Hi,

    I'm having some difficulty persuading a bitmap image to display in a window created using DDT.

    The image is on file - my app. is such that I'll need to change the image at run time, so I can't put it into a resource file.
    So I can't use DDT's CONTROL ADD IMAGE statement... or can I? If I could use that, then change the image in the control to one from a .bmp file, that would be ideal.
    Otherwise, does anyone have any source they could share showing how to put an image from a file onto a DDT dialog?

    (The images I'll eventually be using are JPEGs of around 1200x800 pixels, which I'll want to display a thumbnail of width about 150 dialog units. At this point I'm trying to walk before I can run, and I have a bitmap image of 634x427 pixels as a test file. If I can get that to display, I'll be able to tackle the IJL library.)


    Thanks,

    Dan.
    Dan

  • #2
    The initial image needs to come from a resource file, but you can use CONTROL SET IMAGE(X) to change the image to one subsequently loaded from a disk file. Use CONTROL SEND... %STM_SETIMAGE to change the image at runtime.

    Note that DDT does not release the previous image handle, so you may explicitly release it or you'll cause a memory leak:
    Code:
    CONTROL SEND CBHNDL, Id&, %STM_GETIMAGE, %IMAGE_BITMAP, 0 TO hBmp&
    CONTROL SET IMAGE hDlg&, Id&, NewImage$ ' example uses ID from resource file.
    DeleteObject hBmp&

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      One more point... if this image is for the background, then be sure to check out the SMTP.BAS example supplied with PB/DLL.

      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected]basic.com[email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        I saw the SMTP example, but I'm not looking for a background image so that wasn't really applicable, nor (as I discovered) was it readily adaptable.

        I'll have a play with CONTROL SET IMAGEX and CONTROL SEND tomorrow...

        Thanks!

        ------------------
        --Dan
        Dan

        Comment

        Working...
        X