mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-13 19:19:10 +00:00
Add Pixso (.pip, .pix) support to ThumbnailViewer
This commit is contained in:
@@ -20,6 +20,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ public class Plugin : IViewer
|
|||||||
if (WellKnownExtensions.Any(ext => path.EndsWith(ext, StringComparison.OrdinalIgnoreCase)))
|
if (WellKnownExtensions.Any(ext => path.EndsWith(ext, StringComparison.OrdinalIgnoreCase)))
|
||||||
return true;
|
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);
|
using var s = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||||
const int bufferLength = 16 * 1024;
|
const int bufferLength = 16 * 1024;
|
||||||
var buffer = new byte[bufferLength];
|
var buffer = new byte[bufferLength];
|
||||||
@@ -91,6 +92,7 @@ public class Plugin : IViewer
|
|||||||
_tvp = null;
|
_tvp = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static bool IsText(IReadOnlyList<byte> buffer, int size)
|
private static bool IsText(IReadOnlyList<byte> buffer, int size)
|
||||||
{
|
{
|
||||||
for (var i = 1; i < size; i++)
|
for (var i = 1; i < size; i++)
|
||||||
|
@@ -60,6 +60,20 @@ internal static class Handler
|
|||||||
context.PreferredSize = new Size { Width = 100, Height = 100 };
|
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))
|
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -155,6 +169,32 @@ internal static class Handler
|
|||||||
StreamResourceInfo info = Application.GetResourceStream(new Uri("pack://application:,,,/QuickLook.Plugin.ThumbnailViewer;component/Resources/broken.png"));
|
StreamResourceInfo info = Application.GetResourceStream(new Uri("pack://application:,,,/QuickLook.Plugin.ThumbnailViewer;component/Resources/broken.png"));
|
||||||
return info?.Stream;
|
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))
|
else if (path.EndsWith(".xmind", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
using ZipArchive archive = ZipArchive.Open(path, new());
|
using ZipArchive archive = ZipArchive.Open(path, new());
|
||||||
|
@@ -33,6 +33,7 @@ public class Plugin : IViewer
|
|||||||
".cdr", // CorelDraw
|
".cdr", // CorelDraw
|
||||||
".fig", // Figma
|
".fig", // Figma
|
||||||
".kra", // Krita
|
".kra", // Krita
|
||||||
|
".pip", ".pix", // Pixso
|
||||||
".xd", // AdobeXD
|
".xd", // AdobeXD
|
||||||
".xmind", // XMind
|
".xmind", // XMind
|
||||||
]);
|
]);
|
||||||
|
Reference in New Issue
Block a user