Skip to content

Commit e31b5a8

Browse files
seto77claude
andcommitted
Add Rad-Xcam3030 support, fix Radicon1520 bugs, and auto-detect image orientation
- Added support for FlatPanel Rad-Xcam3030 and 2048x2048 resolution - Added auto-detection of width/height orientation for RadIcon images - Removed unused NativeMemoryArray package, updated System.Linq.Dynamic.Core - Removed System.Linq.Dynamic.Core from Controls project - Updated assembly versions to 2026.4.7.0209 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4cb338e commit e31b5a8

4 files changed

Lines changed: 40 additions & 9 deletions

File tree

Crystallography.Controls/Crystallography.Controls.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net10.0-windows</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2026.4.5.2311</AssemblyVersion>
8-
<FileVersion>2026.4.5.2311</FileVersion>
7+
<AssemblyVersion>2026.4.7.0209</AssemblyVersion>
8+
<FileVersion>2026.4.7.0209</FileVersion>
99
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
1010
<ApplicationUseCompatibleTextRendering>true</ApplicationUseCompatibleTextRendering>
1111
<ApplicationVisualStyles>true</ApplicationVisualStyles>
@@ -49,7 +49,6 @@
4949
<PackageReference Include="OpenTK" Version="4.9.4" />
5050
<PackageReference Include="SimdLinq" Version="1.3.2" />
5151
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
52-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.7.1" />
5352
<PackageReference Include="ZLinq" Version="1.5.5" />
5453
</ItemGroup>
5554

Crystallography/Crystallography.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<OutputType>Library</OutputType>
55
<TargetFramework>net10.0-windows</TargetFramework>
66
<UseWindowsForms>true</UseWindowsForms>
7-
<AssemblyVersion>2026.4.5.2311</AssemblyVersion>
8-
<FileVersion>2026.4.5.2311</FileVersion>
7+
<AssemblyVersion>2026.4.7.0209</AssemblyVersion>
8+
<FileVersion>2026.4.7.0209</FileVersion>
99
<!-- <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> --><!-- 260405Cl .NET 10はWindows7非対応のため削除 -->
1010
<Platforms>x64</Platforms>
1111
<PublishReadyToRun>true</PublishReadyToRun>
@@ -36,11 +36,11 @@
3636
<ItemGroup>
3737
<PackageReference Include="MathNet.Numerics" Version="6.0.0-beta2" />
3838
<PackageReference Include="MemoryPack" Version="1.21.4" />
39-
<PackageReference Include="NativeMemoryArray" Version="1.2.2" />
39+
<!--<PackageReference Include="NativeMemoryArray" Version="1.2.2" />--><!-- 260407Cl 未使用のため削除 -->
4040
<PackageReference Include="OpenTK" Version="4.9.4" />
4141
<PackageReference Include="PureHDF" Version="2.1.2" />
4242
<PackageReference Include="SimdLinq" Version="1.3.2" />
43-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.7.1" />
43+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.7.2" />
4444
<PackageReference Include="ZLinq" Version="1.5.5" />
4545
</ItemGroup>
4646

Crystallography/Images/ImageIO.cs

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,22 @@ private static bool SMV(string filename)
332332

333333
#region rawファイル (RadIcon など)
334334

335-
static readonly Size[] RadIconSize
336-
= [new (688, 2064), new(1548, 2064), new(2064, 2236), new(2080, 2238), new(3096, 3100), new(1300, 4608), new(2940, 4608), new(5888, 4608),];
335+
/// <summary> 指定された行幅wに対して、行折り返し不連続性と縦方向連続性の平均を計算する </summary>
336+
private static (double WrapAvg, double VertAvg) CalcWrapAndVertAvg(int w, int h)
337+
{
338+
double wrapSum = 0, vertSum = 0;
339+
for (int row = 0; row < h - 1; row++)
340+
{
341+
int rowStart = row * w;
342+
wrapSum += Math.Abs(Ring.Intensity[rowStart + w] - Ring.Intensity[rowStart + w - 1]);// 行折り返し不連続性: 行末と次行先頭のピクセル差
343+
for (int x = 0; x < w; x++)
344+
vertSum += Math.Abs(Ring.Intensity[rowStart + w + x] - Ring.Intensity[rowStart + x]); // 縦方向連続性: 同列の隣接行ピクセル差
345+
}
346+
return (wrapSum / Math.Max(h - 1, 1), vertSum / Math.Max((long)(h - 1) * w, 1));
347+
}
348+
349+
static readonly Size[] RadIconSize
350+
= [new (688, 2064), new(2048, 2048), new(2064, 1548), new(2064, 2236), new(2080, 2238), new(3096, 3100), new(1300, 4608), new(2940, 4608), new(5888, 4608),];
337351
public static bool RadIcon(string str)
338352
{
339353
try
@@ -358,6 +372,23 @@ public static bool RadIcon(string str)
358372
}
359373
br.Close();
360374

375+
//全く同じファイルサイズで、2064x1548と1548x2064のケースがある (20200410辻野さんへの対応)
376+
//横方向連続性、縦方向連続性、行折り返し不連続性を評価しRing.SrcImgSizeのwidthとheightを入れ替える
377+
if (Ring.SrcImgSize.Width != Ring.SrcImgSize.Height)
378+
{
379+
var original = CalcWrapAndVertAvg(Ring.SrcImgSize.Width, Ring.SrcImgSize.Height);
380+
var swapped = CalcWrapAndVertAvg(Ring.SrcImgSize.Height, Ring.SrcImgSize.Width);
381+
382+
bool swapNeeded;
383+
if (original.WrapAvg == 0 || swapped.WrapAvg == 0)// どちらか一方でもwrapAvgがゼロなら、vertAvgだけで評価 (小さい方が正しい向き)
384+
swapNeeded = swapped.VertAvg < original.VertAvg;
385+
else// スコア = 行折り返し不連続性 / 縦方向連続性 (大きいほど行幅が正しい)
386+
swapNeeded = swapped.WrapAvg / (swapped.VertAvg + 1e-10) > original.WrapAvg / (original.VertAvg + 1e-10);
387+
388+
if (swapNeeded)
389+
Ring.SrcImgSize = new Size(Ring.SrcImgSize.Height, Ring.SrcImgSize.Width);
390+
}
391+
361392
Ring.BitsPerPixels = 16;
362393
Ring.ImageType = Ring.ImageTypeEnum.RadIcon;
363394
Ring.Comments = "";

IPAnalyzer/Version.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static class Version
99

1010
static public string History =
1111
"History" +
12+
"\r\n ver3.975(2026/04/10) Added support for FlatPanel Rad-Xcam3030 and fixed bugs on Radicon1520. " +
1213
"\r\n ver3.974(2026/04/06) Reduced the size of the installer package. " +
1314
"\r\n ver3.973(2026/01/21) Fixed bugs on loading *.nxs files." +
1415
"\r\n ver3.972(2026/01/16) Fixed bugs on loading *.nxs files." +

0 commit comments

Comments
 (0)