dev
August 20th, 2001, 02:00 AM
How do I get the size of the picture or image that I have loaded onto the Picture Box, in bytes. Could you provide me with the functions or source code in VB?
Thank you.
dev.
Thank you.
dev.
|
Click to See Complete Forum and Search --> : Image size in the Picture Box? dev August 20th, 2001, 02:00 AM How do I get the size of the picture or image that I have loaded onto the Picture Box, in bytes. Could you provide me with the functions or source code in VB? Thank you. dev. Isaacson August 20th, 2001, 03:47 PM Try this extra-cheesy code to get Bitmap size: Remember to repalce "Picture.BMP" with a valid file name ' from MSDN private Type BITMAPINFOHEADER '40 bytes biSize as Long ' not the image size biWidth as Long biHeight as Long biPlanes as Integer biBitCount as Integer ' 2 ^ InfoHeader.biBitCount = Bits per Pixel biCompression as Long ' 0=none, 1=RLE8, 2=RLE4, 3=BitFields biSizeImage as Long ' # of bytes for image, not the file size , not all 'graphics programs fill this in properly is 1K = 1000 OR = 1024 ' try this: it should be close ' (InfoHeader.biBitCount / 8) * InfoHeader.biWidth * InfoHeader.biHeight biXPelsPerMeter as Long biYPelsPerMeter as Long biClrUsed as Long ' colors used in this image biClrImportant as Long ' colors important to this image End Type private Type BITMAPFILEHEADER bfType as Integer bfSize as Long bfReserved1 as Integer bfReserved2 as Integer bfOhFileBits as Long End Type ' replace "Picture.BMP" with common dialog or some valid name aFile = FreeFile Open "Picture.BMP" for binary Access Read as #aFile get #aFile, , FileHeader get #aFile, , InfoHeader Close #aFile MsgBox "This image is :" & vbCrLf & _ InfoHeader.biHeight & " Pixels High" & vbCrLf & _ InfoHeader.biWidth & " Pixels Wide" & vbCrLf & _ InfoHeader.biSizeImage & " Bytes (header)" & vbCrLf & _ (InfoHeader.biBitCount / 8) * InfoHeader.biWidth * InfoHeader.biHeight & _ " Bytes (calculated)" codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |