Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

16-Bits BMP Validation

I'm developing a script using VBScript and I need to validate the input file as a 16-Bits BMP.

At the time my script is like this:

Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\16bmp.bmp" , "D:\test.bmp", OverwriteExisting

But How can I validate the input file as a 16-Bits BMP?



PS: Remember that I need this to be compatible with my site and Windows CE(I will develop a program for it using NSBasic).

like image 279
Nathan Campos Avatar asked Apr 28 '26 15:04

Nathan Campos


1 Answers

I'm not sure I got you right (English being my second language), but if you need to check if a file is a 16-bit BMP image (and not verify the actual pixels), you can make use of the Windows Image Acquisition (WIA) scripting objects. Here's an example:

Const wiaIDUnknown = "{00000000-0000-0000-0000-000000000000}"
Const wiaFormatBMP = "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"

Set oImg = CreateObject("Wia.ImageFile")

On Error Resume Next

oImg.LoadFile("C:\image.bmp")

If oImg.FormatID = wiaIDUnknown Then
  ' The file isn't an image file
Else
  Log.Message "Is BMP: " & (oImg.FormatID = wiaFormatBMP)
  Log.Message "Color depth: " & oImg.PixelDepth
End If

This script requires that you have the wiaaut.dll library installed and registered on your computer; if you don't have it, you can download it as part of the WIA SDK.

See also WIA documentation on MSDN.

like image 156
Helen Avatar answered Apr 30 '26 16:04

Helen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!