views:

56

answers:

2

Is it possible to convert an image file to BMP format using WindowsXP's native libraries and scripting capabilities?

I'm talking about WSH, JScript, VBS, etc...
C++ is also good for what I need if it can be compiled with Dev-C++

+1  A: 

Yes, you can. Look at the Image class which is part of GDI+.

Android Eve
A: 

To convert images from scripts, you can use the WIA Automation Library. It's not strictly "native" library, but it's redistributable (refer to EULA).

Blow is a JScript example that shows how to convert an image to BMP. The original image can be PNG, GIF, JPEG or TIFF. Before running the script, register the wiaaut.dll library in the system.

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

// Load the original image
var img = new ActiveXObject("WIA.ImageFile");
img.LoadFile("D:\\MyFolder\\MyImage.gif");

switch (img.FormatID)
{
  case wiaIDUnknown:
    // Unknown image format or an invalid image file
    break;

  case wiaFormatBMP:
    // The image is already BMP
    break;

  default:
    // Specify the new format
    var ip  = new ActiveXObject("WIA.ImageProcess");
    ip.Filters.Add(ip.FilterInfos("Convert").FilterID);
    ip.Filters(1).Properties("FormatID").Value = wiaFormatBMP

    // Convert and save the image
    img = ip.Apply(img);
    img.SaveFile("D:\\MyFolder\\MyImage.bmp");
}

See also WIA documentation on MSDN.

Helen