Skip to content

Commit

Permalink
修复LsmimageXml解析错误导致的索引异常
Browse files Browse the repository at this point in the history
  • Loading branch information
埃博拉酱 committed Oct 4, 2023
1 parent a17955e commit 35626a3
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 55 deletions.
Binary file modified +Image5D/+internal/private/Image5DMex.mexw64
Binary file not shown.
2 changes: 1 addition & 1 deletion +Image5D/Version.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function V=Version
V.Me='v2.2.0';
V.Me='v2.2.1';
V.MatlabExtension=MATLAB.Version;
V.MATLAB='R2022b';
persistent NewVersion
Expand Down
18 changes: 0 additions & 18 deletions Image5D.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Image5DLib", "Image5DLib\Im
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Image5D测试", "Image5D测试\Image5D测试.vcxproj", "{0D661C84-7BE0-49EA-9B5D-9F1A9B3DC7EF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mex工具", "..\..\..\source\repos\MexTools\Mex工具\Mex工具.vcxproj", "{CE6CE462-A955-46A7-BB11-895054EF51EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug.本地Mex工具|x64 = Debug.本地Mex工具|x64
Expand Down Expand Up @@ -71,22 +69,6 @@ Global
{0D661C84-7BE0-49EA-9B5D-9F1A9B3DC7EF}.Release|x64.Build.0 = Release|x64
{0D661C84-7BE0-49EA-9B5D-9F1A9B3DC7EF}.Release|x86.ActiveCfg = Release|Win32
{0D661C84-7BE0-49EA-9B5D-9F1A9B3DC7EF}.Release|x86.Build.0 = Release|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug.本地Mex工具|x64.ActiveCfg = Debug|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug.本地Mex工具|x64.Build.0 = Debug|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug.本地Mex工具|x86.ActiveCfg = Debug|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug.本地Mex工具|x86.Build.0 = Debug|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug|x64.ActiveCfg = Debug|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug|x64.Build.0 = Debug|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug|x86.ActiveCfg = Debug|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Debug|x86.Build.0 = Debug|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release.本地Mex工具|x64.ActiveCfg = Release.GL|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release.本地Mex工具|x64.Build.0 = Release.GL|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release.本地Mex工具|x86.ActiveCfg = Release|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release.本地Mex工具|x86.Build.0 = Release|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release|x64.ActiveCfg = Release|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release|x64.Build.0 = Release|x64
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release|x86.ActiveCfg = Release|Win32
{CE6CE462-A955-46A7-BB11-895054EF51EA}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 5 additions & 5 deletions Image5DLib/Image5DLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<ClInclude Include="Tiff读入器.h" />
<ClInclude Include="安全拷贝.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="IFD5D.cpp" />
<ClCompile Include="IOmeTiff读写器.cpp" />
Expand All @@ -54,6 +51,9 @@
<ClCompile Include="文件控制块.cpp" />
<ClCompile Include="文件映射.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
Expand Down Expand Up @@ -192,12 +192,12 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\pugixml.1.13.0\build\native\pugixml.targets" Condition="Exists('..\packages\pugixml.1.13.0\build\native\pugixml.targets')" />
<Import Project="..\packages\pugixml.1.14.0\build\native\pugixml.targets" Condition="Exists('..\packages\pugixml.1.14.0\build\native\pugixml.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\pugixml.1.13.0\build\native\pugixml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pugixml.1.13.0\build\native\pugixml.targets'))" />
<Error Condition="!Exists('..\packages\pugixml.1.14.0\build\native\pugixml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pugixml.1.14.0\build\native\pugixml.targets'))" />
</Target>
</Project>
6 changes: 3 additions & 3 deletions Image5DLib/Image5DLib.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
<Filter>include</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="IFD5D.cpp">
<Filter>源文件</Filter>
Expand Down Expand Up @@ -111,4 +108,7 @@
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
19 changes: 6 additions & 13 deletions Image5DLib/Oir读入器.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,8 @@ Oir读入器::Oir读入器(LPCWSTR 头文件路径)
基块索引 += 2;
}
const 文件列表类::const_iterator 文件结束 = 文件列表.cend();
#ifdef _DEBUG
uint8_t 文件序号 = 0;
#endif
while (++当前文件 < 文件结束)
{
#ifdef _DEBUG
if (++文件序号 == 80)
文件序号 = 文件序号;
#endif
文件头 = (Oir文件头*)(*当前文件)->映射指针();
尾指针 = (char*)文件头 + (*当前文件)->文件大小();
if (文件头 + 1 > 尾指针)
Expand Down Expand Up @@ -375,12 +368,11 @@ Oir读入器::Oir读入器(LPCWSTR 头文件路径)
绝对跳出:;
}
新索引.每帧分块数 = 每层像素块数 / SizeC;
const uint32_t 块总数 = 块指针.size();
const uint32_t 文件大小 = 新索引.计算文件大小() + 块总数 * sizeof(const uint16_t*);
新索引.计算依赖字段(块指针.size());
const uint32_t 文件大小 = 新索引.计算文件大小();
索引文件->文件大小(文件大小);
索引文件->映射指针(nullptr);
*(索引 = (Oir索引*)索引文件->映射指针()) = 新索引;
索引->计算依赖字段(块总数);
块指针.resize(索引->SizeTZBC);
uint64_t* 块偏移;
索引->Get变长成员(i激光透过率, i通道颜色, i放大电压, 每块像素数, 块偏移);
Expand All @@ -389,6 +381,8 @@ Oir读入器::Oir读入器(LPCWSTR 头文件路径)
//第0块像素数就是真正的第0块像素数,而第1块实际上可能还是第0块(如果索引->SizeC>1)
for (const uint32_t* const 每块像素尾 = 每块像素头 + 索引->每帧分块数; 每块像素头 < 每块像素尾; 块像素头 += SizeC)
*(每块像素头++) = *块像素头;
const uint32_t A = 每块像素数[0];
const uint32_t B = 每块像素数[1];
std::copy_n(通道颜色.get(), SizeC, i通道颜色);
try
{
Expand All @@ -405,7 +399,8 @@ Oir读入器::Oir读入器(LPCWSTR 头文件路径)
const float* const Z深度尾 = Z深度指针 + 新索引.SizeZ;
while (++Z深度指针 < Z深度尾)
*Z深度指针 = *(Z深度指针 - 1) + 新索引.Z步长;
if ((节点 = 成像参数节点.child("lsmparam:brightnessAdjustmentParam")) && (节点 = 节点.child("lsmparam:enable")) && (节点文本 = 节点.text()) && 节点文本.as_bool() && (节点 = 节点.child("lsmparam:phaseBrightnessAdjustment")))
const xml_node 亮度调整参数节点 = 成像参数节点.child("lsmparam:brightnessAdjustmentParam");
if (亮度调整参数节点 && (节点 = 亮度调整参数节点.child("lsmparam:enable")) && (节点文本 = 节点.text()) && 节点文本.as_bool() && (节点 = 亮度调整参数节点.child("lsmparam:phaseBrightnessAdjustment")))
{
struct Z亮度结构
{
Expand Down Expand Up @@ -488,8 +483,6 @@ Oir读入器::Oir读入器(LPCWSTR 头文件路径)
throw Image5D异常(PMT设置不完整);
}
索引->哈希签名(文件大小);
if (!索引->验证(文件大小))
throw Image5D异常(调试断点);
}
}
void Oir读入器::读入像素(uint16_t* 写出头TZ, uint32_t TStart, uint32_t TSize, uint8_t ZStart, uint8_t ZSize, uint8_t CStart, uint8_t CSize)const
Expand Down
2 changes: 1 addition & 1 deletion Image5DLib/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="pugixml" version="1.13.0" targetFramework="native" />
<package id="pugixml" version="1.14.0" targetFramework="native" />
</packages>
15 changes: 7 additions & 8 deletions Image5DMex/Image5DMex.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,6 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\source\repos\MexTools\Mex工具\Mex工具.vcxproj">
<Project>{ce6ce462-a955-46a7-bb11-895054ef51ea}</Project>
</ProjectReference>
<ProjectReference Include="..\Image5DLib\Image5DLib.vcxproj">
<Project>{f4e56848-cfcb-4f10-ae05-3be7e40423cb}</Project>
</ProjectReference>
Expand All @@ -364,14 +358,19 @@
<ItemGroup>
<ResourceCompile Include="..\Image5DLib\include\资源.rc" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\pugixml.1.13.0\build\native\pugixml.targets" Condition="Exists('..\packages\pugixml.1.13.0\build\native\pugixml.targets')" />
<Import Project="..\packages\pugixml.1.14.0\build\native\pugixml.targets" Condition="Exists('..\packages\pugixml.1.14.0\build\native\pugixml.targets')" />
<Import Project="..\packages\MATLAB.MexTools.6.0.0\build\native\MATLAB.MexTools.targets" Condition="Exists('..\packages\MATLAB.MexTools.6.0.0\build\native\MATLAB.MexTools.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\pugixml.1.13.0\build\native\pugixml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pugixml.1.13.0\build\native\pugixml.targets'))" />
<Error Condition="!Exists('..\packages\pugixml.1.14.0\build\native\pugixml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\pugixml.1.14.0\build\native\pugixml.targets'))" />
<Error Condition="!Exists('..\packages\MATLAB.MexTools.6.0.0\build\native\MATLAB.MexTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MATLAB.MexTools.6.0.0\build\native\MATLAB.MexTools.targets'))" />
</Target>
</Project>
6 changes: 3 additions & 3 deletions Image5DMex/Image5DMex.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
Expand Down Expand Up @@ -44,4 +41,7 @@
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Image5DMex/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="pugixml" version="1.13.0" targetFramework="native" />
<package id="MATLAB.MexTools" version="6.0.0" targetFramework="native" />
<package id="pugixml" version="1.14.0" targetFramework="native" />
</packages>
5 changes: 3 additions & 2 deletions Image5D工具箱.prj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

依赖:pugixml,AVX2以上指令集,Windows系统(推荐Win11,低版本未测试)</param.description>
<param.screenshot>${PROJECT_ROOT}\工具箱图像.png</param.screenshot>
<param.version>2.2.0</param.version>
<param.version>2.2.1</param.version>
<param.output>${PROJECT_ROOT}\Image5D.mltbx</param.output>
<param.products.name />
<param.products.id />
Expand Down Expand Up @@ -111,6 +111,7 @@ x64
<fileset.rootfiles>
<file>${PROJECT_ROOT}\+Image5D</file>
<file>${PROJECT_ROOT}\doc</file>
<file>${PROJECT_ROOT}\LsmimageXml.xml</file>
<file>${PROJECT_ROOT}\README.md</file>
<file>${PROJECT_ROOT}\resources</file>
<file>${PROJECT_ROOT}\工具箱图像.png</file>
Expand All @@ -123,7 +124,7 @@ x64
</build-deliverables>
<workflow />
<matlab>
<root>C:\Program Files\MATLAB\R2023a</root>
<root>C:\Program Files\MATLAB\R2023b</root>
<toolboxes />
</matlab>
<platform>
Expand Down
Binary file modified doc/GettingStarted.mlx
Binary file not shown.

1 comment on commit 35626a3

@Ebola-Chan-bot
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

以及索引文件大小计算错误

Please sign in to comment.