I've created a program that opens a bit map and scans the pixels to count up the non-white pixels.
I put the initial open function inside of a try statement, but it fails to hit an error if the file I input doesn't exist. Also, this is a console app, not a GUI one. All the file checking I saw online only worked with the OpenFileDialog.
Here is the snipet of code:
Expand|Select|Wrap|Line Numbers
- Dim a As String
- For each a in args
- If Prev = "-input" then
- InpBmp = a
- End If
- 'I removed some unnecessary code here.
- Prev = a
- Next
- Try
- BitMap_Trim(InpBmp) 'this sub creates a bitmap called cropped.bmp
- b = New Bitmap(AppDomain.CurrentDomain.BaseDirectory & "cropped.bmp")
- Catch ex As Exception
- Console.WriteLine("Usage: Bitmap_Area_Calc.exe -input <bitmap name>.bmp -hor <number wide>" & Chr(10))
- Console.WriteLine(" [or -vert <number high>] -step <subarea to calc total>")
- Exit Sub
- End Try
Thanks,
Sitko.