/// <summary> /// Reads dimensions and data type of given image file. /// </summary> /// <param name="filename">Name of file to examine.</param> /// <param name="dimensions">Dimension of the image. Returns zero dimensions if the image file could not be read.</param> /// <param name="dataType">Data type of the image. Returns Unknown if the image could not be read.</param> public void GetImageInfo(string filename, out Vec3 dimensions, out ImageDataType dataType) { dimensions = new Vec3(); dataType = ImageDataType.Unknown; using (Pi2Image result = NewImage(ImageDataType.UInt32, 4)) { PiLib.RunAndCheck(Handle, $"fileinfo({filename}, {result.Name})"); dimensions.X = result.GetValue(0); dimensions.Y = result.GetValue(1); dimensions.Z = result.GetValue(2); dataType = (ImageDataType)result.GetValue(3); } }
/// <summary> /// Tests if the given file name or prefix can be used successfully in Read command. /// </summary> /// <param name="filename"></param> /// <returns></returns> public bool IsImageFile(string filename) { using (Pi2Image result = NewImage(ImageDataType.UInt8)) { PiLib.RunAndCheck(Handle, $"isimagefile({filename}, {result.Name})"); return(result.GetValue() != 0); } }