Get Image Size using ByteArray
-
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:
-
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:
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 -
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:
-
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 = FSizehey 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:
-
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:
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 -
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 Kreskowiakactually 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: