Skip to content

Commit

Permalink
Merge branch 'master' into feat-corel-pal-format
Browse files Browse the repository at this point in the history
  • Loading branch information
flabbet committed Jan 11, 2024
2 parents 69ab14d + 28b2998 commit 5a347d0
Show file tree
Hide file tree
Showing 50 changed files with 1,585 additions and 909 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -98,4 +98,4 @@ Please read [CONTRIBUTING.md](https://github.com/flabbet/PixiEditor/blob/master/

## License

This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/flabbet/PixiEditor/blob/master/LICENSE) - file for details
This project is licensed under the LGPLv3 License - see the [LICENSE.md](https://github.com/flabbet/PixiEditor/blob/master/LICENSE) - file for details
36 changes: 18 additions & 18 deletions src/ChunkyImageLib/Operations/OperationHelper.cs
Expand Up @@ -120,25 +120,25 @@ public static Matrix3X3 CreateMatrixFromPoints(ShapeCorners corners, VecD size)
=> CreateMatrixFromPoints((Point)corners.TopLeft, (Point)corners.TopRight, (Point)corners.BottomRight, (Point)corners.BottomLeft, (float)size.X, (float)size.Y);

// see https://stackoverflow.com/questions/48416118/perspective-transform-in-skia/72364829#72364829
public static Matrix3X3 CreateMatrixFromPoints(Point topLeft, Point topRight, Point botRight, Point botLeft, float width, float height)
public static Matrix3X3 CreateMatrixFromPoints(Point topLeft, Point topRight, Point botRight, Point botLeft, double width, double height)
{
(float x1, float y1) = (topLeft.X, topLeft.Y);
(float x2, float y2) = (topRight.X, topRight.Y);
(float x3, float y3) = (botRight.X, botRight.Y);
(float x4, float y4) = (botLeft.X, botLeft.Y);
(float w, float h) = (width, height);

float scaleX = (y1 * x2 * x4 - x1 * y2 * x4 + x1 * y3 * x4 - x2 * y3 * x4 - y1 * x2 * x3 + x1 * y2 * x3 - x1 * y4 * x3 + x2 * y4 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
float skewX = (-x1 * x2 * y3 - y1 * x2 * x4 + x2 * y3 * x4 + x1 * x2 * y4 + x1 * y2 * x3 + y1 * x4 * x3 - y2 * x4 * x3 - x1 * y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
float transX = x1;
float skewY = (-y1 * x2 * y3 + x1 * y2 * y3 + y1 * y3 * x4 - y2 * y3 * x4 + y1 * x2 * y4 - x1 * y2 * y4 - y1 * y4 * x3 + y2 * y4 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
float scaleY = (-y1 * x2 * y3 - y1 * y2 * x4 + y1 * y3 * x4 + x1 * y2 * y4 - x1 * y3 * y4 + x2 * y3 * y4 + y1 * y2 * x3 - y2 * y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
float transY = y1;
float persp0 = (x1 * y3 - x2 * y3 + y1 * x4 - y2 * x4 - x1 * y4 + x2 * y4 - y1 * x3 + y2 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
float persp1 = (-y1 * x2 + x1 * y2 - x1 * y3 - y2 * x4 + y3 * x4 + x2 * y4 + y1 * x3 - y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
float persp2 = 1;

return new Matrix3X3(scaleX, skewX, transX, skewY, scaleY, transY, persp0, persp1, persp2);
(double x1, double y1) = (topLeft.X, topLeft.Y);
(double x2, double y2) = (topRight.X, topRight.Y);
(double x3, double y3) = (botRight.X, botRight.Y);
(double x4, double y4) = (botLeft.X, botLeft.Y);
(double w, double h) = (width, height);

double scaleX = (y1 * x2 * x4 - x1 * y2 * x4 + x1 * y3 * x4 - x2 * y3 * x4 - y1 * x2 * x3 + x1 * y2 * x3 - x1 * y4 * x3 + x2 * y4 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
double skewX = (-x1 * x2 * y3 - y1 * x2 * x4 + x2 * y3 * x4 + x1 * x2 * y4 + x1 * y2 * x3 + y1 * x4 * x3 - y2 * x4 * x3 - x1 * y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
double transX = x1;
double skewY = (-y1 * x2 * y3 + x1 * y2 * y3 + y1 * y3 * x4 - y2 * y3 * x4 + y1 * x2 * y4 - x1 * y2 * y4 - y1 * y4 * x3 + y2 * y4 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
double scaleY = (-y1 * x2 * y3 - y1 * y2 * x4 + y1 * y3 * x4 + x1 * y2 * y4 - x1 * y3 * y4 + x2 * y3 * y4 + y1 * y2 * x3 - y2 * y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
double transY = y1;
double persp0 = (x1 * y3 - x2 * y3 + y1 * x4 - y2 * x4 - x1 * y4 + x2 * y4 - y1 * x3 + y2 * x3) / (x2 * y3 * w + y2 * x4 * w - y3 * x4 * w - x2 * y4 * w - y2 * w * x3 + y4 * w * x3);
double persp1 = (-y1 * x2 + x1 * y2 - x1 * y3 - y2 * x4 + y3 * x4 + x2 * y4 + y1 * x3 - y4 * x3) / (x2 * y3 * h + y2 * x4 * h - y3 * x4 * h - x2 * y4 * h - y2 * h * x3 + y4 * h * x3);
double persp2 = 1;

return new Matrix3X3((float)scaleX, (float)skewX, (float)transX, (float)skewY, (float)scaleY, (float)transY, (float)persp0, (float)persp1, (float)persp2);
}

public static (ShapeCorners, ShapeCorners) CreateStretchedHexagon(VecD centerPos, double hexagonSide, double stretchX)
Expand Down
5 changes: 4 additions & 1 deletion src/ChunkyImageLib/Surface.cs
@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using PixiEditor.DrawingApi.Core.ColorsImpl;
using PixiEditor.DrawingApi.Core.Numerics;
Expand Down Expand Up @@ -131,6 +132,7 @@ public unsafe bool IsFullyTransparent()
return true;
}

#if DEBUG
public void SaveToDesktop(string filename = "savedSurface.png")
{
using var final = DrawingSurface.Create(new ImageInfo(Size.X, Size.Y, ColorType.Rgba8888, AlphaType.Premul, ColorSpace.CreateSrgb()));
Expand All @@ -142,6 +144,7 @@ public void SaveToDesktop(string filename = "savedSurface.png")
png.SaveTo(stream);
}
}
#endif

private DrawingSurface CreateDrawingSurface()
{
Expand Down
Expand Up @@ -48,8 +48,6 @@ public override bool InitializeAndValidate(Document target)
image.SetBlendMode(blendMode);

var selectionImage = FloodFillHelper.FillSelection(target, selection!);

selectionImage.SaveToDesktop();

image.EnqueueDrawImage(new VecI(0, 0), selectionImage);

Expand Down
5 changes: 5 additions & 0 deletions src/PixiEditor.DrawingApi.Core/Surface/Pixmap.cs
Expand Up @@ -9,6 +9,11 @@ public class Pixmap : NativeObject
internal Pixmap(IntPtr objPtr) : base(objPtr)
{
}

public static Pixmap InternalCreateFromExistingPointer(IntPtr objPointer)
{
return new Pixmap(objPointer);
}

public Pixmap(ImageInfo imgInfo, IntPtr dataPtr) : base(dataPtr)
{
Expand Down
Expand Up @@ -99,7 +99,7 @@ public void Transform(VectorPath vectorPath, Matrix3X3 matrix)
public RectD GetBounds(VectorPath vectorPath)
{
SKRect rect = ManagedInstances[vectorPath.ObjectPointer].Bounds;
return new RectD(rect.Left, rect.Top, rect.Right, rect.Bottom);
return RectD.FromSides(rect.Left, rect.Right, rect.Top, rect.Bottom);
}

public void Reset(VectorPath vectorPath)
Expand Down
Expand Up @@ -57,7 +57,7 @@ public int GetBytesSize(Pixmap pixmap)
public Pixmap CreateFrom(SKPixmap pixmap)
{
ManagedInstances[pixmap.Handle] = pixmap;
return new Pixmap(pixmap.Info.ToImageInfo(colorSpaceImplementation), pixmap.GetPixels());
return Pixmap.InternalCreateFromExistingPointer(pixmap.Handle);
}
}
}
58 changes: 38 additions & 20 deletions src/PixiEditor/App.xaml.cs
Expand Up @@ -6,6 +6,7 @@
using System.Windows.Media;
using System.Windows.Threading;
using PixiEditor.Extensions.Common.Localization;
using PixiEditor.Helpers;
using PixiEditor.Models.AppExtensions;
using PixiEditor.Helpers.UI;
using PixiEditor.Models.Controllers;
Expand Down Expand Up @@ -42,34 +43,37 @@ protected override void OnStartup(StartupEventArgs e)

if (ParseArgument("--crash (\"?)([A-z0-9:\\/\\ -_.]+)\\1", arguments, out Group[] groups))
{
CrashReport report = CrashReport.Parse(groups[2].Value);
MainWindow = new CrashReportDialog(report);
MainWindow.Show();
try
{
CrashReport report = CrashReport.Parse(groups[2].Value);
MainWindow = new CrashReportDialog(report);
MainWindow.Show();
}
catch (Exception exception)
{
try
{
CrashHelper.SendExceptionInfoToWebhook(exception, true);
}
finally
{
MessageBox.Show("Fatal error", $"Fatal error while trying to open crash report in App.OnStartup()\n{exception}");
}
}

return;
}

#if !STEAM
#if !STEAM
if (!HandleNewInstance())
{
return;
}
#endif

LoadingWindow.ShowInNewThread();

AddNativeAssets();

InitPlatform();

ExtensionLoader extensionLoader = new ExtensionLoader();
extensionLoader.LoadExtensions();

#endif

var extensionLoader = InitApp();

MainWindow = new MainWindow(extensionLoader);
MainWindow.ContentRendered += (_, _) =>
{
LoadingWindow.Instance.SafeClose();
MainWindow.Activate();
};
MainWindow.Show();
}

Expand All @@ -80,6 +84,20 @@ private void InitPlatform()
platform.PerformHandshake();
}

public ExtensionLoader InitApp()
{
LoadingWindow.ShowInNewThread();

AddNativeAssets();

InitPlatform();

ExtensionLoader extensionLoader = new ExtensionLoader();
extensionLoader.LoadExtensions();

return extensionLoader;
}

private IPlatform GetActivePlatform()
{
#if STEAM
Expand Down
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/ar.json
Expand Up @@ -580,5 +580,8 @@
"RIGHT_CLICK_MODE": "وضع النقر بزر الماوس الأيمن",
"ADD_PRIMARY_COLOR_TO_PALETTE": "أضف اللون الأساسي إلى لوح الألوان",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "أضف اللون الأساسي إلى اللوحة الحالية",
"COPY_COLOR": "انسخ اللون"
"COPY_COLOR": "انسخ اللون",
"ERROR_FAILED_TO_OPEN_EXPLORER": "لا يمكن فتح قائمة الملفات",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "لا يمكن استيراد الكل",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "لا يمكن استرداد الملفات بشكل كامل.\nإذا قمت بإرسال التقرير إلى المطورين\nقد يكونوا قادرين على مساعدتك."
}
7 changes: 5 additions & 2 deletions src/PixiEditor/Data/Localization/Languages/cs.json
Expand Up @@ -23,7 +23,7 @@
"UPDATE_CHANNEL_HELP_TOOLTIP": "Aktualizační kanály mohou být aktualizovány jen v samostatných verzích aplikace (stáhnutých z https://pixieditor.net/) Steam a Microsoft Store verze zacházejí s jednotlivými verzemi odlišně.",
"DEBUG": "Debug",
"ENABLE_DEBUG_MODE": "Aktivovat Debug mód",
"OPEN_CRASH_REPORTS_DIR": "Otevřít složku crash reportů",
"OPEN_CRASH_REPORTS_DIR": "Otevřít složku zpráv o selhání",
"DISCORD_RICH_PRESENCE": "Bohatá přítomnost",
"ENABLED": "Povoleno",
"SHOW_IMAGE_NAME": "Ukázat jméno obrázku",
Expand Down Expand Up @@ -580,5 +580,8 @@
"RIGHT_CLICK_MODE": "Režim pravého tlačítka",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Přidat hlavní barvu do palety",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Přidat hlavní barvu do současné palety",
"COPY_COLOR": "Zkopírovat barvu"
"COPY_COLOR": "Zkopírovat barvu",
"ERROR_FAILED_TO_OPEN_EXPLORER": "Nepodařilo se otevřít Průzkumníka Souborů",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Nepodařilo se obnovit všechno",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Nepodařilo se plně obnovit všechny soubory.\nKdyž pošlete zprávu o selhání vývojářům, možná vám budou schopni pomoct."
}
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/de.json
Expand Up @@ -580,5 +580,8 @@
"RIGHT_CLICK_MODE": "Rechtsklick Modus",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Primärfarbe zu Palette hinzufügen",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Primärfarbe der Farbpalette hinzufügen",
"COPY_COLOR": "Copy color"
"COPY_COLOR": "Farbe kopieren",
"ERROR_FAILED_TO_OPEN_EXPLORER": "Windows Explorer konnte nicht geöffnet werden",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Konnte nicht alle Dokumente wiederherstellen",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Nichte alle Dateien konnten wiederhergestellt werden.\nDie Entwickler können dir eventuell helfen,\nalle Dateien wieder herzustellen."
}
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/en.json
Expand Up @@ -589,5 +589,8 @@
"COPY_COLOR": "Copy color",

"FAILED_DOWNLOADING_TITLE": "Downloading update failed",
"FAILED_DOWNLOADING": "Failed downloading the update, you might not have enough space on the disk"
"FAILED_DOWNLOADING": "Failed downloading the update, you might not have enough space on the disk",

"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Could not recover all",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Could not fully recover all files.\nIf you send the crash report to the developers\nthey might be able to help you."
}
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/it.json
Expand Up @@ -580,5 +580,8 @@
"RIGHT_CLICK_MODE": "Modalità tasto destro",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Aggiungi colore primario alla tavolozza",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Aggiungi colore primario alla tavolozza corrente",
"COPY_COLOR": "Copia colore"
"COPY_COLOR": "Copia colore",
"ERROR_FAILED_TO_OPEN_EXPLORER": "Couldn't open File Explorer",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Could not recover all",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Could not fully recover all files.\nIf you send the crash report to the developers\nthey might be able to help you."
}
5 changes: 4 additions & 1 deletion src/PixiEditor/Data/Localization/Languages/pl.json
Expand Up @@ -580,5 +580,8 @@
"RIGHT_CLICK_MODE": "Akcja prawego przysiku myszy",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Dodaj aktywny kolor do palety",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Dodaj aktywny kolor do aktualnej palety",
"COPY_COLOR": "Kopiuj kolor"
"COPY_COLOR": "Kopiuj kolor",
"ERROR_FAILED_TO_OPEN_EXPLORER": "Nie udało się otworzyć eksploratora plików",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Nie udało się odzyskać wszystkich plików",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Nie udało się odzyskać wszystkich plików. \nJeżeli wyślesz raport awarii do developerów, być może będą w stanie Ci pomóc."
}
41 changes: 22 additions & 19 deletions src/PixiEditor/Data/Localization/Languages/pt-br.json
Expand Up @@ -561,24 +561,27 @@
"TRANSFORM_ACTION_DISPLAY_SCALE_ROTATE_SHEAR_NOPERSPECTIVE": "Arraste as alças para transformar a escala. Mantenha pressionada a tecla Shift para dimensionar proporcionalmente. Mantenha pressionada a tecla Alt e arraste uma alça lateral para cortar. Arraste as alças externas para girar.",
"TRANSFORM_ACTION_DISPLAY_SCALE_ROTATE_NOSHEAR_NOPERSPECTIVE": "Arraste as alças para transformar a escala. Mantenha pressionada a tecla Shift para dimensionar proporcionalmente. Arraste as alças externas para girar.",
"TRANSFORM_ACTION_DISPLAY_SCALE_NOROTATE_NOSHEAR_NOPERSPECTIVE": "Arraste as alças para transformar a escala. Mantenha pressionada a tecla Shift para dimensionar proporcionalmente.",
"OPEN_DOCUMENTATION": "Open documentation",
"OPEN_DOCUMENTATION": "Abrir documentação",
"LOCAL_PALETTE_SOURCE_NAME": "Local",
"ERROR_FORBIDDEN_UNIQUE_NAME": "Extension unique name cannot start with 'pixieditor'.",
"ERROR_MISSING_METADATA": "Extension metadata key '{0}' is missing.",
"ERROR_NO_CLASS_ENTRY": "Extension class entry is missing on path '{0}'.",
"ERROR_NO_ENTRY_ASSEMBLY": "Extension entry assembly is missing on path '{0}'.",
"ERROR_MISSING_ADDITIONAL_CONTENT": "Your current setup doesn't allow loading this extension. Perhaps you don't own it or don't have it installed. You can purchase it here '{0}'.",
"BUY_SUPPORTER_PACK": "Buy Supporter Pack",
"NEWS": "News",
"DISABLE_NEWS_PANEL": "Disable News panel in startup window",
"FAILED_FETCH_NEWS": "Failed to fetch news",
"CROP_TO_SELECTION": "Crop to selection",
"CROP_TO_SELECTION_DESCRIPTIVE": "Crop image to selection",
"SHOW_CONTEXT_MENU": "Show context menu",
"ERASE": "Erase",
"USE_SECONDARY_COLOR": "Use secondary color",
"RIGHT_CLICK_MODE": "Right click mode",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Add primary color to palette",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Add primary color to current palette",
"COPY_COLOR": "Copy color"
"ERROR_FORBIDDEN_UNIQUE_NAME": "O nome exclusivo da extensão não pode começar com \"pixieditor\".",
"ERROR_MISSING_METADATA": "A chave de metadados de extensão '{0}' está ausente.",
"ERROR_NO_CLASS_ENTRY": "A entrada da classe de extensão está ausente no caminho '{0}'.",
"ERROR_NO_ENTRY_ASSEMBLY": "O conjunto de entrada de extensão está ausente no caminho '{0}'.",
"ERROR_MISSING_ADDITIONAL_CONTENT": "Sua configuração atual não permite o carregamento dessa extensão. Talvez você não a possua ou não a tenha instalada. Você pode comprá-la aqui '{0}'",
"BUY_SUPPORTER_PACK": "Comprar Pacote de Apoiador",
"NEWS": "Notícias",
"DISABLE_NEWS_PANEL": "Desativar o painel Notícias na janela de inicialização",
"FAILED_FETCH_NEWS": "Falha ao buscar notícias",
"CROP_TO_SELECTION": "Cortar para a seleção",
"CROP_TO_SELECTION_DESCRIPTIVE": "Cortar imagem para seleção",
"SHOW_CONTEXT_MENU": "Mostrar menu de contexto",
"ERASE": "Apagar",
"USE_SECONDARY_COLOR": "Usar cor secundária",
"RIGHT_CLICK_MODE": "Modo de clique direito",
"ADD_PRIMARY_COLOR_TO_PALETTE": "Adicionar cor primária à paleta",
"ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Adicionar cor primária à paleta atual",
"COPY_COLOR": "Copiar Cor",
"ERROR_FAILED_TO_OPEN_EXPLORER": "Couldn't open File Explorer",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED_TITLE": "Could not recover all",
"CRASH_NOT_ALL_DOCUMENTS_RECOVERED": "Could not fully recover all files.\nIf you send the crash report to the developers\nthey might be able to help you."
}

0 comments on commit 5a347d0

Please sign in to comment.