Seite 4 von 5

Fixed: View 100% distorts text layer created by AddIn

Verfasst: Mo 31 Jul 2017 03:12
von photoken
Win10 1607 x64
PL 20.40b12 x64

I have an AddIn, compiled as an executable (.EXE), that creates a text layer. When PL is first started, and the AddIn is run, the lines of text are distorted when the image is viewed at 100%:
view 100.jpg
If I change the View to another percentage, or export the image, the text lines look correct:
alt view.jpg
If I select the Text tool, and change the font, then after running the AddIn again the text looks correct at 100%.

The AddIn has a GUI form that contains one textbox (textBox1) and one button (OKbutton). In case the problem is with the AddIn code, here's the complete content of the Form1.cs (C#) file that creates the text layer:

Code: Alles auswählen

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HelloWorld {
	public partial class Form1 : Form {
		public Form1() {
		
			InitializeComponent();

			// Initialize a ResourceManager to retrieve localized strings.
			ResourceManager locRM = new ResourceManager("HelloWorld.Resource1", typeof(Form1).Assembly);

			// Populate the text box with either the default text or the saved user's text.
			if (Properties.Settings.Default.UserText == null || Properties.Settings.Default.UserText == "") {
				textBox1.Text = locRM.GetString("DefaultText");
			} else {
				textBox1.Text = Properties.Settings.Default.UserText;
			}
		}

		/// <summary>
		/// Create a text layer with the specified content and formatting.
		/// </summary>
		/// <param name="doc">The active document/image.</param>
		/// <param name="selectedlayer">The selected layer.</param>
		public void CreateTextLayer(PhotoLine.document doc, PhotoLine.layer selectedlayer) {

			// Initialize the arrays and variables that will be needed.
			int[] charrange = new int[] { 0, 1 };
			int[] RGBvalue = new int[] { 255, 255, 255 };
			string testtext;

			// Initialize the new text layer.
			PhotoLine.Text targetlayer = new PhotoLine.Text();

			// Get the text in the textbox.
			testtext = textBox1.Text;

			// Create the font attributes object.
			PhotoLine.Dictionary fontAttribute = new PhotoLine.Dictionary();
			fontAttribute.Add("FamilyName", "Arial");
			fontAttribute.Add("Size", 72);
			fontAttribute.Add("Weight", 700);

			// Create the paragraph attributes object.
			PhotoLine.Dictionary paragraphObject = new PhotoLine.Dictionary();
			paragraphObject.Add("Alignment", PhotoLine.ParagraphAlignment.PACenter);
			paragraphObject.Add("FixLine", true);
			paragraphObject.Add("Line", 50);

			// Set text of the new layer and the range of text characters that will be affected.
			targetlayer.Text = testtext;
			charrange[1] = targetlayer.TextLength;

			// Apply the paragraph and font attributes to the affected text characters.
			targetlayer.SetAttribute(charrange, "Paragraph", paragraphObject);
			targetlayer.SetAttribute(charrange, "Color", RGBvalue);
			targetlayer.SetAttribute(charrange, "Font", fontAttribute);

			// Set the vertical alignment of the text layer's content.
			targetlayer.VerticalAlignment = PhotoLine.TextVerticalAlignment.TVACenter;

			// Name the new text layer, size it to the document size and create the text layer.
			targetlayer.Name = "C# Add-In";
			targetlayer.Size = doc.Size;
			selectedlayer.Parent.Insert(targetlayer, selectedlayer);
		}

		/// <summary>
		/// Close the AddIn.
		/// </summary>
		public static void CloseAddIn() {
			Form1.ActiveForm.Dispose();
		}

		private void OKbutton_Click(object sender, EventArgs e) {

			PhotoLine.Application app = new PhotoLine.Application();

			if (app != null) {
				PhotoLine.document doc = app.ActiveDocument;

				if (doc != null) {
					PhotoLine.layer selectedlayer = (PhotoLine.layer)doc.ActivePage.ActiveLayer;

					if (selectedlayer != null) {
						try {
							CreateTextLayer(doc, selectedlayer);
						} catch (Exception appe) {
							MessageBox.Show(appe.InnerException.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
							throw;
						} finally {
							// Save the user's text and close the AddIn.
							Properties.Settings.Default.UserText = textBox1.Text;
							Properties.Settings.Default.Save();
							CloseAddIn();
						}
					}
				}
			}
		}
	}
}
Also, I notice that the text lines are not centered vertically -- there is more space below the text.

Re: Prob: View 100% distorts text layer created by AddIn

Verfasst: Mo 31 Jul 2017 11:10
von Martin Huber
photoken hat geschrieben: Mo 31 Jul 2017 03:12 I have an AddIn, compiled as an executable (.EXE), that creates a text layer. When PL is first started, and the AddIn is run, the lines of text are distorted when the image is viewed at 100%: (...)
There are two minor problems, that will be fixed in the next version (a missing redraw and fonts are not updated correctly).
photoken hat geschrieben: Mo 31 Jul 2017 03:12(...) here's the complete content of the Form1.cs (C#) file that creates the text layer:
A small note: colors are usually single precision floats with a default range of [0;1].
photoken hat geschrieben: Mo 31 Jul 2017 03:12Also, I notice that the text lines are not centered vertically -- there is more space below the text.
I think, that is because of the descenders (or missing descenders in your text). Maybe it is reasonable to ignore the descenders of the last line, because the visual weight of descenders is usually quite low.

Martin

Re: Prob: View 100% distorts text layer created by AddIn

Verfasst: Di 01 Aug 2017 01:38
von photoken
Martin Huber hat geschrieben: Mo 31 Jul 2017 11:10 A small note: colors are usually single precision floats with a default range of [0;1].
Hmmmm....
It's easier for me to imagine the colour when thinking in terms of RGB values.
Also, it's easier for me to get a neutral gray:
int[] RGBvalue = new int[] { 90, 90, 90};
or a slightly bluish gray:
int[] RGBvalue = new int[] { 90, 90, 110};
Martin Huber hat geschrieben: Mo 31 Jul 2017 11:10
photoken hat geschrieben: Mo 31 Jul 2017 03:12Also, I notice that the text lines are not centered vertically -- there is more space below the text.
I think, that is because of the descenders (or missing descenders in your text). Maybe it is reasonable to ignore the descenders of the last line, because the visual weight of descenders is usually quite low.
Yes, I had not thought of the descenders. That sounds like a reasonable solution, and if the result is obviously "bad" one can always Optimize the text layer size and use the Layer tool to center that optimized text layer horizontally and vertically.

Re: Prob: View 100% distorts text layer created by AddIn

Verfasst: Di 01 Aug 2017 08:39
von Martin Huber
photoken hat geschrieben: Di 01 Aug 2017 01:38
Martin Huber hat geschrieben: Mo 31 Jul 2017 11:10 A small note: colors are usually single precision floats with a default range of [0;1].
Hmmmm....
It's easier for me to imagine the colour when thinking in terms of RGB values.
Also, it's easier for me to get a neutral gray:
int[] RGBvalue = new int[] { 90, 90, 90};
or a slightly bluish gray:
int[] RGBvalue = new int[] { 90, 90, 110};
Floats in the range [0;1] have a some of advantages:
- You can easily define HDR values.
- Compared to ints, with floats you can declare nearly any brightness value.

And if you really cant get used to float, you should be able to write:
single[] RGBvalue = new single[] { 90/255, 90/255, 90/255};

Martin

Re: Neue Testversion 20.40b12

Verfasst: Do 03 Aug 2017 12:05
von Ashcraaft
Kann grad mal bitte jemand schauen, ob in der aktuellen PL-Version oder auch in der BETA 20.40 ein Finder-Preview für PLD-Dateien angezeigt wird?

Bei mir unter OS Sierra 10.12.6 kommt nur ein anwendungsspezifisches Dokument-Icon :?

Re: Neue Testversion 20.40b12

Verfasst: Do 03 Aug 2017 15:47
von bkh
Ashcraaft hat geschrieben: Do 03 Aug 2017 12:05 Kann grad mal bitte jemand schauen, ob in der aktuellen PL-Version oder auch in der BETA 20.40 ein Finder-Preview für PLD-Dateien angezeigt wird?

Bei mir unter OS Sierra 10.12.6 kommt nur ein anwendungsspezifisches Dokument-Icon :?
Mit OS X 10.11.6 bekomme ich mit Finder -> Get Info, in der Icon-Ansicht und per QuickView (Leertaste) Vorschauen. Nur in der Listenansicht sehe ich links vom Dateinamen nur ein allgemeines Icon (was ich auch nicht weiter schlimm finde).

L.G.

Burkhard.

Re: Neue Testversion 20.40b12

Verfasst: Do 03 Aug 2017 17:06
von Martin Huber
bkh hat geschrieben: Do 03 Aug 2017 15:47
Ashcraaft hat geschrieben: Do 03 Aug 2017 12:05 Kann grad mal bitte jemand schauen, ob in der aktuellen PL-Version oder auch in der BETA 20.40 ein Finder-Preview für PLD-Dateien angezeigt wird?

Bei mir unter OS Sierra 10.12.6 kommt nur ein anwendungsspezifisches Dokument-Icon :?
Mit OS X 10.11.6 bekomme ich mit Finder -> Get Info, in der Icon-Ansicht und per QuickView (Leertaste) Vorschauen. Nur in der Listenansicht sehe ich links vom Dateinamen nur ein allgemeines Icon (was ich auch nicht weiter schlimm finde).
Bei mir ist es unter 10.12.6 wie bei Burkhard.

Martin

Re: Neue Testversion 20.40b12

Verfasst: Do 03 Aug 2017 17:08
von Ashcraaft
Martin Huber hat geschrieben: Do 03 Aug 2017 17:06 Bei mir ist es unter 10.12.6 wie bei Burkhard.
Irgendeine Idee, warum die Dokumente im Finder per Quickview nicht angezeigt werden?

Re: Neue Testversion 20.40b12

Verfasst: Do 03 Aug 2017 18:32
von bkh
Ashcraaft hat geschrieben: Do 03 Aug 2017 17:08
Martin Huber hat geschrieben: Do 03 Aug 2017 17:06 Bei mir ist es unter 10.12.6 wie bei Burkhard.
Irgendeine Idee, warum die Dokumente im Finder per Quickview nicht angezeigt werden?
Ich habe gerade gesehen, dass einige plds auch bei mir keine Vorschau haben. Es scheinen durchweg ältere Dateien (2013 und davor) zu sein. Wenn ich sie mit PL 20.02 oder der aktuellen Beta neu speichere, erscheint dann auch die Vorschau.

Bei Interesse kann ich eine Beispieldatei an support mailen.

L.G.

Burkhard.

PL dialog components as VS toolbox items?

Verfasst: Fr 04 Aug 2017 07:12
von photoken
I don't know if this can be done, but I'll ask anyway:

Would it be possible to supply the components of a PL dialog window as VS toolbox items?

For example:
  • An empty dialog window (which would automatically inherit the user's UI colour scheme)
  • Slider
  • Spinbox
  • Combobox
  • Entry field
  • Before/After panel
  • Preview button
  • OK button
  • Cancel button
  • Adjustment layer button
  • General purpose button
I'm looking for a solution which would relieve me of the burden of coding the "plumbing" -- things like previewing, and undoing when the dialog is cancelled, etc.

Re: Neue Testversion 20.40b12

Verfasst: Fr 04 Aug 2017 11:05
von Martin Huber
bkh hat geschrieben: Do 03 Aug 2017 18:32 Ich habe gerade gesehen, dass einige plds auch bei mir keine Vorschau haben. Es scheinen durchweg ältere Dateien (2013 und davor) zu sein.
Ich habe nun bei mir gesucht und auch ein paar gefunden. Es sind wie bei dir durchgängig ältere Dateien.

Seltsamerweise funktioniert die Vorschau mit unserem Quicklook-Plug-In, wenn ich es im Debugger teste. Ich vermute, es hängt mit dem Wechsel der Dateityp-UTI zusammen, die wir mal vorgenommen haben (von "com.computerinsel.pld" auf "de.pl32.pld"). Ich habe dem Quicklook-Plug-In daher nun beide UTIs zugewiesen, aber das hatte keine Auswirkung. Das mag aber daran liegen, dass ich hier Dutzende PhotoLines mit ebensovielen Quicklook-Plug-Ins habe und es daher kaum möglich ist, macOS dazu zu zwingen, die neue Version zu verwenden.

Martin

Re: PL dialog components as VS toolbox items?

Verfasst: Fr 04 Aug 2017 11:08
von Martin Huber
photoken hat geschrieben: Fr 04 Aug 2017 07:12Would it be possible to supply the components of a PL dialog window as VS toolbox items?
No, this would be too much work.

Martin

Re: Neue Testversion 20.40b12

Verfasst: Fr 04 Aug 2017 11:34
von Ashcraaft
bkh hat geschrieben: Do 03 Aug 2017 18:32 Ich habe gerade gesehen, dass einige plds auch bei mir keine Vorschau haben. Es scheinen durchweg ältere Dateien (2013 und davor) zu sein. Wenn ich sie mit PL 20.02 oder der aktuellen Beta neu speichere, erscheint dann auch die Vorschau.
Hier ebenfalls geprüft. Eine Vorschau von 2013-03 hatte keine Finder-Vorschau, wohingegen eine von 2013-10 bereits eine hatte. Der Wechsel scheint also Mitte 2013 stattgefunden zu haben.

Wenn man weiß, dass man die Dateien neu abspeichern muss ist das natürlich schnell getan (und eröffnet gleich auch die Möglichkeit sich von altem Mist zu trennen :D ) DANKE

PDF opening with wrong colors

Verfasst: So 06 Aug 2017 21:11
von evren
Whats wrong with this PDF file? PDF viewer or chrome displays correct but editor opens all in orange.

http://www.evrencomert.com/logo.pdf

English translation needed

Verfasst: So 06 Aug 2017 23:44
von photoken
blur dialog.png