mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@14723 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a16492a289
commit
00e5198469
3 changed files with 59 additions and 0 deletions
12
reference/RichTextIterator/RichTextIterator.upp
Normal file
12
reference/RichTextIterator/RichTextIterator.upp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
description "Demostrates the use of RichTextIterator to extract Images from RichText\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
Test.qtf,
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
18
reference/RichTextIterator/Test.qtf
Normal file
18
reference/RichTextIterator/Test.qtf
Normal file
File diff suppressed because one or more lines are too long
29
reference/RichTextIterator/main.cpp
Normal file
29
reference/RichTextIterator/main.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
Vector<Image> ExtractImages(const RichText& txt)
|
||||
{
|
||||
struct Iter : RichText::Iterator {
|
||||
Vector<Image> m;
|
||||
virtual bool operator()(int, const RichPara& para) {
|
||||
for(int i = 0; i < para.GetCount(); i++) {
|
||||
const RichPara::Part& p = para[i];
|
||||
if(p.object)
|
||||
m.Add(p.object.ToImage(p.object.GetPixelSize()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} iter;
|
||||
|
||||
txt.Iterate(iter);
|
||||
|
||||
return pick(iter.m);
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
int i = 0;
|
||||
for(Image m : ExtractImages(ParseQTF(LoadDataFile("Test.qtf"))))
|
||||
PNGEncoder().SaveFile(GetHomeDirFile(String() << "ExtractedImage_" << ++i << ".png"), m);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue