Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions FModel/Extensions/ImageExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using SkiaSharp;

namespace FModel.Extensions
{
public static class ImageExtensions
{
public static unsafe void ARGBtoABGR(this SKBitmap bitmap)
{
if (bitmap.ColorType != SKColorType.Bgra8888 && bitmap.ColorType != SKColorType.Rgba8888)
return;

var pixels = (uint*)bitmap.GetPixels().ToPointer();
int length = bitmap.Width * bitmap.Height;

for (int i = 0; i < length; i++)
{
uint pixel = pixels[i];
uint a = pixel & 0xFF000000;
uint r = (pixel & 0x00FF0000) >> 16;
uint g = pixel & 0x0000FF00;
uint b = (pixel & 0x000000FF) << 16;

pixels[i] = a | b | g | r;
}
}
}
}
19 changes: 19 additions & 0 deletions FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,15 @@ public void Extract(CancellationToken cancellationToken, GameFile entry, bool ad
break;
}

if (result.Package.EditorThumbnails != null)
{
foreach (var Rawthumbnail in result.Package.EditorThumbnails)
{
var bitmap = SKBitmap.Decode(Rawthumbnail);
ImageExtensions.ARGBtoABGR(bitmap); // Thumbnails are stored as ARGB
TabControl.SelectedTab.AddImage(entry.NameWithoutExtension, false, bitmap, false, true);
}
}
break;
}
case "ini" when entry.Name.Contains("BinaryConfig"):
Expand Down Expand Up @@ -846,6 +855,16 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
if (CheckExport(cancellationToken, result.Package, i))
break;
}

if (result.Package.EditorThumbnails != null)
{
foreach (var Rawthumbnail in result.Package.EditorThumbnails)
{
var bitmap = SKBitmap.Decode(Rawthumbnail);
ImageExtensions.ARGBtoABGR(bitmap); // Thumbnails are stored as ARGB
TabControl.SelectedTab.AddImage(entry.NameWithoutExtension, false, bitmap, false, true);
}
}
}

private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, EBulkType bulk = EBulkType.None) // return true once you want to stop searching for exports
Expand Down
7 changes: 7 additions & 0 deletions FModel/ViewModels/TabControlViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,13 @@ public void AddImage(UTexture texture, bool save, bool updateUi)
{
var appendLayerNumber = false;
var img = new CTexture[1];

if (texture.EditorData?.Header?.TotalRawSize > 0)
{
var bitmap = SKBitmap.Decode(texture.EditorData.RawData);
AddImage(texture.Name, texture.RenderNearestNeighbor, bitmap, save, updateUi);
return;
}
if (texture is UTexture2DArray textureArray)
{
img = textureArray.DecodeTextureArray(UserSettings.Default.CurrentDir.TexturePlatform);
Expand Down