Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
PsdProcessor: StringCallback, TextCallback, and FrameCallback
Rank: Advanced Member
Groups: Guest
Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
The following sample illustrates the processing sequence of the StringCallback, TextCallback, and FrameCallback callbacks. A source PSD file is very simple. It contains a background and 3 text layers (Text 1, Text 2, Text 3). Code:using System;
using Aurigma.GraphicsMill;
using Aurigma.GraphicsMill.AdvancedDrawing;
using Aurigma.GraphicsMill.Templates;
class Program
{
static void Main(string[] args)
{
var psdProcessor = new PsdProcessor();
psdProcessor.StringCallback = (processor, textFrame) =>
{
Console.WriteLine("StringCallback (frame name: \"{0}\")", textFrame.Name);
if (textFrame.Name == "Text 1" || textFrame.Name == "Text 3")
return textFrame.Text + " [Modified in StringCallback]";
return textFrame.Text;
};
psdProcessor.TextCallback = (processor, textFrame, textString) =>
{
Console.WriteLine("\nTextCallback begin (frame name: \"{0}\")", textFrame.Name);
var text = processor.ProcessText(textFrame);
if (textFrame.Name == "Text 1" || textFrame.Name == "Text 2")
{
text.String += " [Modified in TextCallback]";
}
Console.WriteLine("TextCallback end (frame name: \"{0}\")\n", textFrame.Name);
return text;
};
psdProcessor.FrameCallback = (processor, frame) =>
{
Console.WriteLine("FrameCallback (frame name: \"{0}\")", frame.Name);
return processor.ProcessFrame(frame);
};
psdProcessor.Render("../../../input.psd", "../../../result.png");
}
}
Here is a console log: Code:FrameCallback (frame name: "Background")
FrameCallback (frame name: "Text 3")
StringCallback (frame name: "Text 3")
TextCallback begin (frame name: "Text 3")
StringCallback (frame name: "Text 3")
TextCallback end (frame name: "Text 3")
FrameCallback (frame name: "Text 2")
StringCallback (frame name: "Text 2")
TextCallback begin (frame name: "Text 2")
StringCallback (frame name: "Text 2")
TextCallback end (frame name: "Text 2")
FrameCallback (frame name: "Text 1")
StringCallback (frame name: "Text 1")
TextCallback begin (frame name: "Text 1")
StringCallback (frame name: "Text 1")
TextCallback end (frame name: "Text 1")
You can notice that StringCallback can be called several time as it is invoked every time the ProcessText method is called. TextCallback allows change text as well as font, color and other settings. So I recommend using TextCallback only (without StringCallback) to keep the source code simple. input.zip (11kb) downloaded 6 time(s). Edited by user Tuesday, July 4, 2017 10:54:19 PM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|
|
|
|
Aurigma Forums
»
Graphics Mill
»
Discussions – Graphics Mill
»
PsdProcessor: StringCallback, TextCallback, and FrameCallback
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.