Skip to content

Commit a1ff2c8

Browse files
committed
File overwrite error.
1 parent ba4e0f4 commit a1ff2c8

File tree

5 files changed

+53
-34
lines changed

5 files changed

+53
-34
lines changed

HDR10Capture2019/00README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ Extract all and run HDR10Capture.exe
33

44
Tested capture card: DeckLink Mini Recorder 4K.
55

6+
Version 1.2
7+
8+
-File overwrite error.
9+
610
Version 1.1
711

812
-Fix OpenEXR write alpha value bug.

HDR10Capture2019/MLDX12App.cpp

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "MLVideoCaptureEnumToStr.h"
1515
#include "MLVideoTime.h"
1616
#include "MLExrWriter.h"
17+
#include <shlwapi.h>
1718

1819
// D3D12HelloFrameBuffering sample
1920
//*********************************************************
@@ -518,8 +519,8 @@ MLDX12App::SetDefaultImgTexture(void)
518519

519520
mMutex.unlock();
520521

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);
523524

524525
delete[] buff;
525526
}
@@ -886,7 +887,7 @@ MLDX12App::PopulateCommandList(void) {
886887

887888
// 全クライアント領域に画像を描画。
888889
DrawFullscreenTexture(
889-
(TextureEnum)(TCE_TEX_IMG0 + mRenderTexImgIdx),
890+
(TextureEnum)(TCE_TEX_IMG0 + mTexImgIdx),
890891
mRenderImg);
891892

892893
// Start the Dear ImGui frame
@@ -1043,7 +1044,7 @@ MLDX12App::ShowVideoCaptureWindow(void)
10431044
// 選択デバイスを使用開始。
10441045
hr = mVCU.UseDevice(mVCDeviceToUse.device);
10451046
if (FAILED(hr)) {
1046-
sprintf_s(mErrorVCMsg, "Use DeckLink Device failed %08x", hr);
1047+
sprintf_s(mErrorVCMsg, "Error: Use DeckLink Device failed %08x", hr);
10471048
ImGui::OpenPopup("ErrorVCPopup");
10481049
} else {
10491050
// 成功。
@@ -1098,20 +1099,25 @@ MLDX12App::ShowVideoCaptureWindow(void)
10981099
if (MLIF_Unknown != aviIF) {
10991100
ImGui::InputText("Record AVI filename ##VCS", mAviFilePath, sizeof mAviFilePath - 1);
11001101
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.\nFile open error : %s", mAviFilePath);
1102+
if (PathFileExistsA(mAviFilePath)) {
1103+
sprintf_s(mErrorVCMsg, "Error: File exists.\nPlease input different file name. %s", mAviFilePath);
11141104
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.\nFile open error : %s", mAviFilePath);
1119+
ImGui::OpenPopup("ErrorVCPopup");
1120+
}
11151121
}
11161122
}
11171123
}
@@ -1370,21 +1376,31 @@ MLDX12App::ShowImageFileRWWindow(void) {
13701376
switch (et) {
13711377
case ET_PNG:
13721378
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.\nFile Write error : %s", mImgFilePath);
1379+
if (PathFileExistsA(mImgFilePath)) {
1380+
sprintf_s(mErrorFileReadMsg, "Error: File exists.\nPlease input different file name. %s", mImgFilePath);
13771381
ImGui::OpenPopup("ErrorImageFileRWPopup");
1382+
} else {
1383+
hr = MLPngWrite(mImgFilePath, mWriteImg);
1384+
1385+
if (FAILED(hr)) {
1386+
sprintf_s(mErrorFileReadMsg, "Error: Write Image Failed.\nFile Write error : %s", mImgFilePath);
1387+
ImGui::OpenPopup("ErrorImageFileRWPopup");
1388+
}
13781389
}
13791390
}
13801391
break;
13811392
case ET_EXR:
13821393
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.\nPlease input different file name. %s", mImgFilePath);
13841396

1385-
if (FAILED(hr)) {
1386-
sprintf_s(mErrorFileReadMsg, "Write Image Failed.\nFile Write error : %s", mImgFilePath);
13871397
ImGui::OpenPopup("ErrorImageFileRWPopup");
1398+
} else {
1399+
hr = mExrWriter.Write(mImgFilePath, mWriteImg);
1400+
if (FAILED(hr)) {
1401+
sprintf_s(mErrorFileReadMsg, "Error: Write Image Failed.\nFile Write error : %s", mImgFilePath);
1402+
ImGui::OpenPopup("ErrorImageFileRWPopup");
1403+
}
13881404
}
13891405
}
13901406
break;
@@ -1410,7 +1426,7 @@ MLDX12App::ShowImageFileRWWindow(void) {
14101426
}
14111427
mMutex.unlock();
14121428
if (hr < 0) {
1413-
sprintf_s(mErrorFileReadMsg, "Read Image Failed.\nFile open error : %s", mImgFilePath);
1429+
sprintf_s(mErrorFileReadMsg, "Error: Read Image Failed.\nFile open error : %s", mImgFilePath);
14141430
ImGui::OpenPopup("ErrorImageFileRWPopup");
14151431
} else {
14161432
mState = S_ImageViewing;
@@ -1449,12 +1465,12 @@ MLDX12App::UpdateImgTexture(void) {
14491465

14501466
mMutex.unlock();
14511467

1452-
int uploadTexIdx = !mRenderTexImgIdx;
1468+
int uploadTexIdx = !mTexImgIdx;
14531469
UploadImgToGpu(mRenderImg, mTexImg[uploadTexIdx],
14541470
(TextureEnum)(TCE_TEX_IMG0 + uploadTexIdx));
14551471

14561472
mRenderImg.DeleteData();
1457-
mRenderTexImgIdx = uploadTexIdx;
1473+
mTexImgIdx = uploadTexIdx;
14581474

14591475

14601476
return true;

HDR10Capture2019/MLDX12App.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class MLDX12App : public MLDX12 {
126126
/// 描画中テクスチャが0番の場合、アップロード用テクスチャは1番。
127127
/// 描画中テクスチャが1番の場合、アップロード用テクスチャは0番。
128128
/// </summary>
129-
int mRenderTexImgIdx = 0;
129+
int mTexImgIdx = 0;
130130

131131
/// <summary>
132132
/// 使用中のmFenceValues[]要素番号。
@@ -163,7 +163,6 @@ class MLDX12App : public MLDX12 {
163163
void SetDefaultImgTexture(void);
164164
bool UpdateImgTexture(void);
165165

166-
167166
void CreateTexture(ComPtr<ID3D12Resource>& tex, int texIdx, int w, int h, DXGI_FORMAT fmt, int pixelBytes, uint8_t* data);
168167
void CreateImguiTexture(void);
169168
void ImGuiCommands(void);

HDR10Capture2019/Resource.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
6161
//
6262

6363
VS_VERSION_INFO VERSIONINFO
64-
FILEVERSION 1,1,0,1
65-
PRODUCTVERSION 1,1,0,1
64+
FILEVERSION 1,2,0,1
65+
PRODUCTVERSION 1,2,0,1
6666
FILEFLAGSMASK 0x3fL
6767
#ifdef _DEBUG
6868
FILEFLAGS 0x1L
@@ -79,12 +79,12 @@ BEGIN
7979
BEGIN
8080
VALUE "CompanyName", "TODO: <Company name>"
8181
VALUE "FileDescription", "HDR10Capture"
82-
VALUE "FileVersion", "1.1.0.1"
82+
VALUE "FileVersion", "1.2.0.1"
8383
VALUE "InternalName", "HDR10Capture"
8484
VALUE "LegalCopyright", "Copyright (C) 2020"
8585
VALUE "OriginalFilename", "HDR10Capture.exe"
8686
VALUE "ProductName", "HDR10Capture"
87-
VALUE "ProductVersion", "1.1.0.1"
87+
VALUE "ProductVersion", "1.2.0.1"
8888
END
8989
END
9090
BLOCK "VarFileInfo"

HDR10Capture2019/imgui_draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)
174174

175175
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
176176
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
177-
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
177+
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.96f); //< original alpha == 0.94f
178178
colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f);
179179
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
180180
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);

0 commit comments

Comments
 (0)