Skip to content

Commit 24ef07b

Browse files
committed
Initial commit
0 parents  commit 24ef07b

28 files changed

+1611
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vs
2+
bin
3+
obj
4+
packages
5+
Setup/setup*-SetupFiles
6+
Setup/setup-cache

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Fidifis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# TextureMerge
2+
## Software to merge textures into image channels, producing one image with up to four textures.
3+
4+
this program is ideal if you want to pack individual grayscale textures in one image.
5+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img1.jpg)
6+
7+
1. Download the software from [releases](https://github.com/Fidifis/TextureMerge/releases)
8+
2. Open TextureMerge.exe
9+
*(optionally you can create shortcut on your desktop to open it faster next time)*
10+
3. Click load under the color channel into which you want to insert texture.
11+
12+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img2.jpg)
13+
14+
4. The Windows dialog appears. Select the texture and click open.
15+
16+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img3.jpg)
17+
18+
5. Repeat for other textures. Empty channels will be black or you can change it to white (the alpha channel will not be added if no image provided).
19+
6. When you are done click Merge.
20+
21+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img4.jpg)
22+
23+
7. The Windows dialog appears. Enter a file name and click save.
24+
25+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img5.jpg)
26+
27+
28+
## You now have textures packed.
29+
30+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img6.jpg)
31+
32+
33+
## Example of use in Unreal Engine
34+
![image](https://github.com/Fidifis/TextureMerge/raw/master/Tutorial-images/img7.jpg)

Setup/setup.aip

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

TextureMerge.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32616.157
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextureMerge", "TextureMerge\TextureMerge.csproj", "{29621F4C-F190-41AF-882C-E8408B76372C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{29621F4C-F190-41AF-882C-E8408B76372C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{29621F4C-F190-41AF-882C-E8408B76372C}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{29621F4C-F190-41AF-882C-E8408B76372C}.Debug|x64.ActiveCfg = Debug|x64
19+
{29621F4C-F190-41AF-882C-E8408B76372C}.Debug|x64.Build.0 = Debug|x64
20+
{29621F4C-F190-41AF-882C-E8408B76372C}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{29621F4C-F190-41AF-882C-E8408B76372C}.Release|Any CPU.Build.0 = Release|Any CPU
22+
{29621F4C-F190-41AF-882C-E8408B76372C}.Release|x64.ActiveCfg = Release|x64
23+
{29621F4C-F190-41AF-882C-E8408B76372C}.Release|x64.Build.0 = Release|x64
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {5D2D99F3-CF72-47D5-829B-243720E423F6}
30+
EndGlobalSection
31+
EndGlobal

TextureMerge/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>

TextureMerge/App.xaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<Application x:Class="TextureMerge.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:local="clr-namespace:TextureMerge"
5+
StartupUri="MainWindow.xaml">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<Style TargetType="local:MainWindow">
9+
<Setter Property="Background" Value="#FF34363A"/>
10+
</Style>
11+
<Style TargetType="local:Resize">
12+
<Setter Property="Background" Value="#FF34363A"/>
13+
</Style>
14+
<Style TargetType="Label">
15+
<Setter Property="Foreground" Value="White"/>
16+
</Style>
17+
<Style TargetType="CheckBox">
18+
<Setter Property="Foreground" Value="White"/>
19+
</Style>
20+
<Style TargetType="TextBox">
21+
<Setter Property="Foreground" Value="White"/>
22+
<Setter Property="Background" Value="Transparent"/>
23+
<Setter Property="BorderBrush" Value="#FF0097F5"/>
24+
<Setter Property="Padding" Value="3,3,3,3"/>
25+
</Style>
26+
<Style TargetType="Border">
27+
<Setter Property="BorderBrush" Value="#FF007AC8" />
28+
<Setter Property="CornerRadius" Value="5,5,5,5" />
29+
<Setter Property="BorderThickness" Value="1,1,1,1" />
30+
</Style>
31+
<Style TargetType="Button">
32+
<Setter Property="Background" Value="Transparent"/>
33+
<Setter Property="Foreground" Value="White"/>
34+
<Setter Property="MinHeight" Value="25"/>
35+
<Setter Property="Template">
36+
<Setter.Value>
37+
<ControlTemplate TargetType="{x:Type Button}">
38+
<Border Background="{TemplateBinding Background}"
39+
BorderBrush="#FF007AC8"
40+
BorderThickness="2,2,2,2"
41+
CornerRadius="10,10,10,10">
42+
<ContentPresenter
43+
HorizontalAlignment="Center"
44+
VerticalAlignment="Center"
45+
Margin="10,0,10,0"/>
46+
</Border>
47+
</ControlTemplate>
48+
</Setter.Value>
49+
</Setter>
50+
<Style.Triggers>
51+
<Trigger Property="IsMouseOver" Value="True">
52+
<Setter Property="Background" Value="#FF2C5067"/>
53+
</Trigger>
54+
<Trigger Property="IsPressed" Value="True">
55+
<Setter Property="Background" Value="#FF182B37"/>
56+
</Trigger>
57+
</Style.Triggers>
58+
</Style>
59+
</ResourceDictionary>
60+
</Application.Resources>
61+
</Application>

TextureMerge/App.xaml.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System.Windows;
2+
3+
namespace TextureMerge
4+
{
5+
public partial class App : Application
6+
{
7+
}
8+
}

TextureMerge/Extensions.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using System.Windows.Media;
5+
using ImageMagick;
6+
7+
namespace TextureMerge
8+
{
9+
public enum Channel : int { Red, Green, Blue, Alpha }
10+
11+
public static class Extensions
12+
{
13+
public static ImageSource ToImageSource(this MagickImage image)
14+
{
15+
var stream = new MemoryStream();
16+
image.Format = MagickFormat.Png;
17+
image.Write(stream);
18+
return (ImageSource)new ImageSourceConverter().ConvertFrom(stream);
19+
}
20+
21+
public static void Save(this MagickImage bitmap, string saveFilePath)
22+
{
23+
if (!Directory.Exists(Path.GetDirectoryName(saveFilePath)))
24+
throw new ArgumentException("Invalid path");
25+
26+
using (FileStream stream = new FileStream(saveFilePath, FileMode.Create)) {
27+
bitmap.Format = GetExtension(Path.GetExtension(saveFilePath));
28+
bitmap.Write(stream);
29+
stream.Close();
30+
}
31+
}
32+
33+
public static Task SaveAsync(this MagickImage bitmap, string saveFilePath)
34+
{
35+
return Task.Run(() => bitmap.Save(saveFilePath));
36+
}
37+
38+
private static MagickFormat GetExtension(string ext)
39+
{
40+
switch (ext)
41+
{
42+
//This is some formats that are supported by ImageMagick
43+
case ".png": return MagickFormat.Png;
44+
case ".jpg": return MagickFormat.Jpeg;
45+
case ".jpeg": return MagickFormat.Jpeg;
46+
case ".bmp": return MagickFormat.Bmp;
47+
case ".gif": return MagickFormat.Gif;
48+
case ".tiff": return MagickFormat.Tiff;
49+
case ".tif": return MagickFormat.Tiff;
50+
case ".tga": return MagickFormat.Tga;
51+
case ".webp": return MagickFormat.WebP;
52+
case ".pdf": return MagickFormat.Pdf;
53+
case ".psd": return MagickFormat.Psd;
54+
case ".dib": return MagickFormat.Dib;
55+
case ".ico": return MagickFormat.Ico;
56+
case ".svg": return MagickFormat.Svg;
57+
default: throw new ArgumentException("Invalid extension");
58+
};
59+
}
60+
}
61+
}

TextureMerge/MainWindow.xaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<Window x:Class="TextureMerge.MainWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:TextureMerge"
7+
mc:Ignorable="d"
8+
Title="Texture Merge"
9+
Height="500" Width="1100"
10+
MinWidth="600" MinHeight="350">
11+
<Window.Resources>
12+
<ResourceDictionary>
13+
<Style x:Key="bigLabelStyle" TargetType="Label" BasedOn="{StaticResource {x:Type Label}}">
14+
<Setter Property="FontSize" Value="20"/>
15+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
16+
<Setter Property="VerticalContentAlignment" Value="Center"/>
17+
</Style>
18+
</ResourceDictionary>
19+
</Window.Resources>
20+
<Grid>
21+
<Grid.RowDefinitions>
22+
<RowDefinition Height="*"/>
23+
<RowDefinition Height="30"/>
24+
<RowDefinition Height="50"/>
25+
<RowDefinition Height="40"/>
26+
</Grid.RowDefinitions>
27+
<Grid Grid.Row="0" Margin="50,30,50,10">
28+
<Grid.ColumnDefinitions>
29+
<ColumnDefinition Width="*"/>
30+
<ColumnDefinition Width="*"/>
31+
<ColumnDefinition Width="*"/>
32+
<ColumnDefinition Width="*"/>
33+
</Grid.ColumnDefinitions>
34+
<Grid Grid.Column="0" Margin="5,0,5,0">
35+
<Label x:Name="redNoDataLabel" Content="No Image" Style="{StaticResource bigLabelStyle}"/>
36+
<Border>
37+
<Image x:Name="RedCh" Margin="10,10,10,40"/>
38+
</Border>
39+
<Label Content="R" HorizontalAlignment="Center" VerticalAlignment="Top" Background="#FFCC0000" FontSize="16"/>
40+
<Grid Height="45" VerticalAlignment="Bottom">
41+
<Grid.ColumnDefinitions>
42+
<ColumnDefinition Width="7*"/>
43+
<ColumnDefinition Width="5*"/>
44+
</Grid.ColumnDefinitions>
45+
<Button Content="Load" Grid.Column="0" Margin="10,10,5,10" Click="ButtonLoadR" />
46+
<Button Content="Clear" Grid.Column="1" Margin="5,10,10,10" Click="ButtonClearR" />
47+
</Grid>
48+
</Grid>
49+
<Grid Grid.Column="1" Margin="5,0,5,0">
50+
<Label x:Name="greenNoDataLabel" Content="No Image" Style="{StaticResource bigLabelStyle}"/>
51+
<Border>
52+
<Image x:Name="GreenCh" Margin="10,10,10,40"/>
53+
</Border>
54+
<Label Content="G" HorizontalAlignment="Center" VerticalAlignment="Top" Background="#FF00CC00" FontSize="16"/>
55+
<Grid Height="45" VerticalAlignment="Bottom">
56+
<Grid.ColumnDefinitions>
57+
<ColumnDefinition Width="7*"/>
58+
<ColumnDefinition Width="5*"/>
59+
</Grid.ColumnDefinitions>
60+
<Button Content="Load" Grid.Column="0" Margin="10,10,5,10" Click="ButtonLoadG" />
61+
<Button Content="Clear" Grid.Column="1" Margin="5,10,10,10" Click="ButtonClearG" />
62+
</Grid>
63+
</Grid>
64+
<Grid Grid.Column="2" Margin="5,0,5,0">
65+
<Label x:Name="blueNoDataLabel" Content="No Image" Style="{StaticResource bigLabelStyle}"/>
66+
<Border>
67+
<Image x:Name="BlueCh" Margin="10,10,10,40"/>
68+
</Border>
69+
<Label Content="B" HorizontalAlignment="Center" VerticalAlignment="Top" Background="#FF0000CC" FontSize="16"/>
70+
<Grid Height="45" VerticalAlignment="Bottom">
71+
<Grid.ColumnDefinitions>
72+
<ColumnDefinition Width="7*"/>
73+
<ColumnDefinition Width="5*"/>
74+
</Grid.ColumnDefinitions>
75+
<Button Content="Load" Grid.Column="0" Margin="10,10,5,10" Click="ButtonLoadB" />
76+
<Button Content="Clear" Grid.Column="1" Margin="5,10,10,10" Click="ButtonClearB" />
77+
</Grid>
78+
</Grid>
79+
<Grid Grid.Column="3" Margin="5,0,5,0">
80+
<Label x:Name="alphaNoDataLabel" Content="No Image" Style="{StaticResource bigLabelStyle}"/>
81+
<Border>
82+
<Image x:Name="AlphaCh" Margin="10,10,10,40"/>
83+
</Border>
84+
<Label Content="A" HorizontalAlignment="Center" VerticalAlignment="Top" Background="#FFCCCCCC" FontSize="16"/>
85+
<Grid Height="45" VerticalAlignment="Bottom">
86+
<Grid.ColumnDefinitions>
87+
<ColumnDefinition Width="7*"/>
88+
<ColumnDefinition Width="5*"/>
89+
</Grid.ColumnDefinitions>
90+
<Button Content="Load" Grid.Column="0" Margin="10,10,5,10" Click="ButtonLoadA" />
91+
<Button Content="Clear" Grid.Column="1" Margin="5,10,10,10" Click="ButtonClearA" />
92+
</Grid>
93+
</Grid>
94+
</Grid>
95+
<Grid Grid.Row="1" Margin="0,0,50,0" VerticalAlignment="Center" HorizontalAlignment="Right">
96+
<Label Content="Color when no image provided: " HorizontalAlignment="Left" Margin="0,0,100,0" VerticalAlignment="Center"/>
97+
<Rectangle x:Name="DefaultColorRect" Fill="Black" Height="20" Width="20" HorizontalAlignment="Right" Margin="0,0,70,0"/>
98+
<Button Content="Change" HorizontalAlignment="Right" VerticalAlignment="Center" Click="ChangeDefaultColor"/>
99+
</Grid>
100+
<Grid Grid.Row="2" VerticalAlignment="Bottom" Margin="0,0,0,0">
101+
<Grid.ColumnDefinitions>
102+
<ColumnDefinition Width="15*"/>
103+
<ColumnDefinition Width="7*"/>
104+
</Grid.ColumnDefinitions>
105+
<Grid Grid.Column="0" Margin="20,0,10,0" Height="25" VerticalAlignment="Center">
106+
<TextBox x:Name="PathToSave" Margin="0,0,90,0" TextAlignment="Right" Text="C:\Users\user\Documents" TextChanged="PathToSaveChanged"/>
107+
<Button Content="Browse" HorizontalAlignment="Right" Width="80" Click="ButtonBrowse"/>
108+
</Grid>
109+
<Grid Grid.Column="1" Margin="20,0,10,0" Height="25" VerticalAlignment="Center">
110+
<TextBox x:Name="SaveImageName" Margin="0,0,90,0" TextAlignment="Right" Text="Pack.png" TextChanged="SaveImageNameChanged"/>
111+
<Button Content="Merge" HorizontalAlignment="Right" Width="80" Click="ButtonMerge"/>
112+
</Grid>
113+
</Grid>
114+
<Grid Grid.Row="3">
115+
<Label x:Name="StatusLabel" Content="" Margin="0,0,30,0" VerticalAlignment="Center" HorizontalAlignment="Right" FontSize="16" FontWeight="Bold"/>
116+
</Grid>
117+
</Grid>
118+
</Window>

0 commit comments

Comments
 (0)