Add Pixso (.pip, .pix) support to ThumbnailViewer
Some checks are pending
MSBuild / build (push) Waiting to run
MSBuild / publish (push) Blocked by required conditions

This commit is contained in:
ema
2025-07-08 22:28:08 +08:00
parent c47d9f3c9b
commit a6c077fbbb
3 changed files with 44 additions and 1 deletions

View File

@@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
@@ -48,7 +49,7 @@ public class Plugin : IViewer
if (WellKnownExtensions.Any(ext => path.EndsWith(ext, StringComparison.OrdinalIgnoreCase)))
return true;
// Read the first 16KB, check if we can get something.
// Read the first 16KB, check if we can get something
using var s = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
const int bufferLength = 16 * 1024;
var buffer = new byte[bufferLength];
@@ -91,6 +92,7 @@ public class Plugin : IViewer
_tvp = null;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsText(IReadOnlyList<byte> buffer, int size)
{
for (var i = 1; i < size; i++)

View File

@@ -60,6 +60,20 @@ internal static class Handler
context.PreferredSize = new Size { Width = 100, Height = 100 };
}
}
else if (path.EndsWith(".pip", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".pix", StringComparison.OrdinalIgnoreCase))
{
try
{
using Stream imageData = ViewImage(path);
BitmapImage bitmap = imageData.ReadAsBitmapImage();
context.SetPreferredSizeFit(new Size(bitmap.PixelWidth, bitmap.PixelHeight), 0.8d);
}
catch (Exception e)
{
_ = e;
context.PreferredSize = new Size { Width = 100, Height = 100 };
}
}
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
{
try
@@ -155,6 +169,32 @@ internal static class Handler
StreamResourceInfo info = Application.GetResourceStream(new Uri("pack://application:,,,/QuickLook.Plugin.ThumbnailViewer;component/Resources/broken.png"));
return info?.Stream;
}
else if (path.EndsWith(".pip", StringComparison.OrdinalIgnoreCase) || path.EndsWith(".pix", StringComparison.OrdinalIgnoreCase))
{
try
{
using ZipArchive archive = ZipArchive.Open(path, new());
using IReader reader = archive.ExtractAllEntries();
while (reader.MoveToNextEntry())
{
if (reader.Entry.Key!.EndsWith(".thumb.png", StringComparison.OrdinalIgnoreCase))
{
MemoryStream ms = new();
using EntryStream stream = reader.OpenEntryStream();
stream.CopyTo(ms);
return ms;
}
}
}
catch
{
///
}
StreamResourceInfo info = Application.GetResourceStream(new Uri("pack://application:,,,/QuickLook.Plugin.ThumbnailViewer;component/Resources/broken.png"));
return info?.Stream;
}
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
{
using ZipArchive archive = ZipArchive.Open(path, new());

View File

@@ -33,6 +33,7 @@ public class Plugin : IViewer
".cdr", // CorelDraw
".fig", // Figma
".kra", // Krita
".pip", ".pix", // Pixso
".xd", // AdobeXD
".xmind", // XMind
]);