Announcement

Collapse
No announcement yet.

imagex

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

  • imagex

    Hi, I try to find more information on imagex, according the online manual,
    CONTROL SET IMAGEX hDlg, id&, newimage$
    after you use
    CONTROL ADD IMAGEX, hDlg, id&, image$, x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback]
    I read about bitmap and icon select.
    %SS_BITMAP
    Display only bitmap images. Also see %SS_ICON. (persistent)
    %SS_ICON
    Display only icon images. Also see %SS_ICON. (persistent)
    ((or you may choose not to specify the image format at all.))
    I got wrong that suggest it support other format.
    -------------------------------------
    Now I'm lost
    The only explanation is load bitmap
    I can't see the joint but if I ask bmp that the only thing show.
    ( I try gif or jpeg in the PB forum and FF forum with no real result )
    nFile& = FREEFILE
    OPEN "myimage.bmp" FOR BINARY AS nFile&
    GET #nFile&, 19, nWidth&
    GET #nFile&, 23, nHeight&
    CLOSE nFile&
    The real question I can"t find no demo or source or documentation.
    IF PB support (gif,tiff,jpeg,png or gig animated) seem only bmp.
    The EZGUI seem more advence in documentation said support gif
    with no documentation.
    In real basic the image is very close to html form like src img.
    we load the file to define windows like control add imagex.
    If you find some info how load and use imagex with format file support.

    one more question.
    many programmer use this variable ( lRslt ) What is the real definition.
    Thanks:wavey:





  • #2
    If you want to use image types other than BMP you will have to load them using a suitable library such as GDIPlus. There are plenty of examples here, this one might be useful to you, good luck!

    Comment


    • #3
      Originally posted by Robert Duham View Post
      one more question.
      many programmer use this variable ( lRslt ) What is the real definition.
      Thanks:wavey:
      Long Result. The result of a function stored in a Long (32 BIT integer) variable.

      Comment


      • #4

        can't see the joint but if I ask bmp that the only thing show.
        ( I try gif or jpeg in the PB forum and FF forum with no real result )
        Code:
         nFile& = FREEFILE
         OPEN "myimage.bmp" FOR BINARY AS nFile&
         GET #nFile&, 19, nWidth&
         GET #nFile&, 23, nHeight&
         CLOSE nFile&
        The real question I can"t find no demo or source or documentation
        The reason this code is not too easy to figure out is because it is written using "magic numbers". Had it been written without magic numbers, you could see what it is doing. Let's see if we can do that.

        First, let's look at the way bitmap files are stored on disk:
        Bitmaps should be saved in a file that uses the established bitmap file format and assigned a name with the three-character .bmp extension. The established bitmap file format consists of a BITMAPFILEHEADER structure followed by a BITMAPINFOHEADER, BITMAPV4HEADER, or BITMAPV5HEADER structure
        If we translate that into user defined types representing the start of a file we get...
        Code:
        UNION BITMAPUNION
          BMIH  AS BITMAPINFOHEADER
          BMV4H AS BITMAPV4HEADER
          BMV5H As BITMAPV5HEADER
        END UNION
        
        TYPE BITMAPSTARTOFFILE
         BMFH  AS BITMAPFILEHEADER  ' size = 14 
         BMU   AS BITMAPUNION
        END TYPE
        The three members of BITMAPUNION as well as the BITMAPFILEHEADER are defined in your Win32API.INC file.

        But that is a lot more complex than we need for these purposes.

        When you inspect the three UNION members, you find in all cases the width and height of the bitmap are located at offsets 4 and 8 respectively of the BITMAPINFOHEADER, BITMAPv4HEADER or BITMAPV5HEADER; which, when you add the 14 bytes for the BITMAPFILEHEADER, puts the width and height at offsets 18 and 22.. which correspond to 'positions' 19 and 23 (the 'magic numbers!') when the file is opened for BINARY with the default BASE of 1.

        Since we don't really need all the info from the UNION, we can simplify the type we use for the start of the file...
        Code:
        TYPE BITMAPSTARTOFFILE
          BMIH    AS BITMAPINFOHEADER
          Unused  AS LONG     '  actually structure size, but we don't need that. 
          nWidth  AS LONG
          nHeight AS LONG 
        END TYPE
        So a little better - that is, more understandable - code might read...

        Code:
           LOCAL BMSOF AS BITMAPSTARTOFILE   ' the simple version above 
        
        
           nFile& = FREEFILE
           OPEN     "myimage.bmp" FOR BINARY AS nFile&
           GEt       #nFile, , BMSOF          '  read the data at start of file
           CLOSE     nFile&                    ' done with file, close it 
           ' get our values from the file data in BMSOF:
           nWidth&  =   BMSOF.nWidth
           nHeight& =   BMSOF.nHeight
        Does that make it a bit more clear what that "magic number" code is doing?


        FWIw, I think I'd create a "Write once, use many" FUNCTION or SUB for this

        Code:
        FUNCTION GetBitmapWidthandHeightFromFile (szBmpFile AS ASIICZ, nWidth  as Long, nHeight As LONG) AS LONG
        
           LOCAL BMSOF AS BITMAPSTARTOFILE   ' the simple version above 
           LOCAL nFile AS LONG, fv AS LONG
        
           ON ERROR RESUME NEXT 
        
           nFile   = FREEFILE
           OPEN     "myimage.bmp" FOR BINARY AS nFile&
           IF ISFALSE ERR THEN 
              GET      #nFile, , BMSOF          '  read the data at start of file
              CLOSE     nFile                    ' done with file, close it 
              nWidth =   BMSOF.nWidth
              nHeight =   BMSOF.nHeight
              fv =        0                 ' success!
           ELSE
              fv = ERRCLEAR                 ' assign and reset 
           END IF
        
           FUNCTION = fv 
        
        END FUNCTION
        
          CALL GetBitmapWidthAndHeightFromFile ("myimage.bmp", nWidth, nHeight) to lresult
        
          IF ISFALSE lresult THEN 
             we got the width and height OK, do cool stuff
          ELSE
             MSGBOX USING$("Error getting Bitmap width and height # &", lResult, ERROR$(lresult)), %MB_ICONHAND, "Bitmap file access error" 
          .....
        MCM
        Michael Mattias
        Tal Systems Inc. (retired)
        Racine WI USA
        [email protected]
        http://www.talsystems.com

        Comment

        Working...
        X