|
-
Mar 30th, 2007, 01:18 AM
#1
Thread Starter
Member
How to read Dimension of .bmp file ??
Hey guys...
I have got a project which involves reading the dimensions (in pixels) of bitmap files.. i need to find the dim and then copy it to a template excel file..
I am not able to find a way to get the dimensions.. please advice
i am using Visual Studio 2005..
cheers
Abhilash
-
Mar 30th, 2007, 01:53 AM
#2
Lively Member
Re: How to read Dimension of .bmp file ??
set picture box autosize = true and scalemode = 3 means pixels
then simply after loading image in picture box u can use scale width and scale heghit for dim
-
Mar 30th, 2007, 01:57 AM
#3
Thread Starter
Member
Re: How to read Dimension of .bmp file ??
hey..
thx for your reply..
actually i donot need to view the picture... because i will be accepting a folder full of images and hav to read each of their dimensions and write onto excel. is there a way to just read the dimension in pixels off the .bmp file without opening it.
thx
Abhilash
-
Mar 30th, 2007, 02:12 AM
#4
Lively Member
Re: How to read Dimension of .bmp file ??
just set visible = false and progamically load each image in picture and calculate its dimension and then load 2nd iimage and so on
-
Mar 30th, 2007, 02:30 AM
#5
Thread Starter
Member
Re: How to read Dimension of .bmp file ??
hey...
thx for the info.. i understand wad u mean...
but i am new to vb programming... can u please gimme the code for this function... i will be extremely grateful if u can help me out..
i know how to accept the folder from the user and get the filenames (imagenames)... could you gimme the rest of the code.. ie. loading the image and calculating the dimensions and storing them in a variable...
thx a lot
abhilash
-
Mar 30th, 2007, 03:17 AM
#6
Re: How to read Dimension of .bmp file ??
If you don't want to load the picture into a picturebox, you can use the following code:
vb Code:
Option Explicit
Private Type BITMAPFILEHEADER
bfType(1) As Byte
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Sub GetBitmapSize(ByVal Bitmap As String, ByRef lWidth As Long, ByRef lHeight As Long)
Dim hFile As Integer
Dim bfh As BITMAPFILEHEADER
Dim bih As BITMAPINFOHEADER
hFile = FreeFile
Open Bitmap For Binary Access Read Shared As #hFile
Get #hFile, , bfh
Get #hFile, , bih
Close #hFile
lWidth = bih.biWidth
lHeight = bih.biHeight
End Sub
Private Sub Command1_Click()
Dim lngWidth As Long
Dim lngHeight As Long
Call GetBitmapSize("c:\windows\zapotec.bmp", lngWidth, lngHeight)
MsgBox "Width: " & lngWidth & vbCrLf & "Height: " & lngHeight
End Sub
Last edited by Frans C; Mar 30th, 2007 at 03:23 AM.
Frans
-
Mar 30th, 2007, 03:29 AM
#7
Re: How to read Dimension of .bmp file ??
Please do not make duplicate threads.
Original thread in VB.NET forum:
http://vbforums.com/showthread.php?t=460571
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Mar 30th, 2007, 03:47 AM
#8
Thread Starter
Member
Re: How to read Dimension of .bmp file ??
Hey Frans
thx a lot for your help
cheers
Abhilash
-
Mar 30th, 2007, 04:00 AM
#9
Thread Starter
Member
Re: How to read Dimension of .bmp file ??
Hey Frans!!
looks like you gave me a code for VB 6.. i am using VB 2005.. sori to bother you but this code doesnt seem to work on vb 2005... please help..
thx
abhilash
-
Mar 30th, 2007, 04:02 AM
#10
Re: How to read Dimension of .bmp file ??
This is exactly why you should not make multiple threads in different forums.
For the rest of the replies on the topic please see the vb.net thread of his I linked to in post #7.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|