Skip to content

Commit

Permalink
Update all
Browse files Browse the repository at this point in the history
- Bump packages
- Revamp UI
- Additional decoding options
  • Loading branch information
iMrShadow committed Jul 24, 2024
1 parent 1435e48 commit b535d2d
Show file tree
Hide file tree
Showing 70 changed files with 11,161 additions and 634 deletions.
164 changes: 162 additions & 2 deletions TelltaleTextureTool/TelltaleTextureTool/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,175 @@
<!-- <Setter Property="Background" Value="#FFDDDDDD" /> -->
<!-- </Style> -->
<avalonia:HyperLinkStyle />

<Style Selector="mscontrols|MsBoxStandardView">
<Setter Property="Background"
Value="#424242" />
Value="{DynamicResource ButtonColor}" />
</Style>

<Style Selector="Button:disabled">
<Setter Property="Background"
Value="#ffffff" />
</Style>
<FluentTheme>

<!-- this is pointover for expander -->
<Style Selector="Expander:pointerover/template/ToggleButton">
<Setter Property="Background"
Value="{DynamicResource ButtonColor}" />
</Style>

<Style Selector="Expander/template/ToggleButton">
<Setter Property="Background"
Value="{DynamicResource ButtonColor}" />
</Style>


<!--<Style Selector="Expander:pointerover/template/Border#ToggleButtonBackground">
<Setter Property="Background"
Value="#ff0000" />
</Style>
<Style Selector="Expander/template/Border#ToggleButtonBackground">
<Setter Property="Background"
Value="#ff0000" />
</Style>-->

<!--<Style Selector="Expander/template/ToggleButton:pointerover">
<Setter Property="Background"
Value="#ff0000" />
</Style>-->


<Style Selector="Expander /template/ ToggleButton:pointerover /template/ Border#ToggleButtonBackground">
<Setter Property="Background"
Value="{DynamicResource ButtonColor}" />
</Style>


<!--<Style Selector="Slider:horizontal/template/ Track#PART_Track.Grid">
<Setter Property="Height" Value="20" />
</Style>
<Style Selector="Slider:horizontal/template/RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="#ff0000" />
</Style>
<Style Selector="Slider:horizontal/template/RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="#ff0000" />
</Style>
<Style Selector="Slider:horizontal/template/ Border#TrackBackground">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
<Style Selector="Slider/template/">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
<Style Selector="Slider:horizontal/template/ Border#TrackBackground/template/">
<Setter Property="BorderThickness" Value="20" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}" />
</Style>
--><!--<Style Selector="Slider:horizontal/template/ TickBar">
<Setter Property="BorderThickness" Value="20" />
</Style>--><!--
<Style Selector="Slider:horizontal/template/ Grid#grid">
</Style>
<Style Selector="Slider:horizontal/template/ Thumb#thumb">
<Setter Property="Background" Value="#ff0000" />
</Style>-->

<Style Selector="Slider/template/Grid#SliderContainer">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Height" Value="50" />
<Setter Property="Margin" Value="0" />
</Style>

<Style Selector="Slider/template/TickBar#TopTickBar">
<Setter Property="Margin" Value="0" />
<Setter Property="Height" Value="0" />
</Style>

<Style Selector="Slider/template/TickBar#BottomTickBar">
<Setter Property="Margin" Value="0" />
<Setter Property="Height" Value="0" />
</Style>

<Style Selector="Slider/template/RepeatButton#PART_IncreaseButton">
<Setter Property="Background" Value="{DynamicResource PanelSplitterColor}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="{DynamicResource PanelSplitterColor}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<!-- Customize the content of the button here -->

</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<!-- Style for the Decrease Button -->
<Style Selector="Slider/template/RepeatButton#PART_DecreaseButton">
<Setter Property="Background" Value="{DynamicResource PanelSplitterColor}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Background="{DynamicResource PanelSplitterColor}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<!-- Customize the content of the button here -->

</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style Selector="Slider/template/Thumb">
<Setter Property="Background" Value="{DynamicResource PanelSplitterColor}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="{DynamicResource PanelSplitterColor}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Border Background="{DynamicResource PanelSplitterColor}" Margin="0,1,0,1"
BorderBrush="{DynamicResource PanelSplitterColor}"
BorderThickness="2"

>
<!-- Customize the content of the Thumb here -->
<Label CornerRadius="3" Width="12" Background="Gray" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


<!-- Thumb PointerOver State -->
<Style Selector="Thumb:pointerover">
<Setter Property="Background" Value="Transparent" />
</Style>

<!-- Thumb Pressed State -->
<Style Selector="Thumb:pressed">
<Setter Property="Background" Value="Transparent" />
</Style>

