public void EnumFieldsTest() { IsoSpeedEnum iso = IsoSpeedEnum.iso640; ApertureEnum aperture = ApertureEnum.f72; ExposalEnum exposal = ExposalEnum.t6; ImageQualityEnum imageQuality = ImageQualityEnum.PPT_sRAW1; ConfigureMockCamera(null, null, null, new IsoSpeedEnum[] { }, new ApertureEnum[] { }, new ExposalEnum[] { }, new ImageQualityEnum[] { }, iso, aperture, exposal, imageQuality); CameraInfo cameraInfo = new CameraInfo(_camera); Assert.AreEqual(IsoSpeed.With(iso), cameraInfo.CurrentIsoSpeed); Assert.AreEqual(Aperture.With(aperture), cameraInfo.CurrentAperture); Assert.AreEqual(Exposal.With(exposal), cameraInfo.CurrentExposal); Assert.AreEqual(ImageQuality.With(imageQuality), cameraInfo.CurrentImageQuality); _mockery.VerifyAllExpectationsHaveBeenMet(); }
private void ConfigureMockCamera(string aCameraId, string aProductName, string anOwnerName, IsoSpeedEnum[] anIsoSpeeds, ApertureEnum[] anApertures, ExposalEnum[] anExposals, ImageQualityEnum[] anImageQualities, IsoSpeedEnum anIsoSpeed, ApertureEnum anAperture, ExposalEnum anExposal, ImageQualityEnum anImageQuality) { Expect.Once.On(_camera).GetProperty("Id").Will(Return.Value(aCameraId)); Expect.Once.On(_camera).GetProperty("ProductName").Will(Return.Value(aProductName)); Expect.Once.On(_camera).GetProperty("OwnerName").Will(Return.Value(anOwnerName)); Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDKLib.EDSDK.PropID_ISOSpeed).Will(Return.Value(anIsoSpeeds)); Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDKLib.EDSDK.PropID_Av).Will(Return.Value(anApertures)); Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDKLib.EDSDK.PropID_Tv).Will(Return.Value(anExposals)); Expect.Once.On(_camera).Method("GetAvailableValues").With(EDSDKLib.EDSDK.PropID_ImageQuality).Will(Return.Value(anImageQualities)); Expect.Once.On(_camera).GetProperty("IsoSpeed").Will(Return.Value((int)anIsoSpeed)); Expect.Once.On(_camera).GetProperty("ApertureValue").Will(Return.Value((int)anAperture)); Expect.Once.On(_camera).GetProperty("ExposalValue").Will(Return.Value((int)anExposal)); Expect.Once.On(_camera).GetProperty("ImageQualityValue").Will(Return.Value((int)anImageQuality)); }
/// <summary> /// 抓拍图像 /// </summary> /// <param name="FileName">图片保存的路径</param> /// <param name="ImageType">保存图像的类型</param> /// <param name="ImageSize">保存图像的大小</param> /// <param name="ImageQuality">图像的质量</param> /// <returns>true表示成功,false表示失败</returns> public bool SnapsortFromDevice(string FileName, ImageTypeEnum ImageType, ImageSizeEnum ImageSize, ImageQualityEnum ImageQuality) { if (!InitializedForDevice) throw new InvalidOperationException(); string RealFileName = new System.IO.FileInfo(FileName).FullName; switch (ImageType) { case ImageTypeEnum.Bitmap: if (DvcPlayHandle < 0) throw new InvalidOperationException(); return HCSDK.HCNetSDK.NET_DVR_CapturePicture(DvcPlayHandle, RealFileName+".bmp"); case ImageTypeEnum.Jpeg: if (DvcUserID < 0) throw new InvalidOperationException(); HCSDK.HCNetSDK.NET_DVR_JPEGPARA JPEGPARA = new HCSDK.HCNetSDK.NET_DVR_JPEGPARA(); JPEGPARA.wPicSize = (ushort)ImageSize; JPEGPARA.wPicQuality = (ushort)ImageQuality; return HCSDK.HCNetSDK.NET_DVR_CaptureJPEGPicture(DvcUserID, VideoChannel, JPEGPARA, RealFileName+".jpg"); default: throw new ArgumentException(); } }
public bool Snap(ImageTypeEnum ImageType, ImageSizeEnum ImageSize, ImageQualityEnum ImageQuality) { if (DeviceArea == null || DeviceName == null) throw new InvalidOperationException(); string path = FileManager.FileManager.GetSnapFileName(DeviceArea, DeviceName); this.SnapsortFromDevice(path, ImageType, ImageSize, ImageQuality); return true; }
public static ImageQuality With(ImageQualityEnum anImageQualityEnum) { return(new ImageQuality(anImageQualityEnum, string.Format("#{0}", anImageQualityEnum))); }
public ImageQuality(ImageQualityEnum anImageQualityEnum, string aDisplayString) : base((uint)anImageQualityEnum, aDisplayString, EDSDK.PropID_ImageQuality) { }