Results 1 to 5 of 5

Thread: How to get the picture size!

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55

    How to get the picture size!

    I want to use VB to get a picture size(height and width)?
    I don't wanna use the image control or the other control.I only want to use code.thanks advance!

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    Assuming you have access to the bitmap handle...
    VB Code:
    1. Type Size
    2.         cx As Long
    3.         cy As Long
    4. End Type
    5.  
    6. Declare Function GetBitmapDimensionEx Lib "gdi32" Alias "GetBitmapDimensionEx" (ByVal hBitmap As Long, lpDimension As SIZE) As Long

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55
    Thanks!!!!
    but if my picture is .jpg or .gif,can I use it in this format?

  4. #4
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148
    Once a gif or jpg is selected into a device context (i.e. displayed on the screen) it is converted to a bitmap by GDI and you can use the aforementioned API call againts it's handle.
    If you want to get the dimensions from the file without displaying it you will need to interogate the file format....I'm afraid I do no t know the format for jpg or gif images, but it'll be documented on the net somewhere.

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2002
    Posts
    55
    thank u very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width