2012-10-24 59 views
0

我想通過代碼更改windows mobile 6.5中的攝像頭分辨率。但它不工作我的代碼片段如下。Windows Mobile 6.5中的攝像頭分辨率變化

CameraCaptureDialog cameraCaptureDialog = new CameraCaptureDialog(); 
cameraCaptureDialog.Owner = this; 
cameraCaptureDialog.Resolution = new Size(800, 600); 
+0

某些相機不支持每個分辨率。可能您可以從註冊表中獲得支持的解決方案列表。如果您選擇不支持的分辨率,代碼將失敗。 – josef

+0

嗨josef,該設備確實支持這個決議,但它沒有通過代碼進行更改。感謝您的回覆 –

回答

1

這裏是我用來啓動CameraCaptureDialog片段:

cameraDialog.Owner = this; 
cameraDialog.InitialDirectory = @"\My Documents"; 
cameraDialog.DefaultFileName = "test.jpg"; 
cameraDialog.Title = "iCOMM Camera Demo"; 
cameraDialog.StillQuality = CameraCaptureStillQuality.Default; 
cameraDialog.Mode = CameraCaptureMode.Still; 

的差異是,我不使用由CameraCaptureDialog課堂上給出一個自由定義大小的對象,但一個exisiting分辨率常量。

如上所述,應在註冊表中列出支持的解決方案。在另一個代碼我使用以下方法來獲取已知資源的:

public cResolution[] getResolutions(){ 
cResolution[] cRes; 
RegistryKey rKey = Registry.LocalMachine.OpenSubKey(regSubResolution, false); 
string[] subKeys = rKey.GetSubKeyNames(); 
cRes = new cResolution[subKeys.Length]; 
int i=0; 
foreach (string s in subKeys) 
{ 
    RegistryKey rKeySub = Registry.LocalMachine.OpenSubKey(regSubResolution + "\\" + s, false); 
    string item; 
    int w, h, hqfs, nqfs, lqfs, pw, ph; 
    item = (string)rKeySub.GetValue("ItemString"); 
    w = (int)rKeySub.GetValue("Width"); 
    h = (int)rKeySub.GetValue("Height"); 
    hqfs = (int)rKeySub.GetValue("HighQualityFileSize"); 
    lqfs = (int)rKeySub.GetValue("LowQualityFileSize"); 
    nqfs = (int)rKeySub.GetValue("NormalQualityFileSize"); 
    ph = (int)rKeySub.GetValue("PreviewHeight"); 
    pw = (int)rKeySub.GetValue("PreviewWidth"); 
    cRes[i] = new cResolution(item, h, w, pw, ph, hqfs, nqfs, lqfs); 
    i++; 
    rKeySub = null; 
} 

但正如所說,這依賴於OEM實現相機。

〜約瑟夫