Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Get Image Size using ByteArray

Get Image Size using ByteArray

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Midnight Ahri
    wrote on last edited by
    #1

    a long long way trying to get picture file size when loaded into application, now i got something close enough. i convert image into [byte]() like this,

    Dim imgSize As [Byte]() = Nothing
    imgSize = DirectCast(Me.imgView.EditValue, Byte())
    MessageBox.Show(imgSize.GetLength(0).ToString())

    yes i have the value in byte, however the value != from the file windows properties, and yes always bigger. did i miss something or wrong way? :sigh:

    D 9 2 Replies Last reply
    0
    • M Midnight Ahri

      a long long way trying to get picture file size when loaded into application, now i got something close enough. i convert image into [byte]() like this,

      Dim imgSize As [Byte]() = Nothing
      imgSize = DirectCast(Me.imgView.EditValue, Byte())
      MessageBox.Show(imgSize.GetLength(0).ToString())

      yes i have the value in byte, however the value != from the file windows properties, and yes always bigger. did i miss something or wrong way? :sigh:

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      That depends on what you mean by "get picture file size when loaded into application". A Bitmap object will always represent an image in memory as 32-bits per pixel (R, G, B, A). Images on disk can be of varyious formats and compressions, so there is no relationship at all between the image size in memory and the file size of the image on disk.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      1 Reply Last reply
      0
      • M Midnight Ahri

        a long long way trying to get picture file size when loaded into application, now i got something close enough. i convert image into [byte]() like this,

        Dim imgSize As [Byte]() = Nothing
        imgSize = DirectCast(Me.imgView.EditValue, Byte())
        MessageBox.Show(imgSize.GetLength(0).ToString())

        yes i have the value in byte, however the value != from the file windows properties, and yes always bigger. did i miss something or wrong way? :sigh:

        9 Offline
        9 Offline
        9082365
        wrote on last edited by
        #3

        I may be missing some subtlety here but why don't you get the file size directly?

        Dim Info = My.Computer.FileSystem.GetFileInfo("filepath")
        Dim FSize = Info.Length
        Label1.Text = FSize

        M 1 Reply Last reply
        0
        • 9 9082365

          I may be missing some subtlety here but why don't you get the file size directly?

          Dim Info = My.Computer.FileSystem.GetFileInfo("filepath")
          Dim FSize = Info.Length
          Label1.Text = FSize

          M Offline
          M Offline
          Midnight Ahri
          wrote on last edited by
          #4

          hey thank you for that code, but i've just figured out that your suggestion works only for standard picturebox. however, i'm using devexpress picture edit control. this control didn't support location. :( but really, thank you very much for helping. :laugh:

          D 1 Reply Last reply
          0
          • M Midnight Ahri

            hey thank you for that code, but i've just figured out that your suggestion works only for standard picturebox. however, i'm using devexpress picture edit control. this control didn't support location. :( but really, thank you very much for helping. :laugh:

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            His code does absolutely NOTHING with a PictureBox. You're not explaining yourself very well at all so we have no idea what information you're really after or why. That makes it very difficult to help you with anything.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak

            M 1 Reply Last reply
            0
            • D Dave Kreskowiak

              His code does absolutely NOTHING with a PictureBox. You're not explaining yourself very well at all so we have no idea what information you're really after or why. That makes it very difficult to help you with anything.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              M Offline
              M Offline
              Midnight Ahri
              wrote on last edited by
              #6

              actually i'm asking why when i convert an image into byte array and get the length, i gain byte size of the image, but the size always bigger than the real image 10-50KB. you are right about compression dave, thank you. :laugh:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups