Skip to content

Commit c354a29

Browse files
committed
v 1.0
1 parent a5ce7bb commit c354a29

File tree

9 files changed

+7433
-421
lines changed

9 files changed

+7433
-421
lines changed

ImageToGTR3/3d-Image.ico

204 KB
Binary file not shown.

ImageToGTR3/ColorMap.cs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void ArrayToColors()
5656
}
5757
}
5858

59-
private void ARGB_BGRA(bool blackAlpha, byte errorValue,bool r, bool g, bool b)
59+
private void ARGB_BGRA()
6060
{
6161
for (int i = 0; i < Colors.Count; i++)
6262
{
@@ -69,49 +69,13 @@ private void ARGB_BGRA(bool blackAlpha, byte errorValue,bool r, bool g, bool b)
6969
G = (byte)(G * scale);
7070
B = (byte)(B * scale);
7171

72-
if (blackAlpha)
73-
{
74-
if (R < errorValue && G < errorValue && B < errorValue) A = 0;
75-
}
76-
if (r) A = R;
77-
if (g) A = G;
78-
if (b) A = B;
79-
8072
Colors[i] = Color.FromArgb(R, G, B, A);
8173
}
8274
}
83-
private void SetTransparent(bool blackAlpha, byte errorValue, bool r, bool g, bool b)
84-
{
85-
for (int i = 0; i < Colors.Count; i++)
86-
{
87-
byte A = Colors[i].A;
88-
byte R = Colors[i].R;
89-
byte G = Colors[i].G;
90-
byte B = Colors[i].B;
91-
92-
if (blackAlpha)
93-
{
94-
if (R < errorValue && G < errorValue && B < errorValue) A = 0;
95-
}
96-
if (r) A = R;
97-
if (g) A = G;
98-
if (b) A = B;
99-
100-
Colors[i] = Color.FromArgb(A, R, G, B);
101-
}
102-
}
10375

104-
public void ColorsFix(bool argb_brga, bool blackAlpha, byte errorValue,
105-
bool r, bool g, bool b, bool firstСolor, bool lastСolor, int colorMapCount, byte colorMapEntrySize)
76+
public void ColorsFix(bool argb_brga, int colorMapCount, byte colorMapEntrySize)
10677
{
107-
if (firstСolor) Colors[0] = Color.FromArgb(0, Colors[0].R, Colors[0].G, Colors[0].B);
108-
if (lastСolor)
109-
{
110-
int index = Colors.Count - 1;
111-
Colors[index] = Color.FromArgb(0, Colors[index].R, Colors[index].G, Colors[index].B);
112-
}
113-
if (argb_brga) ARGB_BGRA(blackAlpha, errorValue, r, g, b);
114-
else if (colorMapEntrySize!=31) SetTransparent(blackAlpha, errorValue, r, g, b);
78+
if (argb_brga) ARGB_BGRA();
11579

11680
ColorMapCount = colorMapCount;
11781
ColorMapEntrySize = colorMapEntrySize;

ImageToGTR3/Form1.Designer.cs

Lines changed: 13 additions & 264 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ImageToGTR3/Form1.cs

Lines changed: 175 additions & 117 deletions
Large diffs are not rendered by default.

ImageToGTR3/Form1.resx

Lines changed: 3575 additions & 0 deletions
Large diffs are not rendered by default.

ImageToGTR3/Form1.ru.resx

Lines changed: 3610 additions & 0 deletions
Large diffs are not rendered by default.

ImageToGTR3/Header.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class Header
1313
public byte[] _header;
1414
int ColorMapCount;
1515
byte ColorMapEntrySize;
16+
public int Width { get; }
17+
public int Height { get; }
1618

1719
public Header(byte[] streamBuffer)
1820
{
@@ -21,6 +23,8 @@ public Header(byte[] streamBuffer)
2123
ImageIDLength = _header[0];
2224
ColorMapCount = BitConverter.ToUInt16(_header, 5);
2325
ColorMapEntrySize = _header[7];
26+
Width = BitConverter.ToUInt16(_header, 12);
27+
Height = BitConverter.ToUInt16(_header, 14);
2428

2529
if (_header[1] != 1 || _header[2] != 1) throw new Exception("Не верный формат файла");
2630
}

ImageToGTR3/ImageDescription.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,30 @@ public ImageDescription(byte[] streamBuffer, byte lenght)
1515
Array.Copy(streamBuffer, 18, _imageDescription, 0, lenght);
1616
}
1717

18-
public void SetSize(int newSize)
18+
public void SetSize(int newSize, int Width)
1919
{
2020
Array.Resize(ref _imageDescription, newSize);
21+
if (newSize > 6)
22+
{
23+
_imageDescription[0] = 0x53;
24+
_imageDescription[1] = 0x4F;
25+
_imageDescription[2] = 0x4D;
26+
_imageDescription[3] = 0x48;
27+
Array.Copy(IntToByte(Width), 0, _imageDescription, 4, 2);
28+
}
29+
}
30+
31+
private byte[] IntToByte(int value)
32+
{
33+
byte[] intBytes = BitConverter.GetBytes(value);
34+
return intBytes;
35+
}
36+
37+
public int GetRealWidth()
38+
{
39+
if (_imageDescription.Length < 6) return -1;
40+
int Width = BitConverter.ToUInt16(_imageDescription, 4);
41+
return Width;
2142
}
2243
}
2344
}

ImageToGTR3/ImageToGTR3.csproj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<Deterministic>true</Deterministic>
14+
<PublishUrl>publish\</PublishUrl>
15+
<Install>true</Install>
16+
<InstallFrom>Disk</InstallFrom>
17+
<UpdateEnabled>false</UpdateEnabled>
18+
<UpdateMode>Foreground</UpdateMode>
19+
<UpdateInterval>7</UpdateInterval>
20+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
21+
<UpdatePeriodically>false</UpdatePeriodically>
22+
<UpdateRequired>false</UpdateRequired>
23+
<MapFileExtensions>true</MapFileExtensions>
24+
<ApplicationRevision>0</ApplicationRevision>
25+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
26+
<IsWebBootstrapper>false</IsWebBootstrapper>
27+
<UseApplicationTrust>false</UseApplicationTrust>
28+
<BootstrapperEnabled>true</BootstrapperEnabled>
1429
</PropertyGroup>
1530
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1631
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,6 +46,9 @@
3146
<ErrorReport>prompt</ErrorReport>
3247
<WarningLevel>4</WarningLevel>
3348
</PropertyGroup>
49+
<PropertyGroup>
50+
<ApplicationIcon>3d-Image.ico</ApplicationIcon>
51+
</PropertyGroup>
3452
<ItemGroup>
3553
<Reference Include="Magick.NET-Q16-AnyCPU, Version=7.17.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
3654
<HintPath>..\packages\Magick.NET-Q16-AnyCPU.7.17.0\lib\net40\Magick.NET-Q16-AnyCPU.dll</HintPath>
@@ -64,6 +82,9 @@
6482
<EmbeddedResource Include="Form1.resx">
6583
<DependentUpon>Form1.cs</DependentUpon>
6684
</EmbeddedResource>
85+
<EmbeddedResource Include="Form1.ru.resx">
86+
<DependentUpon>Form1.cs</DependentUpon>
87+
</EmbeddedResource>
6788
<EmbeddedResource Include="Properties\Resources.resx">
6889
<Generator>ResXFileCodeGenerator</Generator>
6990
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -87,5 +108,15 @@
87108
<ItemGroup>
88109
<None Include="App.config" />
89110
</ItemGroup>
111+
<ItemGroup>
112+
<Content Include="3d-Image.ico" />
113+
</ItemGroup>
114+
<ItemGroup>
115+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
116+
<Visible>False</Visible>
117+
<ProductName>.NET Framework 3.5 SP1</ProductName>
118+
<Install>false</Install>
119+
</BootstrapperPackage>
120+
</ItemGroup>
90121
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
91122
</Project>

0 commit comments

Comments
 (0)