14
14
#include " MLVideoCaptureEnumToStr.h"
15
15
#include " MLVideoTime.h"
16
16
#include " MLExrWriter.h"
17
+ #include < shlwapi.h>
17
18
18
19
// D3D12HelloFrameBuffering sample
19
20
// *********************************************************
@@ -518,8 +519,8 @@ MLDX12App::SetDefaultImgTexture(void)
518
519
519
520
mMutex .unlock ();
520
521
521
- mTexImg [mRenderTexImgIdx ].Reset ();
522
- CreateTexture (mTexImg [mRenderTexImgIdx ], TCE_TEX_IMG0, texW, texH, DXGI_FORMAT_R16G16B16A16_FLOAT, pixelBytes, (uint8_t *)buff);
522
+ mTexImg [mTexImgIdx ].Reset ();
523
+ CreateTexture (mTexImg [mTexImgIdx ], TCE_TEX_IMG0, texW, texH, DXGI_FORMAT_R16G16B16A16_FLOAT, pixelBytes, (uint8_t *)buff);
523
524
524
525
delete[] buff;
525
526
}
@@ -886,7 +887,7 @@ MLDX12App::PopulateCommandList(void) {
886
887
887
888
// 全クライアント領域に画像を描画。
888
889
DrawFullscreenTexture (
889
- (TextureEnum)(TCE_TEX_IMG0 + mRenderTexImgIdx ),
890
+ (TextureEnum)(TCE_TEX_IMG0 + mTexImgIdx ),
890
891
mRenderImg );
891
892
892
893
// Start the Dear ImGui frame
@@ -1043,7 +1044,7 @@ MLDX12App::ShowVideoCaptureWindow(void)
1043
1044
// 選択デバイスを使用開始。
1044
1045
hr = mVCU .UseDevice (mVCDeviceToUse .device );
1045
1046
if (FAILED (hr)) {
1046
- sprintf_s (mErrorVCMsg , " Use DeckLink Device failed %08x" , hr);
1047
+ sprintf_s (mErrorVCMsg , " Error: Use DeckLink Device failed %08x" , hr);
1047
1048
ImGui::OpenPopup (" ErrorVCPopup" );
1048
1049
} else {
1049
1050
// 成功。
@@ -1098,20 +1099,25 @@ MLDX12App::ShowVideoCaptureWindow(void)
1098
1099
if (MLIF_Unknown != aviIF) {
1099
1100
ImGui::InputText (" Record AVI filename ##VCS" , mAviFilePath , sizeof mAviFilePath - 1 );
1100
1101
if (ImGui::Button (" Record ## VCS" , ImVec2 (256 , 48 ))) {
1101
- wchar_t path[512 ];
1102
- memset (path, 0 , sizeof path);
1103
- MultiByteToWideChar (CP_UTF8, 0 , mAviFilePath , sizeof mAviFilePath , path, 511 );
1104
-
1105
- bool bRv = mVCU .AviWriter ().Start (
1106
- path, fmt.width , fmt.height ,
1107
- (double )fmt.frameRateTS /fmt.frameRateTV ,
1108
- aviIF, true );
1109
- if (bRv) {
1110
- mVCState = VCS_Recording;
1111
- mErrorVCMsg [0 ] = 0 ;
1112
- } else {
1113
- sprintf_s (mErrorVCMsg , " Record Failed.\n File open error : %s" , mAviFilePath );
1102
+ if (PathFileExistsA (mAviFilePath )) {
1103
+ sprintf_s (mErrorVCMsg , " Error: File exists.\n Please input different file name. %s" , mAviFilePath );
1114
1104
ImGui::OpenPopup (" ErrorVCPopup" );
1105
+ } else {
1106
+ wchar_t path[512 ];
1107
+ memset (path, 0 , sizeof path);
1108
+ MultiByteToWideChar (CP_UTF8, 0 , mAviFilePath , sizeof mAviFilePath , path, 511 );
1109
+
1110
+ bool bRv = mVCU .AviWriter ().Start (
1111
+ path, fmt.width , fmt.height ,
1112
+ (double )fmt.frameRateTS /fmt.frameRateTV ,
1113
+ aviIF, true );
1114
+ if (bRv) {
1115
+ mVCState = VCS_Recording;
1116
+ mErrorVCMsg [0 ] = 0 ;
1117
+ } else {
1118
+ sprintf_s (mErrorVCMsg , " Error: Record Failed.\n File open error : %s" , mAviFilePath );
1119
+ ImGui::OpenPopup (" ErrorVCPopup" );
1120
+ }
1115
1121
}
1116
1122
}
1117
1123
}
@@ -1370,21 +1376,31 @@ MLDX12App::ShowImageFileRWWindow(void) {
1370
1376
switch (et) {
1371
1377
case ET_PNG:
1372
1378
if (ImGui::Button (" Write PNG Image ##RF0" , ImVec2 (256 , 48 ))) {
1373
- hr = MLPngWrite (mImgFilePath , mWriteImg );
1374
-
1375
- if (FAILED (hr)) {
1376
- sprintf_s (mErrorFileReadMsg , " Write Image Failed.\n File Write error : %s" , mImgFilePath );
1379
+ if (PathFileExistsA (mImgFilePath )) {
1380
+ sprintf_s (mErrorFileReadMsg , " Error: File exists.\n Please input different file name. %s" , mImgFilePath );
1377
1381
ImGui::OpenPopup (" ErrorImageFileRWPopup" );
1382
+ } else {
1383
+ hr = MLPngWrite (mImgFilePath , mWriteImg );
1384
+
1385
+ if (FAILED (hr)) {
1386
+ sprintf_s (mErrorFileReadMsg , " Error: Write Image Failed.\n File Write error : %s" , mImgFilePath );
1387
+ ImGui::OpenPopup (" ErrorImageFileRWPopup" );
1388
+ }
1378
1389
}
1379
1390
}
1380
1391
break ;
1381
1392
case ET_EXR:
1382
1393
if (ImGui::Button (" Write EXR Image ##RF0" , ImVec2 (256 , 48 ))) {
1383
- hr = mExrWriter .Write (mImgFilePath , mWriteImg );
1394
+ if (PathFileExistsA (mImgFilePath )) {
1395
+ sprintf_s (mErrorFileReadMsg , " Error: File exists.\n Please input different file name. %s" , mImgFilePath );
1384
1396
1385
- if (FAILED (hr)) {
1386
- sprintf_s (mErrorFileReadMsg , " Write Image Failed.\n File Write error : %s" , mImgFilePath );
1387
1397
ImGui::OpenPopup (" ErrorImageFileRWPopup" );
1398
+ } else {
1399
+ hr = mExrWriter .Write (mImgFilePath , mWriteImg );
1400
+ if (FAILED (hr)) {
1401
+ sprintf_s (mErrorFileReadMsg , " Error: Write Image Failed.\n File Write error : %s" , mImgFilePath );
1402
+ ImGui::OpenPopup (" ErrorImageFileRWPopup" );
1403
+ }
1388
1404
}
1389
1405
}
1390
1406
break ;
@@ -1410,7 +1426,7 @@ MLDX12App::ShowImageFileRWWindow(void) {
1410
1426
}
1411
1427
mMutex .unlock ();
1412
1428
if (hr < 0 ) {
1413
- sprintf_s (mErrorFileReadMsg , " Read Image Failed.\n File open error : %s" , mImgFilePath );
1429
+ sprintf_s (mErrorFileReadMsg , " Error: Read Image Failed.\n File open error : %s" , mImgFilePath );
1414
1430
ImGui::OpenPopup (" ErrorImageFileRWPopup" );
1415
1431
} else {
1416
1432
mState = S_ImageViewing;
@@ -1449,12 +1465,12 @@ MLDX12App::UpdateImgTexture(void) {
1449
1465
1450
1466
mMutex .unlock ();
1451
1467
1452
- int uploadTexIdx = !mRenderTexImgIdx ;
1468
+ int uploadTexIdx = !mTexImgIdx ;
1453
1469
UploadImgToGpu (mRenderImg , mTexImg [uploadTexIdx],
1454
1470
(TextureEnum)(TCE_TEX_IMG0 + uploadTexIdx));
1455
1471
1456
1472
mRenderImg .DeleteData ();
1457
- mRenderTexImgIdx = uploadTexIdx;
1473
+ mTexImgIdx = uploadTexIdx;
1458
1474
1459
1475
1460
1476
return true ;
0 commit comments