Aurelon Open API 8.1.1
Loading...
Searching...
No Matches
ScodixDitherText.cpp
1#include "./AOI_Page.h"
2#include "../GPage.h"
3#include "../GBitmap.h"
4#include "../GDocument.h"
5#include "../GMultiSymbol.h"
6#include "../GLayer.h"
7#include "../GPathText.h"
8#include "../GPlaceHolder.h"
9
10using namespace aur;
11using namespace aur::ACPL;
12using namespace aur::PDF;
13
14static void SetPatternedTextStyle( Text* text, DeviceN* devn, long percentage, uint16_t maxL )
15{
16 StylePtr fs = text->GetFillStyle();
17 if( fs && fs->ResourceType() == Solid::eResourceType )
18 {
19 SolidPtr c = SolidPtr(fs);
20 Color col;
21 c->GetColor( col );
22 col.space->ConvertColor( col.channel, GraySpace, col.channel );
23 if( col.channel[0] > maxL )
24 col.channel[0] = 8192; // Provision for small white text
25 else
26 col.channel[0] = uint16_t( percentage * 655.35 );
27 col.space = devn;
28 fs = new Solid( text->GetDocument(), col );
29 text->SetFillStyle( fs );
30 fs->Dispose();
31 }
32}
33
34static void HandleObject( Object* obj, DeviceN* devn, float minSize, float maxSize, uint16_t maxL, bool& changed )
35{
36 switch( obj->GetType() )
37 {
38 case gLayerType:
39 case gGroupType:
40 for( ObjectPtr kid = GroupPtr( obj )->GetFirstChild(); kid ; kid = kid->GetNext() )
41 HandleObject( kid, devn, minSize, maxSize, maxL, changed );
42 break;
43 case gPathTextType :
44 case gTextType:
45 {
46 Text* text = (Text*)obj;
47 PropsT props;
48 text->GetProperties( props );
49 if( props.style.size <= maxSize )
50 {
51 long percentage;
52 if( props.style.size <= minSize )
53 percentage = 50;
54 else
55 percentage = long( 50 + 50 * ( props.style.size - minSize ) / ( maxSize - minSize ) );
56 SetPatternedTextStyle( text, devn, percentage, maxL );
57 changed = true;
58 }
59 }
60 break;
61 case gMultiSymbolType :
62 case gSymbolType :
63 case gPlaceHolderType:
64 {
65 Object* symObj = SymbolPtr(obj)->GetObject();
66 HandleObject( symObj, devn, minSize, maxSize, maxL, changed );
67 }
68 break;
69 }
70}
71
72extern AOIAPI void ScodixPatternText( AOI_Page* aoiP, float minPtSize, float maxPtSize, uint16_t maxL );
73AOIAPI void ScodixPatternText( AOI_Page* aoiP, float minPtSize, float maxPtSize, uint16_t maxL )
74{
75 float minSize = minPtSize / 4;
76 float maxSize = maxPtSize / 4;
77 bool changed = false;
78 maxL = ( 255 - maxL ) * 257;
79
80 Page* page = (Page*)aoiP;
81 DeviceN* devn = new DeviceN( page->GetDocument(), page->GetDocument()->GetDeviceGrayColorSpace() );
82 devn->AddChannel( "Scodix", NULL );
83 devn->SetFunction( new IdentityFunction() );
84 for( Object* l = page->GetFirstLayer(); l; l = l->GetNext() )
85 HandleObject( l, devn, minSize, maxSize, maxL, changed );
86 if( changed )
87 page->Modified();
88 devn->Dispose();
89}
Page in the document.
Definition AOI_Page.h:11