我是 C# 新手,现在使用佳能的EDSDK在图片框中实时查看相机。如何将实时取景图像旋转 180°?
建立 liveView 后,我尝试旋转图像
MainForm.cs
Camera MainCamera; // is instanciated elsewhere
public void startLiveView() {
MainCamera.StartLiveView();
// at this point, live-view is working and LiveViewPicBox contains the live-view
// this code has no effect:
Image img = LiveViewPicBox.Image;
img.RotateFlip(RotateFlipType.Rotate180FlipY);
LiveViewPicBox.Image = img;
}
相机.cs
public void StartLiveView()
{
CheckState();
if (!IsLiveViewOn) SetSetting(PropertyID.Evf_OutputDevice, (int)EvfOutputDevice.PC);
}
public void SetSetting(PropertyID propID, object value, int inParam = 0)
{
CheckState();
MainThread.Invoke(() =>
{
int propsize;
DataType proptype;
ErrorHandler.CheckError(this, CanonSDK.EdsGetPropertySize(CamRef, propID, inParam, out proptype, out propsize));
ErrorHandler.CheckError(this, CanonSDK.EdsSetPropertyData(CamRef, propID, inParam, propsize, value));
});
}
SDKMethods.cs (CanonSDK)
[DllImport(DllPath)]
public extern static ErrorCode EdsGetPropertySize(IntPtr inRef, PropertyID inPropertyID, int inParam, out DataType outDataType, out int outSize);
[DllImport(DllPath)]
public extern static ErrorCode EdsSetPropertyData(IntPtr inRef, PropertyID inPropertyID, int inParam, int inPropertySize, [MarshalAs(UnmanagedType.AsAny), In] object inPropertyData);
实时视图正在工作,但未应用旋转。
注意:pictureBox 有属性WaitOnLoad=false
我假设我需要旋转某种图像流,尽管我不太了解 SDK 中的大部分代码。谁能帮助我,告诉我从哪里开始?