<FluentTheme>
<FluentTheme.Palettes>
<!-- Palette for Light theme variant -->
<ColorPaletteResources x:Key="Light"
Expand Down
56 changes: 32 additions & 24 deletions TelltaleTextureTool/TelltaleTextureTool/GUI/ImageData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,34 @@ private void GetImageData(string filePath, TextureType textureType, out Bitmap b

private void GetImageDataFromOthers(string filePath, out Bitmap bitmap, out ImageProperties imageProperties)
{
bitmap = new Bitmap(filePath);

var imageInfo = SixLabors.ImageSharp.Image.Identify(filePath);
var image = SixLabors.ImageSharp.Image.Load<Rgba32>(filePath);

bool hasAlpha = ImageUtilities.IsImageOpaque(image);
string hasAlphaString = hasAlpha ? "True" : "False";

imageProperties = new ImageProperties()
// Load the image using SkiaSharp
using (var skBitmap = SKBitmap.Decode(filePath))
{
Name = Path.GetFileNameWithoutExtension(filePath),
Extension = Path.GetExtension(filePath),
CompressionType = imageInfo.Metadata.DecodedImageFormat.Name,
ChannelCount = (imageInfo.PixelType.BitsPerPixel / 8).ToString(),
Height = imageInfo.Height.ToString(),
Width = imageInfo.Width.ToString(),
HasAlpha = hasAlphaString,
MipMapCount = "N/A"
};
// Create a memory stream to hold the image data
using (var ms = new MemoryStream())
{
// Encode the SKBitmap to a PNG and write to the memory stream
skBitmap.Encode(ms, SKEncodedImageFormat.Png, 100);
ms.Seek(0, SeekOrigin.Begin); // Rewind the stream to the beginning

// Create an Avalonia Bitmap from the memory stream
bitmap = new Bitmap(ms);
}

string hasAlphaString = skBitmap.Info.IsOpaque ? "True" : "False";

imageProperties = new ImageProperties()
{
Name = Path.GetFileNameWithoutExtension(filePath),
Extension = Path.GetExtension(filePath),
SurfaceFormat = skBitmap.ColorType.ToString(),
ChannelCount = (skBitmap.BytesPerPixel*8).ToString(),
Height = skBitmap.Height.ToString(),
Width = skBitmap.Width.ToString(),
HasAlpha = hasAlphaString,
MipMapCount = "N/A" // SkiaSharp does not provide mipmap count directly
};
}
}

private void GetImageDataFromD3DTX(string filePath, D3DTXVersion d3DTXVersion, out Bitmap bitmap, out ImageProperties imageProperties)
Expand All @@ -94,7 +103,7 @@ private void GetImageDataFromD3DTX(string filePath, D3DTXVersion d3DTXVersion, o
imageProperties = new ImageProperties()
{
Name = metadata.TextureName,
CompressionType = d3dtx.GetStringFormat(),
SurfaceFormat = d3dtx.GetStringFormat(),
Width = metadata.Width.ToString(),
Height = metadata.Height.ToString(),
HasAlpha = d3dtx.GetHasAlpha(),
Expand Down Expand Up @@ -131,7 +140,7 @@ private void GetImageDataFromTIFF(string filePath, out Bitmap bitmap, out ImageP
{
Name = Path.GetFileNameWithoutExtension(filePath),
Extension = Path.GetExtension(filePath),
CompressionType = imageInfo.Metadata.DecodedImageFormat.Name,
SurfaceFormat = imageInfo.Metadata.DecodedImageFormat.Name,
ChannelCount = (imageInfo.PixelType.BitsPerPixel / 8).ToString(),
Height = imageInfo.Height.ToString(),
Width = imageInfo.Width.ToString(),
Expand All @@ -147,7 +156,7 @@ private void GetImageDataFromInvalid(out Bitmap? bitmap, out ImageProperties ima
imageProperties = new ImageProperties()
{
Name = "",
CompressionType = "",
SurfaceFormat = "",
ChannelCount = "",
Height = "",
Width = "",
Expand Down Expand Up @@ -303,7 +312,6 @@ private static Bitmap GetDDSBitmap(IImage image)
throw new ArgumentException($"Skia unable to interpret pfim format: {image.Format}");
}


// Converts the data into writeableBitmap. (TODO Insert a link to the code)
var imageInfo = new SKImageInfo(image.Width, image.Height, colorType);
var handle = GCHandle.Alloc(newData, GCHandleType.Pinned);
Expand Down Expand Up @@ -339,7 +347,7 @@ private static ImageProperties GetKtx2Properties(string ddsFilePath)
Extension = ".ktx2",
Height = texture.BaseHeight.ToString(),
Width = texture.BaseWidth.ToString(),
CompressionType = texture.VkFormat.ToString(),
SurfaceFormat = texture.VkFormat.ToString(),
HasAlpha = KTX2_HELPER.HasAlpha(texture.VkFormat) ? "True" : "False",
//ChannelCount = Helper.GetDataFormatDescriptor(texture.VkFormat).DescriptorBlockSize.ToString(),
MipMapCount = texture.NumLevels.ToString()
Expand All @@ -351,7 +359,7 @@ public static ImageProperties GetImagePropertiesFromInvalid()
return new ImageProperties()
{
Name = "",
CompressionType = "",
SurfaceFormat = "",
ChannelCount = "",
Height = "",
Width = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class ImageProperties : ObservableObject
public string? Extension { get; set; }
public string? Width { get; set; }
public string? Height { get; set; }
public string? CompressionType { get; set; }
public string? SurfaceFormat { get; set; }
public string? HasAlpha { get; set; }
public string? BitsPerPixel { get; set; }
public string? ChannelCount { get; set; }
Expand Down
Loading

0 comments on commit b535d2d

Please sign in to comment.