Bazaar:Leptonica - added image rectangular markers

git-svn-id: svn://ultimatepp.org/upp/trunk@1577 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
micio 2009-09-20 14:55:01 +00:00
parent 5b22349663
commit b26e58fcd8
25 changed files with 1378 additions and 363 deletions

321
bazaar/PixRaster/Marker.cpp Normal file
View file

@ -0,0 +1,321 @@
#include "Marker.h"
NAMESPACE_UPP
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// constructors
Marker::Marker()
{
kind = EmptyMarker;
borderThickness = 2;
borderColor = Blue;
borderLineType = 0;
fillColor = WhiteGray();
selBorderThickness = 2;
selBorderColor = LtBlue;
selBorderLineType = 0;
selFillColor = LtGray();
closed = false;
} // END Constructor class Marker
// construct a rectangular Marker
Marker::Marker(Point const &p1, Point const &p2)
{
kind = RectMarker;
borderThickness = 2;
borderColor = Blue;
borderLineType = 0;
fillColor = WhiteGray();
selBorderThickness = 2;
selBorderColor = LtBlue;
selBorderLineType = 0;
selFillColor = LtGray();
closed = true;
points.Add(Point(min(p1.x, p2.x), min(p1.y, p2.y)));
points.Add(Point(max(p1.x, p2.x), max(p1.y, p2.y)));
} // END Constructor class Marker
// construct a polygonal Marker
Marker::Marker(Vector<Point> const &pts)
{
kind = PolyMarker;
borderThickness = 2;
borderColor = Blue;
borderLineType = 0;
fillColor = WhiteGray();
selBorderThickness = 2;
selBorderColor = LtBlue;
selBorderLineType = 0;
selFillColor = LtGray();
closed = true;
points <<= pts;
} // END Constructor class Marker
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
Marker::Marker(const Marker &m)
{
kind = m.GetKind();
borderThickness = m.GetBorderThickness();
borderColor = m.GetBorderColor();
borderLineType = m.GetBorderLineType();
fillColor = m.GetFillColor();
selBorderThickness = m.GetSelBorderThickness();
selBorderColor = m.GetSelBorderColor();
selBorderLineType = m.GetSelBorderLineType();
selFillColor = m.GetSelFillColor();
closed = m.IsClosed();
points <<= m.GetPoints();
} // END Constructor class Marker
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// sets the marker to a rectangular area
void Marker::Set(const Point &p1, const Point &p2)
{
kind = RectMarker;
points.Clear();
points.Add(Point(min(p1.x, p2.x), min(p1.y, p2.y)));
points.Add(Point(max(p1.x, p2.x), max(p1.y, p2.y)));
} // END Marker::Set()
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// sets the marker to be a polygonal area
void Marker::Set(const Vector<Point> &pts)
{
kind = PolyMarker;
points <<= pts;
} // END Marker::Set()
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// test for point hit
Marker::HitKind Marker::Hit(const Point &p, int minDist, int &hitIndex)
{
switch(kind)
{
case EmptyMarker:
return Miss;
case RectMarker:
{
Point p1 = points[0];
Point p2 = points[1];
if(abs(p1.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
return TopLeft;
if(abs(p2.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
return TopRight;
if(abs(p1.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
return BottomLeft;
if(abs(p2.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
return BottomRight;
if(abs(p1.y - p.y) <= minDist && p.x >= p1.x && p.x <= p2.x)
return Top;
if(abs(p2.y - p.y) <= minDist && p.x >= p1.x && p.x <= p2.x)
return Bottom;
if(abs(p1.x - p.x) <= minDist && p.y >= p1.y && p.y <= p2.y)
return Left;
if(abs(p2.x - p.x) <= minDist && p.y >= p1.y && p.y <= p2.y)
return Right;
if(p.x > p1.x && p.x < p2.x && p.y > p1.y && p.y < p2.y)
return Inside;
return Miss;
}
case PolyMarker:
// FIXME -- support polygon
default:
NEVER();
} // switch
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// open/close the polygon (invalid for rectangle markers)
void Marker::Open()
{
closed = false;
}
void Marker::Close()
{
closed = true;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// clears the marker
void Marker::Clear(void)
{
points.Clear();
kind = EmptyMarker;
closed = false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// gets rectangular bounding box of marker
Rect Marker::GetBoundingBox() const
{
switch(kind)
{
case EmptyMarker:
return Rect(0, 0, 0, 0);
case RectMarker:
return Rect(points[0], points[1]);
case PolyMarker:
{
int minX = INT_MAX;
int maxX = INT_MIN;
int minY = INT_MAX;
int maxY = INT_MIN;
for(int i = 0; i < points.GetCount(); i++)
{
Point p = points[i];
if(p.x < minX) minX = p.x;
if(p.x > maxX) maxX = p.x;
if(p.y < minY) minY = p.y;
if(p.y > maxY) maxY = p.y;
}
return Rect(minX, minY, maxX, maxY);
}
default:
NEVER();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// gets vertexs of marker
Vector<Point> Marker::GetPoints() const
{
Vector<Point> res;
switch(kind)
{
case RectMarker:
res.Add(points[0]);
res.Add(Point(points[1].x, points[0].y));
res.Add(points[1]);
res.Add(Point(points[0].x, points[1].y));
return res;
case PolyMarker:
return Vector<Point>(points, 1);
default:
return Vector<Point>();
}
}
// gets dragged outline
Vector<Point> Marker::DragOutline(Point const &startPt, Point const &endPt, int minDist)
{
// if empty marker, just return empty polygon
if(kind == EmptyMarker)
return Vector<Point>();
// find kind of hit on start point
int index = 0;
HitKind hitKind = Hit(startPt, minDist, index);
if(hitKind == Miss)
return Vector<Point>();
int dx = endPt.x - startPt.x;
int dy = endPt.y - startPt.y;
switch(kind)
{
case RectMarker:
{
int x1 = points[0].x;
int y1 = points[0].y;
int x2 = points[1].x;
int y2 = points[1].y;
Vector<Point> res;
switch(hitKind)
{
case TopLeft:
x1 += dx;
y1 += dy;
break;
case TopRight:
x2 += dx;
y1 += dy;
break;
case BottomLeft:
x1 += dx;
y2 += dy;
break;
case BottomRight:
x2 += dx;
y2 += dy;
break;
case Top:
y1 += dy;
break;
case Bottom:
y2 += dy;
break;
case Left:
x1 += dx;
break;
case Right:
x2 += dx;
break;
default: // inside
x1 += dx; y1 += dy;
x2 += dx; y2 += dy;
break;
}
res.Add(Point(x1, y1));
res.Add(Point(x2, y1));
res.Add(Point(x2, y2));
res.Add(Point(x1, y2));
return res;
}
case PolyMarker:
// FIXME -- support polygon
default:
NEVER();
} // switch(kind)
} // END Marker::DragOutline()
// drag the marker to final position
void Marker::Drag(Point const &startPt, Point const &endPt, int minDist)
{
if(kind == EmptyMarker)
return;
Vector<Point> pts = DragOutline(startPt, endPt, minDist);
switch(kind)
{
case RectMarker:
{
points[0] = pts[0];
points[1] = pts[2];
break;
}
case PolyMarker:
points = pts;
break;
default:
NEVER();
}
} // END Marker::Drag()
END_UPP_NAMESPACE

103
bazaar/PixRaster/Marker.h Normal file
View file

@ -0,0 +1,103 @@
#ifndef _Marker_h_
#define _Marker_h_
#include <CtrlLib/CtrlLib.h>
NAMESPACE_UPP
// Image Marker class
// supports rectangular and polygonal areas
class Marker
{
public:
typedef Marker CLASSNAME;
enum HitKind { Miss, PolyVertex, PolySide, Left, Right, Top, Bottom, TopLeft, TopRight, BottomLeft, BottomRight, Inside };
enum MarkerKind { EmptyMarker, RectMarker, PolyMarker };
protected:
MarkerKind kind;
bool closed;
int borderThickness;
Color borderColor;
int borderLineType;
RGBA fillColor;
int selBorderThickness;
Color selBorderColor;
int selBorderLineType;
RGBA selFillColor;
Vector<Point> points;
public:
// construct an empty marker
Marker();
// construct a rectangular Marker
Marker(Point const &p1, Point const &p2);
// construct a polygonal Marker
Marker(Vector<Point> const &pts);
// copy constructor
Marker(Marker const &m);
// sets the marker to a rectangular area
void Set(const Point &p1, const Point &p2);
// sets the marker to be a polygonal area
void Set(const Vector<Point> &pts);
// empties the marker
void Clear();
// opens/closes the marker
void Open();
void Close();
// test for point hit
// hitIndex is only for polygons, gives vertex's index of selected vertex
HitKind Hit(const Point &p, int minDist, int &hitIndex);
// member read access
virtual MarkerKind GetKind() const { return kind; }
bool IsClosed() const { return closed; }
Color GetBorderColor() const { return borderColor; }
int GetBorderLineType() const { return borderLineType; }
int GetBorderThickness() const { return borderThickness; }
RGBA GetFillColor() const { return fillColor; }
Color GetSelBorderColor() const { return selBorderColor; }
int GetSelBorderLineType() const { return selBorderLineType; }
int GetSelBorderThickness() const { return selBorderThickness; }
RGBA GetSelFillColor() const { return selFillColor; }
Rect GetBoundingBox() const;
Vector<Point> GetPoints() const;
// member write access
void SetKind(MarkerKind k);
void SetBorderColor(Color c);
void SetBorderLineType(int lt);
void SetBorderThickness(int th);
RGBA SetFillColor(RGBA const &rgba);
void SetSelBorderColor(Color c);
void SetSelBorderLineType(int lt);
void SetSelBorderThickness(int th);
RGBA SetSelFillColor(RGBA const &rgba);
// gets dragged outline
Vector<Point>DragOutline(Point const &startPt, Point const &endPt, int minDist);
// drag the marker to final position
void Drag(Point const &startPt, Point const &endPt, int minDist);
}; // END Class Marker
typedef Array<Marker> Markers;
END_UPP_NAMESPACE
#endif

View file

@ -31,7 +31,7 @@ void Pix::Destroy()
delete[] localPalette;
localPalette = NULL;
}
polyMarkers.Clear();
markers.Clear();
} // END Pix::Destroy()
@ -408,7 +408,7 @@ Pix::Pix()
pix = NULL;
rasterFormat = NULL;
localPalette = NULL;
polyMarkers.Clear();
markers.Clear();
} // END Pix::Pix()
@ -423,7 +423,7 @@ Pix::Pix(int width, int height, int depth, RGBA *colorTable)
}
rasterFormat = NULL;
localPalette = NULL;
polyMarkers.Clear();
markers.Clear();
} // END Pix::Pix()
@ -436,7 +436,7 @@ Pix::Pix(PIX **_pix)
*_pix = NULL;
rasterFormat = NULL;
localPalette = NULL;
polyMarkers.Clear();
markers.Clear();
} // END Pix::Pix()
@ -447,7 +447,7 @@ Pix::Pix(Pix const &_pix)
pix = pixClone((Pix &)_pix);
rasterFormat = NULL;
localPalette = NULL;
polyMarkers <<= _pix.polyMarkers;
markers <<= _pix.markers;
} // END Pix::Pix()
@ -458,7 +458,7 @@ Pix::Pix(Pix const &_pix, int i)
pix = pixCopy(NULL, (Pix &)_pix);
rasterFormat = NULL;
localPalette = NULL;
polyMarkers <<= _pix.polyMarkers;
markers <<= _pix.markers;
} // END Pix::Pix()
@ -505,7 +505,7 @@ Pix &Pix::operator=(Pix &_pix)
pix = pixClone(_pix);
rasterFormat = NULL;
localPalette = NULL;
polyMarkers <<= _pix.polyMarkers;
markers <<= _pix.markers;
return *this;
} // END Pix::operator=()
@ -521,7 +521,7 @@ Pix &Pix::operator <<=(Pix &_pix)
pix = pixCopy(NULL, _pix);
rasterFormat = NULL;
localPalette = NULL;
polyMarkers <<= _pix.polyMarkers;
markers <<= _pix.markers;
return *this;
} // END Pix::operator <<=()
@ -536,7 +536,7 @@ Pix &Pix::DeepCopy(Pix &_pix)
pix = pixCopy(NULL, _pix);
rasterFormat = NULL;
localPalette = NULL;
polyMarkers <<= _pix.polyMarkers;
markers <<= _pix.markers;
return *this;
} // END Pix::DeepCopy()
@ -1113,7 +1113,7 @@ const RasterFormat *PixRaster::GetFormatEx(int page)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// read page polymarkers
PolyMarkers *PixRaster::GetPolyMarkersEx(int page)
Markers *PixRaster::GetMarkersEx(int page)
{
if (IsEmpty())
return NULL;
@ -1121,7 +1121,7 @@ PolyMarkers *PixRaster::GetPolyMarkersEx(int page)
// gets true page number
page = getTruePage(page);
return At(page).GetPolyMarkers();
return At(page).GetMarkers();
} // END PixRaster::GetPolyMarkersEx()

View file

@ -7,7 +7,7 @@
#include "lib/allheaders.h"
#undef Pix
#include "PolyMarker.h"
#include "Marker.h"
NAMESPACE_UPP
@ -51,7 +51,7 @@ class PixBase : public Raster
virtual const RasterFormat *GetFormat() { return GetFormatEx(PIXRASTER_CURPAGE); }
virtual int GetWidth() { return GetSize().cx; }
virtual int GetHeight() { return GetSize().cy; }
virtual PolyMarkers *GetPolyMarkers() { return GetPolyMarkersEx(PIXRASTER_CURPAGE); }
virtual Markers *GetMarkers() { return GetMarkersEx(PIXRASTER_CURPAGE); }
// extended Raster functions -- they allow to query
@ -64,7 +64,7 @@ class PixBase : public Raster
virtual const RasterFormat *GetFormatEx(int page) = 0;
virtual int GetWidthEx(int page) { return GetSizeEx(page).cx; }
virtual int GetHeightEx(int page) { return GetSizeEx(page).cy; }
virtual PolyMarkers *GetPolyMarkersEx(int page) = 0;
virtual Markers *GetMarkersEx(int page) = 0;
virtual bool IsEmpty() = 0;
operator bool() { return !IsEmpty(); }
@ -96,7 +96,7 @@ class Pix : public PixBase
RGBA *localPalette;
// polygon markers
Array<PolyMarker>polyMarkers;
Markers markers;
protected:
@ -198,8 +198,8 @@ class Pix : public PixBase
virtual const RasterFormat *GetFormatEx(int page);
// gets polygon markers
virtual PolyMarkers *GetPolyMarkers() { return &polyMarkers; }
virtual PolyMarkers *GetPolyMarkersEx(int) { return &polyMarkers; }
virtual Markers *GetMarkers() { return &markers; }
virtual Markers *GetMarkersEx(int) { return &markers; }
// file I/O
bool Load(FileIn &fs, int page = 0);
@ -366,8 +366,8 @@ class PixRaster : public PixBase
virtual const RasterFormat *GetFormatEx(int page);
// gets polygon markers
virtual PolyMarkers *GetPolyMarkers() { return GetPolyMarkersEx(PIXRASTER_CURPAGE); }
virtual PolyMarkers *GetPolyMarkersEx(int page);
virtual Markers *GetMarkers() { return GetMarkersEx(PIXRASTER_CURPAGE); }
virtual Markers *GetMarkersEx(int page);
// check whether pixraster has images
bool IsEmpty(void) { return !pages.GetCount(); };

View file

@ -173,8 +173,8 @@ file
PixRaster.h,
PixRasterLoad.cpp,
PixRaster.cpp,
PolyMarker.h,
PolyMarker.cpp,
Marker.h,
Marker.cpp,
TiffIo.cpp,
UppLept.cpp,
Lept-Skew.cpp,

View file

@ -1,216 +0,0 @@
#include "PolyMarker.h"
using namespace Upp;
// constructors
PolyMarker::PolyMarker()
{
kind = Empty;
borderThickness = 0;
borderColor = Black;
borderLineType = 0;
fillColor.a = 0;
fillColor.r = 0;
fillColor.g = 0;
fillColor.b = 0;
closed = false;
}
PolyMarker::PolyMarker(const PolyMarker &pm)
{
kind = pm.GetKind();
borderThickness = pm.GetBorderThickness();
borderColor = pm.GetBorderColor();
borderLineType = pm.GetBorderLineType();
fillColor = pm.GetFillColor();
closed = pm.IsClosed();
}
// test for point hit
PolyMarker::HitKind PolyMarker::Hit(const Point &p, int minDist)
{
switch(kind)
{
case Empty:
return Miss;
case Rectangle:
{
Point p1 = points[0];
Point p2 = points[1];
int x1 = min(p1.x, p2.x);
int y1 = min(p1.y, p2.y);
int x2 = max(p1.x, p2.x);
int y2 = max(p1.y, p2.y);
if(abs(p1.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
return Vertex;
if(abs(p2.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
return Vertex;
if(abs(p1.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
return Side;
if(abs(p2.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
return Side;
if(abs(p1.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= y2 + minDist)
return Side;
if(abs(p2.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= y2 + minDist)
return Side;
if(p.x > x1 && p.x < x2 && p.y > y1 && p.y < y2)
return Inside;
return Miss;
}
case Polygon:
// FIXME -- support polygon
default:
NEVER();
} // switch
}
// gets vertex or side on point
One<Point> const PolyMarker::VertexAt(const Point &p, int minDist)
{
switch(kind)
{
case Empty:
return One<Point>();
case Rectangle:
{
Point p1 = points[0];
Point p2 = points[1];
int x1 = min(p1.x, p2.x);
int y1 = min(p1.y, p2.y);
int x2 = max(p1.x, p2.x);
int y2 = max(p1.y, p2.y);
if(abs(p1.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
return One<Point>(new Point(p1.x, p1.y));
else if(abs(p2.x - p.x) <= minDist && abs(p1.y - p.y) <= minDist)
return One<Point>(new Point(p2.x, p1.y));
else if(abs(p2.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
return One<Point>(new Point(p2.x, p2.y));
else if(abs(p1.x - p.x) <= minDist && abs(p2.y - p.y) <= minDist)
return One<Point>(new Point(p1.x, p2.y));
return One<Point>();
}
case Polygon:
{
for(int i = 0; i < points.GetCount(); i++)
{
Point pi = points[i];
if(abs(pi.x - p.x) <= minDist && abs(pi.y - p.y) <= minDist)
return One<Point>(new Point(pi));
}
return One<Point>();
}
default:
return One<Point>();
} // switch kind
}
One<Rect> const PolyMarker::SideAt(const Point &p, int minDist)
{
switch(kind)
{
case Empty:
return One<Rect>();
case Rectangle:
{
Point p1 = points[0];
Point p2 = points[1];
int x1 = min(p1.x, p2.x);
int y1 = min(p1.y, p2.y);
int x2 = max(p1.x, p2.x);
int y2 = max(p1.y, p2.y);
if(abs(p1.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
return One<Rect>(new Rect(Point(p1.x, y1), Point(p1.x, y2)));
else if(abs(p2.x - p.x) < minDist && p.y >= y1 - minDist && p.y <= y2 + minDist)
return One<Rect>(new Rect(Point(p2.x, y1), Point(p2.x, y2)));
else if(abs(p1.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= x2 + minDist)
return One<Rect>(new Rect(Point(x1, p1.y), Point(x2, p1.y)));
else if(abs(p2.y - p.y) < minDist && p.x >= x1 - minDist && p.x <= x2 + minDist)
return One<Rect>(new Rect(Point(x1, p2.y), Point(x2, p2.y)));
return One<Rect>();
}
case Polygon:
// fixme : add support
default:
return One<Rect>();
} // switch kind
}
// open/close the polygon (invalid for rectangle markers)
bool PolyMarker::Open(void)
{
closed = false;
}
bool PolyMarker::Close(void)
{
closed = true;
}
// adds a vertex to the polygon (invalid for rectangle markers)
bool PolyMarker::AddVertex(const Point &p)
{
if(closed || kind == Rectangle)
return false;
points.Add(p);
return true;
}
bool PolyMarker::AddVertex(const Array<Point> &ap)
{
if(closed || kind == Rectangle || !ap.GetCount())
return false;
for(int i = 0; i < ap.GetCount(); i++)
points.Add(ap[i]);
return true;
}
void PolyMarker::MakeRect(const Point &p1, const Point &p2)
{
points.Clear();
points.Add(p1);
points.Add(p1);
kind = Rectangle;
closed = true;
}
// clears the marker
void PolyMarker::Clear(void)
{
points.Clear();
kind = Empty;
closed = false;
}
// gets a dragged PolyMarker giving start and end point
PolyMarker PolyMarker::Drag(const Point &startP, const Point &endP)
{
}
// changes the PolyMarker at end of drag ops
void PolyMarker::DoDrag(const Point &startP, const Point &endP)
{
}
// paint the PolyMarker on a given viewport
void PolyMarker::Paint(const Rect &vport)
{
}

View file

@ -1,76 +0,0 @@
#ifndef _PolyMarker_h_
#define _PolyMarker_h_
#include <CtrlLib/CtrlLib.h>
NAMESPACE_UPP
class PolyMarker
{
public:
typedef PolyMarker CLASSNAME;
enum HitKind { Miss, Vertex, Side, Inside };
enum PolyKind { Empty, Rectangle, Polygon };
protected:
PolyKind kind;
Array<Point> points;
int borderThickness;
Color borderColor;
int borderLineType;
RGBA fillColor;
bool closed;
public:
// constructors
PolyMarker();
PolyMarker(const PolyMarker &pm);
// test for point hit
HitKind Hit(const Point &p, int minDist);
// gets nearest vertex or side to point
One<Point> const VertexAt(const Point &p, int minDist);
One<Rect> const SideAt(const Point &p, int minDist);
// open/close the polygon (invalid for rectangle markers)
bool Open(void);
bool Close(void);
// adds a vertex to the polygon (invalid for rectangle markers)
bool AddVertex(const Point &p);
bool AddVertex(const Array<Point> &ap);
void MakeRect(const Point &p1, const Point &p2);
// clears the marker
void Clear(void);
// member read access
PolyKind GetKind(void) const { return kind; }
bool IsClosed(void) const { return closed; }
Color GetBorderColor(void) const { return borderColor; }
int GetBorderLineType(void) const { return borderLineType; }
int GetBorderThickness(void) const { return borderThickness; }
RGBA GetFillColor(void) const { return fillColor; }
Rect const &GetBoundingBox(void);
Array<Point> const &GetPoints(void);
// gets a dragged PolyMarker giving start and end point
PolyMarker Drag(const Point &startP, const Point &endP);
// changes the PolyMarker at end of drag ops
void DoDrag(const Point &startP, const Point &endP);
// paint the PolyMarker on a given viewport
void Paint(const Rect &vport);
} ; // END Class PolyMarker
typedef Array<PolyMarker> PolyMarkers;
END_UPP_NAMESPACE
#endif

View file

@ -0,0 +1,291 @@
topic "class Pix : public PixBase";
[ $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9; $$1,0#37138531426314131252341829483380:structitem]
[l288;2 $$2,0#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
[H6;0 $$4,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:codeitem]
[{_}
[s1;:Pix`:`:class: [@(0.0.255) class]_[* Pix]_:_[@(0.0.255) public]_[*@3 PixBase]&]
[s2;%% Single page Leptonica raster object.&]
[s2;%% It encapsulates [* Pix] single`-page Leptonica raster objects&]
[s2;%% &]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Public enums]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:PIXRASTER`_BRING`_IN`_WHITE: [@(0.0.255) enum]_[* BringInModes]&]
[s2;%% &]
[s2; Color filling mode in operations that adds parts to images,
for example rotations :&]
[s0; &]
[s5; -|[* PIXRASTER`_BRING`_IN`_WHITE]-|Fills new parts with white color&]
[s5; -|[* PIXRASTER`_BRING`_IN`_BLACK]-|Fills new parts with black color&]
[s2;%% &]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Constructors, destructor and assignment operator]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:Pix`(`): [* Pix]()&]
[s2;%% Constructs an empty [* Pix].&]
[s3; &]
[s4; &]
[s5;:Pix`:`:Pix`(int`,int`,int`,RGBA`*`): [* Pix]([@(0.0.255) int]_[*@3 width],
[@(0.0.255) int]_[*@3 height], [@(0.0.255) int]_[*@3 depth], [_^RGBA^ RGBA]_`*[*@3 colorTable
]_`=_NULL)&]
[s2;%% Constructs and initializes Pix of [%-*@3 width] , [%-*@3 height]
and [%-*@3 depth] .&]
[s2;%% Optionally sets its [%-*@3 colorTable] if available.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(PIX`*`*`): [* Pix]([_^PIX^ PIX]_`*`*[*@3 `_pix])&]
[s2;%% Constructs [* Pix] from the Leptonica [* PIX] [%-*@3 `_pix] object.&]
[s2;%% To avoid mis`-use of owned [* PIX], it clears source pointer;
beware to double indirection when using.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(Pix const`&`): [* Pix]([* Pix]_[@(0.0.255) const]_`&[*@3 `_pix])&]
[s2;%% Copy constructor. Initializes [* Pix] object from a source one
[%-*@3 `_pix].&]
[s2;%% Source is [* reference copied], so any change on copy will reflect
on original object.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(Pix const`&`,int`): [* Pix]([* Pix]_[@(0.0.255) const]_`&[*@3 `_pix],
[@(0.0.255) int]_[*@3 i])&]
[s2;%% Deep copy constructor. Initializes [* Pix] object from a source
one [%-*@3 `_pix].&]
[s2;%% Source is [* deep copied], so any change on copy will [* NOT]
reflect on original object.&]
[s2;%% &]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(Raster`&`,bool`,int`): [* Pix]([_^Raster^ Raster]_`&[*@3 raster],
[@(0.0.255) bool]_[*@3 deepCopy]_`=_[@(0.0.255) false], [@(0.0.255) int]_[*@3 page]_`=_PIXR
ASTER`_CURPAGE)&]
[s2;%% Constructs [* Pix] from [%-*@3 page] in source [%-*@3 raster] with
optional [%-*@3 deepCopy] &]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(FileIn`&`,int`): [* Pix]([_^FileIn^ FileIn]_`&[*@3 fs],
[@(0.0.255) int]_[*@3 page]_`=_[@3 0])&]
[s2;%% Constructs [* Pix] reading its content from opened stream [%-*@3 fs]
; if fs supports multipaged images, an optional argument [%-*@3 page]
can select one of them.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Pix`(String const`&`,int`): [* Pix]([_^String^ String]_[@(0.0.255) const]_`&[*@3 f
ileName], [@(0.0.255) int]_[*@3 page]_`=_[@3 0])&]
[s2;%% Constructs [* Pix] reading its content from [%-*@3 fileName] file;
if file format supports multipaged images, an optional argument
[%-*@3 page] can select one of them&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:`~Pix`(`): [@(0.0.255) `~][* Pix]()&]
[s2;%% Frees underlying PIX decrementing its reference counter and
deleting it if needed.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:operator`=`(Pix`&`): [_^Pix^ Pix]_`&[* operator`=]([_^Pix^ Pix]_`&[*@3 pix])&]
[s2;%% Assignment operator. [%-*@3 pix] is [* referenced], NOT copied,
so any change on destination [* Pix] will reflect on original one.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:operator`<`<`=`(Pix`&`): [_^Pix^ Pix]_`&[@(0.0.255) operator]_<<`=([_^Pix^ Pix]_
`&[*@3 pix])&]
[s2;%% Assignment operator. [%-*@3 pix] is [* deep copied], NOT referenced,
so any change on destination [* Pix] will [* NOT ]reflect on original
one.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:DeepCopy`(Pix`&`): [_^Pix^ Pix]_`&[* DeepCopy]([_^Pix^ Pix]_`&[*@3 pix])&]
[s2;%% Return a [* deep copy] of [%-*@3 pix].&]
[s3;%% &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Internal handling of Leptonica objects]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:GetPIX`(int`): [@(0.0.255) virtual] [_^PIX^ PIX]_`*[* GetPIX]([@(0.0.255) int]_[*@3 p
age]_`=_PIXRASTER`_CURPAGE)&]
[s2;%% Gets underlying Leptonica [* PIX ]object for [%-*@3 page]. As
[* Pix] is single`-paged, just returns the underlying [* PIX] object.&]
[s2;%% [* WARNING], [* Pix] owns [* PIX ]object, so don`'t free it.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:operator PIX`*`(`): [* operator_PIX`*]()&]
[s2;%% Gets underlying Leptonica [* PIX ]object.&]
[s2;%% [* WARNING], [* Pix] owns [* PIX ]object, so don`'t free it.&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Page handling functions]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:SeekPage`(int`): [@(0.0.255) virtual] [@(0.0.255) void]_[* SeekPage]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Sets active [%-*@3 page]. As Pix object is single`-paged, does
nothing.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetPageCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPageCount]()&]
[s2;%% Gets number of images on PixRaster. As Pix object is single`-paged,
returns 1.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetActivePage`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetActivePage]()&]
[s2;%% Gets number of currently active page. As Pix object is single`-paged,
returns 0.&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Miscellaneous Raster functions]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:GetSize`(`): [@(0.0.255) virtual] [_^Size^ Size]_[* GetSize]()&]
[s2;%% Returns the size of Raster`'s active page in pixels.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetSizeEx`(int`): [@(0.0.255) virtual] [_^Size^ Size]_[* GetSizeEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the size of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetWidth`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetWidth]()&]
[s2;%% Returns the width of Raster in pixels for active page.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetWidthEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetWidthEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the width of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetHeight`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetHeight]()&]
[s2;%% Returns the height of Raster in pixels for active page.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetHeightEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetHeightEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the height of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetInfo`(`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_[* GetInfo]()&]
[s2;%% Returns the information about Raster`'s active page.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetInfoEx`(int`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_[* GetInfoEx(][@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the information about Raster for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetLine`(int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_[* GetLine]([@(0.0.255) i
nt]_[@3 line])&]
[s2;%% Reads a single scanline [%-*@3 line] from the raster`'s active
page. If possible, Raster should be optimized for reading scanlines
in ascending order `- this what most processing functions (should)
require.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetLineEx`(int`,int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_[* GetLine
Ex]([@(0.0.255) int]_[@3 line], [@(0.0.255) int]_[@3 page])&]
[s2;%% Reads a single scanline [%-*@3 line] from [%-*@3 page] ot the
raster. If possible, Raster should be optimized for reading scanlines
in ascending order `- this what most processing functions (should)
require.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetPaletteCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPaletteCount](
)&]
[s2;%% Returns the size of palette for raster`'s active page. If
there is no palette, returns 0&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetPaletteCountEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPaletteCo
untEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns the size of palette for raster`'s [%-*@3 page]. If there
is no palette, returns 0..&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetPalette`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_`*[* GetPa
lette]()&]
[s2;%% Returns active pages`'current palette, NULL if there is no
palette.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetPaletteEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_`*[* G
etPaletteEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns [%-*@3 page][%- `'s ]current palette, NULL if there is
no palette &]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:GetFormat`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ RasterF
ormat]_`*[* GetFormat]()&]
[s2;%% Returns the format of Raster`'s active page, can return NULL
if format is RGBA.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetFormatEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ Ra
sterFormat]_`*[* GetFormatEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns the format of Raster`'s [%-*@3 page], can return NULL
if format is RGBA.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:IsEmpty`(`): [@(0.0.255) bool]_[* IsEmpty]()&]
[s2;%% Returns [%-@(0.0.255) true] if raster contains no images.&]
[s3; &]
[s4; &]
[s5;:Pix`:`:operator bool`(`): [* operator_bool]()&]
[s2;%% Returns true if raster has some content, false otherwise&]
[s3; &]
[s4; &]
[s5;:Pix`:`:Clear`(`): [@(0.0.255) virtual] [@(0.0.255) void]_[* Clear]()_`=_[@3 0]&]
[s2;%% Clears raster content&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Polygon markers access]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:GetPolyMarkers`(`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarkers]_`*[* GetP
olyMarkers]()&]
[s2;%% Returns array of polygon markers for current raster page&]
[s3; &]
[s4; &]
[s5;:Pix`:`:GetPolyMarkersEx`(int`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarkers]_`*
[* GetPolyMarkersEx]([@(0.0.255) int]_[@3 page])&]
[s2; [%% Returns array of polygon markers for raster ][@3 page]&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Conversion and file I/O functions]]}}&]
[s0; &]
[s4; &]
[s5;:Pix`:`:Load`(Raster`&`,bool`,int`): [@(0.0.255) void]_[* Load]([_^Raster^ Raster][@(0.0.255) `&
]_[*@3 raster], [@(0.0.255) bool]_[*@3 deepCopy]_`=_[@(0.0.255) false],
[@(0.0.255) int]_[*@3 page]_`=_PIXRASTER`_CURPAGE)&]
[s2;%% Initializes [* Pix] from [%-*@3 page] in source [%-*@3 raster] with
optional [%-*@3 deepCopy] &]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Load`(FileIn`&`,int`): [@(0.0.255) bool]_[* Load]([_^FileIn^ FileIn]_`&[*@3 fs],
[@(0.0.255) int]_[*@3 page]_`=_[@3 0])&]
[s2;%% Initializes [* Pix] reading its content from opened stream [%-*@3 fs]
; if fs supports multipaged images, an optional argument [%-*@3 page]
can select one of them.&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Load`(String`,int`): [@(0.0.255) bool]_[* Load]([_^String^ String]_[*@3 fileName],
[@(0.0.255) int]_[*@3 page]_`=_[@3 0])&]
[s2;%% Initializes [* Pix] reading its content from [%-*@3 fileName]
file; if file format supports multipaged images, an optional
argument [%-*@3 page] can select one of them&]
[s3;%% &]
[s4; &]
[s5;:Pix`:`:Save`(String`): [@(0.0.255) bool]_[* Save]([_^String^ String]_[*@3 fileName])&]
[s2;%% Stores Pix into [%-*@3 fileName] named file.&]
[s3;%% &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Leptonica functions wrappers]]}}&]
[s0; &]
[s2; [*^topic`:`/`/Leptonica`/src`/PixRaster`$en`-us`#PixRaster`:`:class^ Pix]
provides wrappers to many Leptonica image handling functions;
as the list is huge it has been divided by cathegories; see Leptonica
wrappers index.&]
[s0; ]

View file

@ -0,0 +1,159 @@
topic "class PixBase : public Raster";
[ $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9; $$1,0#37138531426314131252341829483380:structitem]
[l288;2 $$2,0#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
[H6;0 $$4,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:codeitem]
[{_}
[s1;:PixBase`:`:class: [@(0.0.255) class]_[* PixBase]_:_[@(0.0.255) public]_[*@3 Raster]&]
[s2;%% This is the base class of Leptonica raster objects, Pix and
PixRaster.&]
[s2;%% It has the sole purpose to provide a common base class for
Leptonica raster pointers,&]
[s2;%% with some common function prototypes for pointer access.&]
[s2;%% Used mainly inside PixRasterCtrl&]
[s2;%% PixBase is an abstract class and cannot be instantiated.&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Internal handling of Leptonica objects]]}}&]
[s0; &]
[s4; &]
[s5;:PixBase`:`:GetPIX`(int`): [@(0.0.255) virtual] [_^PIX^ PIX]_`*[* GetPIX]([@(0.0.255) int
]_[*@3 page]_`=_PIXRASTER`_CURPAGE)_`=_[@3 0]&]
[s2;%% Gets underlying Leptonica PIX object for [%-*@3 page].&]
[s3;%% &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Page handling functions]]}}&]
[s0; &]
[s4; &]
[s5;:PixBase`:`:SeekPage`(int`): [@(0.0.255) virtual] [@(0.0.255) void]_[* SeekPage]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Sets active [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetPageCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPageCount]()&]
[s2;%% Gets number of images on PixRaster&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetActivePage`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetActivePage](
)&]
[s2;%% Gets number of currently active page&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Miscellaneous Raster functions]]}}&]
[s0; &]
[s4; &]
[s5;:PixBase`:`:GetSize`(`): [@(0.0.255) virtual] [_^Size^ Size]_[* GetSize]()&]
[s2;%% Returns the size of Raster`'s active page in pixels.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetSizeEx`(int`): [@(0.0.255) virtual] [_^Size^ Size]_[* GetSizeEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the size of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetWidth`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetWidth]()&]
[s2;%% Returns the width of Raster in pixels for active page.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetWidthEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetWidthEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the width of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetHeight`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetHeight]()&]
[s2;%% Returns the height of Raster in pixels for active page.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetHeightEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetHeightEx]([@(0.0.255) i
nt]_[@3 page])&]
[s2;%% Returns the height of Raster in pixels for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetInfo`(`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_[* GetInfo]()&]
[s2;%% Returns the information about Raster`'s active page.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetInfoEx`(int`): [@(0.0.255) virtual] [_^Raster`:`:Info^ Info]_[* GetInfoE
x(][@(0.0.255) int]_[@3 page])&]
[s2;%% Returns the information about Raster for [%-*@3 page].&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetLine`(int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_[* GetLine]([@(0.0.255) i
nt]_[@3 line])&]
[s2;%% Reads a single scanline [%-*@3 line] from the raster`'s active
page. If possible, Raster should be optimized for reading scanlines
in ascending order `- this what most processing functions (should)
require.&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetLineEx`(int`,int`): [@(0.0.255) virtual] [_^Raster`:`:Line^ Line]_[* Get
LineEx]([@(0.0.255) int]_[@3 line], [@(0.0.255) int]_[@3 page])&]
[s2;%% Reads a single scanline [%-*@3 line] from [%-*@3 page] ot the
raster. If possible, Raster should be optimized for reading scanlines
in ascending order `- this what most processing functions (should)
require.&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetPaletteCount`(`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPaletteCou
nt]()&]
[s2;%% Returns the size of palette for raster`'s active page. If
there is no palette, returns 0&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetPaletteCountEx`(int`): [@(0.0.255) virtual] [@(0.0.255) int]_[* GetPalet
teCountEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns the size of palette for raster`'s [%-*@3 page]. If there
is no palette, returns 0..&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetPalette`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_`*[* G
etPalette]()&]
[s2;%% Returns active pages`'current palette, NULL if there is no
palette.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetPaletteEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RGBA^ RGBA]_
`*[* GetPaletteEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns [%-*@3 page][%- `'s ]current palette, NULL if there is
no palette &]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:GetFormat`(`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ Ras
terFormat]_`*[* GetFormat]()&]
[s2;%% Returns the format of Raster`'s active page, can return NULL
if format is RGBA.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetFormatEx`(int`): [@(0.0.255) virtual] [@(0.0.255) const]_[_^RasterFormat^ R
asterFormat]_`*[* GetFormatEx]([@(0.0.255) int]_[@3 page])&]
[s2;%% Returns the format of Raster`'s [%-*@3 page], can return NULL
if format is RGBA.&]
[s3;%% &]
[s4; &]
[s5;:PixBase`:`:IsEmpty`(`): [@(0.0.255) bool]_[* IsEmpty]()&]
[s2;%% Returns [%-@(0.0.255) true] if raster contains no images.&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:operator bool`(`): [* operator_bool]()&]
[s2;%% Returns true if raster has some content, false otherwise&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:Clear`(`): [@(0.0.255) virtual] [@(0.0.255) void]_[* Clear]()_`=_[@3 0]&]
[s2;%% Clears raster content&]
[s3; &]
[s0; &]
[ {{10000F(128)G(128)@1 [s0;%% [* Polygon markers access]]}}&]
[s0; &]
[s4; &]
[s5;:PixBase`:`:GetPolyMarkers`(`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarkers]_`*[* G
etPolyMarkers]()&]
[s2;%% Returns array of polygon markers for current raster page&]
[s3; &]
[s4; &]
[s5;:PixBase`:`:GetPolyMarkersEx`(int`): [@(0.0.255) virtual] [_^PolyMarkers^ PolyMarkers
]_`*[* GetPolyMarkersEx]([@(0.0.255) int]_[@3 page])&]
[s2; [%% Returns array of polygon markers for raster ][@3 page]&]
[s3; &]
[s0; ]

View file

@ -1,5 +1,6 @@
#include "ImageCache.h"
NAMESPACE_UPP
///////////////////////////////////////////////////////////////////////////////////////////////
// constructor
@ -356,3 +357,5 @@ Size const ImageCache::GetSize(void)
return imageBuffer.GetSize();
} // EBND ImageCache::GetSize()
END_UPP_NAMESPACE

View file

@ -3,7 +3,7 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
NAMESPACE_UPP
class ImageCache
{
@ -59,4 +59,6 @@ class ImageCache
}; // END Class ImageCache
END_UPP_NAMESPACE
#endif

View file

@ -1,6 +1,8 @@
#include "PixRasterBaseCtrl.h"
#include "PixRasterCtrl.h"
NAMESPACE_UPP
#define BackColor SColorFace()
///////////////////////////////////////////////////////////////////////////////////////////////
@ -29,6 +31,11 @@ PixRasterBaseCtrl::PixRasterBaseCtrl(PixRasterCtrl *t, bool hScroll, bool vScrol
// marks cache as invalid
imageCache.SetValid(false);
// no marker selected
selectedMarker = NULL;
highlightMarker = NULL;
dragPolygon.Clear();
} // END constructor class PixRasterBaseCtrl
///////////////////////////////////////////////////////////////////////////////////////////////
@ -37,6 +44,167 @@ PixRasterBaseCtrl::~PixRasterBaseCtrl()
{
} // END destructor class PixRasterBaseCtrl
///////////////////////////////////////////////////////////////////////////////////////////////
// converts a page and an array of page points into an array of view points
Vector<Point> PixRasterBaseCtrl::PointsToView(int page, Vector<Point> const &pts)
{
// gets the PixRaster object
PixBase *pixBase = pixRasterCtrl->GetPixBase();
// calculate view position inside the full tiff image
// in page coords
int viewLeft, viewTop;
if(hScrollBar.IsVisible())
viewLeft = ScaleToPage(hScrollBar.Get());
else
viewLeft = 0;
if(vScrollBar.IsVisible())
viewTop = ScaleToPage(vScrollBar.Get());
else
viewTop = 0;
// gets requested page position (in page coordinates)
int pageTop = 0;
int gapSize = ScaleToPage(10);
for(int i = 0; i < page; i++)
pageTop += pixBase->GetHeightEx(i) + gapSize;
// if page not visible, just return an empty array
int pageBottom = pageTop + pixBase->GetHeightEx(page);
int viewBottom = viewTop + ScaleToPage(GetSize().cy);
if(viewBottom < pageTop || viewTop > pageBottom)
return Vector<Point>();
// horizontal gap if page width < ctrl width
int viewWidth = ScaleToPage(GetSize().cx);
int pageWidth = pixBase->GetWidthEx(page);
int hGap;
if(pageWidth < viewWidth)
hGap = (viewWidth - pageWidth) / 2;
else
hGap = 0;
// calculates the offset of points in page coordinates
int dx = -viewLeft + hGap;
int dy = -viewTop + pageTop;
// creates the new array scaling the coordinates
Vector<Point>res(pts, 1);
for(int iPoint = 0; iPoint < res.GetCount(); iPoint++)
{
res[iPoint].x = ScaleToView(res[iPoint].x + dx);
res[iPoint].y = ScaleToView(res[iPoint].y + dy);
}
return res;
} // END PixRasterBaseCtrl::PointsToView()
///////////////////////////////////////////////////////////////////////////////////////////////
// converts a view point into page + page point
bool PixRasterBaseCtrl::PointToPage(Point const &srcPt, int &page, Point &destPt)
{
if(!pixRasterCtrl)
return false;
// gets the PixRaster object
PixBase *pixBase = pixRasterCtrl->GetPixBase();
if(!pixBase || !pixBase->GetPageCount())
return false;
// gets point position in raster coordinates
int yPos = ScaleToPage(vScrollBar.Get() + srcPt.y);
// gets gap size between pages
int gapSize = ScaleToPage(10);
// iterates through page positions to find the requested one
int top = 0;
for(int iPage = 0; iPage < pixBase->GetPageCount(); iPage++)
{
int pageWidth = pixBase->GetWidthEx(iPage);
int pageHeight = pixBase->GetHeightEx(iPage);
int bottom = top + pageHeight;
if(yPos >= top && yPos <= bottom)
{
int xPos;
if(ScaleToView(pageWidth) >= GetSize().cx)
xPos = ScaleToPage(srcPt.x);
else
xPos = ScaleToPage(srcPt.x) - (ScaleToPage(GetSize().cx) - pageWidth) / 2;
if(xPos < 0 || xPos > pageWidth)
return false;
destPt = Point(xPos, yPos - top);
page = iPage;
return true;
}
top += pageHeight + gapSize;
}
} // END PixRasterBaseCtrl::PointToPage()
///////////////////////////////////////////////////////////////////////////////////////////////
// left mouse button handlers
void PixRasterBaseCtrl::LeftDown(Point p, dword keyflags)
{
// translates mouse coordinate in page and page coordinates
int page;
Point pagePt;
if(!PointToPage(p, page, pagePt))
return;
// found a page on point, scan it to get the marker on it (if any)
// gets the PixRaster object
PixBase *pixBase = pixRasterCtrl->GetPixBase();
int minDist = ScaleToPage(5);
Markers *markers = pixBase->GetMarkersEx(page);
for(int i = 0; i < markers->GetCount(); i++)
{
Marker &marker = (*markers)[i];
int index;
Marker::HitKind hitKind = marker.Hit(pagePt, minDist, index);
if(hitKind == Marker::Miss)
continue;
// found a marker on cursor -- start drag op
dragPolygon = PointsToView(page, marker.DragOutline(pagePt, pagePt, minDist));
selectedMarker = &marker;
dragPoint = pagePt;
dragPage = page;
}
} // END PixRasterBaseCtrl::LeftDown()
void PixRasterBaseCtrl::LeftUp(Point p, dword keyflags)
{
Point endDragPoint;
int endDragPage;
// if dragging a marker, stop and update it
if(selectedMarker)
{
int minDist = ScaleToPage(5);
PointToPage(p, endDragPage, endDragPoint);
// if dest point still on page, complete dragging op
// otherwise abort it
if(endDragPage == dragPage)
selectedMarker->Drag(dragPoint, endDragPoint, minDist);
selectedMarker = NULL;
pixRasterCtrl->Refresh();
}
} // END PixRasterBaseCtrl::LeftDown()
///////////////////////////////////////////////////////////////////////////////////////////////
// right mouse button handlers
void PixRasterBaseCtrl::RightDown(Point p, dword keyflags)
{
} // END PixRasterBaseCtrl::RightDown()
///////////////////////////////////////////////////////////////////////////////////////////////
// middle mouse button pan handlers
void PixRasterBaseCtrl::MiddleDown(Point p, dword keyflags)
@ -49,27 +217,77 @@ void PixRasterBaseCtrl::MiddleDown(Point p, dword keyflags)
void PixRasterBaseCtrl::MouseMove(Point p, dword keyflags)
{
// reacts only to moves with middle button pressed
if(!(keyflags & K_MOUSEMIDDLE))
Point endDragPoint;
int endDragPage;
if(!pixRasterCtrl || !pixRasterCtrl->GetPixBase())
return;
// gets distance between current and pan point
int dx = panPoint.x - p.x + panHScroll;
int dy = panPoint.y - p.y + panVScroll;
// gets max scrolling values
int hMax = hScrollBar.GetTotal();
int vMax = vScrollBar.GetTotal();
// check what we're dragging....
if(keyflags & K_MOUSEMIDDLE)
{
// moves with middle button pressed -- panning image
// gets distance between current and pan point
int dx = panPoint.x - p.x + panHScroll;
int dy = panPoint.y - p.y + panVScroll;
// sets new pan position
if(dx < 0) dx = 0;
if(dx > hMax) dx = hMax;
if(dy < 0) dy = 0;
if(dy > vMax) dy = vMax;
hScrollBar.Set(dx);
vScrollBar.Set(dy);
// gets max scrolling values
int hMax = hScrollBar.GetTotal();
int vMax = vScrollBar.GetTotal();
// sets new pan position
if(dx < 0) dx = 0;
if(dx > hMax) dx = hMax;
if(dy < 0) dy = 0;
if(dy > vMax) dy = vMax;
hScrollBar.Set(dx);
vScrollBar.Set(dy);
Refresh();
}
else if((keyflags & K_MOUSELEFT) && selectedMarker)
{
// dragging a marker
int minDist = ScaleToPage(5);
PointToPage(p, endDragPage, endDragPoint);
Refresh();
if(endDragPage == dragPage)
dragPolygon = PointsToView(dragPage, selectedMarker->DragOutline(dragPoint, endDragPoint, minDist));
else
dragPolygon.Clear();
pixRasterCtrl->Refresh();
}
else
{
// nothing else, just highlight marker under cursor
// and set the appropriate cursor
int page;
Point pagePt;
int minDist = ScaleToPage(5);
Marker *newMarker = NULL;
if(PointToPage(p, page, pagePt))
{
PixBase *pixBase = pixRasterCtrl->GetPixBase();
Markers *markers = pixBase->GetMarkersEx(page);
for(int iMarker = 0; iMarker < markers->GetCount(); iMarker++)
{
Marker &marker = (*markers)[iMarker];
int index;
if(marker.Hit(pagePt, minDist, index) != Marker::Miss)
{
newMarker = &marker;
break;
}
}
}
if(highlightMarker != newMarker)
{
highlightMarker = newMarker;
pixRasterCtrl->Refresh();
}
}
} // END PixRasterBaseCtrl::MouseMove()
@ -181,14 +399,14 @@ void PixRasterBaseCtrl::PaintCache()
pixBase->SeekPage(i);
// translates current top of page in view coordinates
int viewCurrentTop = iscale(currentTop, imageScale, 1000);
int viewCurrentTop = ScaleToView(currentTop);
// gets current page size and translates it in view coordinates
Rect viewPageRect(
-cacheLeft,
-cacheTop + viewCurrentTop,
iscale(pixBase->GetSize().cx, imageScale, 1000) - cacheLeft,
iscale(pixBase->GetSize().cy, imageScale, 1000) - cacheTop + viewCurrentTop
ScaleToView(pixBase->GetSize().cx) - cacheLeft,
ScaleToView(pixBase->GetSize().cy) - cacheTop + viewCurrentTop
);
// now scans the rectangles that must be repainted
@ -206,10 +424,10 @@ void PixRasterBaseCtrl::PaintCache()
{
// gets back the tiff rectangle
Rect tiffRect(
iscale(rect.left + cacheLeft, 1000, imageScale),
iscale(rect.top + cacheTop, 1000, imageScale) - currentTop,
iscale(rect.right + cacheLeft, 1000, imageScale),
iscale(rect.bottom + cacheTop, 1000, imageScale) -currentTop
ScaleToPage(rect.left + cacheLeft),
ScaleToPage(rect.top + cacheTop) - currentTop,
ScaleToPage(rect.right + cacheLeft),
ScaleToPage(rect.bottom + cacheTop) -currentTop
);
// rescales the image area
@ -223,7 +441,7 @@ void PixRasterBaseCtrl::PaintCache()
imageCache.Copy(Point(rect.left, rect.top), Rect(0, 0, img.GetWidth(), img.GetHeight()), img);
}
}
currentTop += pixBase->GetHeight() + iscale(10, 1000, imageScale);
currentTop += pixBase->GetHeight() + ScaleToPage(10);
}
// restore PixRaster's active page
@ -234,8 +452,105 @@ void PixRasterBaseCtrl::PaintCache()
///////////////////////////////////////////////////////////////////////////////////////////////
// repaint polygon markers over the images
void PixRasterBaseCtrl::PaintMarkers(void)
void PixRasterBaseCtrl::PaintMarkers(Draw &d)
{
// if no associated PixRaster object, do nothing
if(!pixRasterCtrl || !pixRasterCtrl->GetPixBase())
return;
// gets associated PixRaster object
PixBase *pixBase = pixRasterCtrl->GetPixBase();
// calculate view position inside the full tiff image
int left, top;
if(hScrollBar.IsVisible())
left = hScrollBar.Get();
else
left = 0;
if(vScrollBar.IsVisible())
top = vScrollBar.Get();
else
top = 0;
// loop for all pages, to see which of them fits the view
int currentTop = 0;
int currentPage = pixBase->GetActivePage();
for(int i = 0 ; i < pixBase->GetPageCount() ; i++)
{
// sets the active page
pixBase->SeekPage(i);
// translates current top of page in view coordinates
int viewCurrentTop = ScaleToView(currentTop);
// gets current page size and translates it in view coordinates
Rect viewPageRect(
-left,
-top + viewCurrentTop,
ScaleToView(pixBase->GetSize().cx) - left,
ScaleToView(pixBase->GetSize().cy) - top + viewCurrentTop
);
// this is when page view is smaller than ctrl view
int hGap;
int pw = viewPageRect.right - viewPageRect.left;
if(pw >= GetSize().cx)
hGap = 0;
else
hGap = (GetSize().cx - pw) / 2;
// checks wether the page fits the view..
viewPageRect.Intersect(GetView());
if(!viewPageRect.IsEmpty())
{
// this page is inside view, let's take its markers
Markers &markers = *pixBase->GetMarkers();
for(int iMarker = 0; iMarker < markers.GetCount(); iMarker++)
{
Marker &marker = markers[iMarker];
// don't paint marker being dragged... it will be done by
// drag routine itself
if(&marker == selectedMarker)
continue;
switch(marker.GetKind())
{
case Marker::EmptyMarker:
continue;
default:
Vector<Point> pts = marker.GetPoints();
Point points[pts.GetCount()];
for(int i = 0; i < pts.GetCount(); i++)
{
points[i].x = ScaleToView(pts[i].x) - left + hGap;
points[i].y = ScaleToView(pts[i].y) - top + viewCurrentTop;
}
if(&marker != highlightMarker)
d.DrawPolygon(points, pts.GetCount(),
marker.GetFillColor(),
marker.GetBorderThickness(),
marker.GetBorderColor(),
marker.GetBorderLineType(),
White);
else
d.DrawPolygon(points, pts.GetCount(),
marker.GetSelFillColor(),
marker.GetSelBorderThickness(),
marker.GetSelBorderColor(),
marker.GetSelBorderLineType(),
White);
break;
}
}
}
currentTop += pixBase->GetHeight() + ScaleToPage(10);
}
// restore PixRaster's active page
pixBase->SeekPage(currentPage);
} // END PixRasterBaseCtrl::PaintMarkers()
@ -258,6 +573,20 @@ void PixRasterBaseCtrl::Paint(Draw &d)
imageCache.Paint(d, Point(0, 0));
else
imageCache.Paint(d, Point((GetSize().cx - imageCache.GetWidth()) / 2, 0));
// paints markers inside control
PaintMarkers(d);
// if dragging, paints rubber banded polygon
if(selectedMarker && dragPolygon.GetCount())
{
d.DrawPolygon(dragPolygon, dragPolygon.GetCount(),
selectedMarker->GetFillColor(),
selectedMarker->GetBorderThickness(),
selectedMarker->GetBorderColor(),
PEN_DOT,
White);
}
} // END LeptonicaBaseCtrl::Paint()
@ -334,14 +663,14 @@ void PixRasterBaseCtrl::Layout(void)
}
// now calculate gaps to be exactly 10 pixels in every zoom factor
int gapSize = iscale(10, 1000, imageScale);
int gapSize = ScaleToPage(10);
// adds total gaps sizes to total height
rasterHeight += (pageCount -1) * gapSize;
// and finally, sets up scrollbars and shows them
// and calculate cache sizes
int scaledRasterHeight = iscale(rasterHeight, imageScale, 1000);
int scaledRasterHeight = ScaleToView(rasterHeight);
int cacheHeight;
vScrollBar.SetPage(GetSize().cy);
vScrollBar.SetTotal(scaledRasterHeight);
@ -360,7 +689,7 @@ void PixRasterBaseCtrl::Layout(void)
vScrollBar.Hide();
cacheHeight = scaledRasterHeight;
}
int scaledRasterWidth = iscale(rasterWidth, imageScale, 1000);
int scaledRasterWidth = ScaleToView(rasterWidth);
int cacheWidth;
hScrollBar.SetPage(GetSize().cx);
hScrollBar.SetTotal(scaledRasterWidth);
@ -389,4 +718,6 @@ void PixRasterBaseCtrl::Layout(void)
// mark layout terminated
inside = false;
} // END LeptonicaBaseCtrl::Layout()
} // END PixRasterBaseCtrl::Layout()
END_UPP_NAMESPACE

View file

@ -5,16 +5,17 @@
#include "ImageCache.h"
using namespace Upp;
NAMESPACE_UPP;
// types of zoom inside view
enum ZoomTypes { ZOOM_NORMAL, ZOOM_WIDTH, ZOOM_PAGE };
// forward declaration
// forward declarations
class PixRasterCtrl;
class Marker;
// Tiff view ctrl class
class PixRasterBaseCtrl : public Ctrl
class PixRasterBaseCtrl : public LocalLoop
{
public :
typedef PixRasterBaseCtrl CLASSNAME;
@ -34,9 +35,21 @@ class PixRasterBaseCtrl : public Ctrl
// calculates image scale factor
// pure virtual function, MUST be redefined on derived classes
virtual int CalcScale(int imageScale, int rasterWidth, int maxPageHeight) = 0;
// scales a coordinate from page to view
inline int ScaleToView(int x) { return iscale(x, imageScale, 1000); }
// scales a coordinate from view to page
inline int ScaleToPage(int x) { return iscale(x, 1000, imageScale); }
// converts a page and an array of page points into an array of view points
Vector<Point> PointsToView(int page, Vector<Point> const &pts);
// converts a view point into page + page point
bool PointToPage(Point const &srcPt, int &page, Point &destPt);
// scrollbar handler
virtual void OnScroll(void);
virtual void OnScroll();
// paint routine
virtual void Paint(Draw &d);
@ -46,24 +59,42 @@ class PixRasterBaseCtrl : public Ctrl
int cacheLeft, cacheTop;
// repaint images on image cache
virtual void PaintCache(void);
virtual void PaintCache();
// repaint polygon markers over the images
virtual void PaintMarkers(void);
virtual void PaintMarkers(Draw &d);
// mouse button handlers
virtual void LeftDown(Point p, dword keyflags);
virtual void LeftUp(Point p, dword keyflags);
virtual void MiddleDown(Point p, dword keyflags);
virtual void RightDown(Point p, dword keyflags);
virtual void MouseMove(Point p, dword keyflags);
// mouse wheel handler
virtual void MouseWheel(Point p, int zdelta, dword keyflags);
// pan point on middle mouse button pan operations
// point for pan operations
Point panPoint;
int panHScroll, panVScroll;
// mouse button pan handlers
virtual void MiddleDown(Point p, dword keyflags);
virtual void MouseMove(Point p, dword keyflags);
virtual Image CursorImage(Point p, dword keyflags);
// highlighted marker (under mouse cursor)
Marker *highlightMarker;
// selected marker and drag mode
Marker *selectedMarker;
// page on which dragging is done
int dragPage;
// starting drag point
Point dragPoint;
// current polygon in dragging ops
Vector<Point>dragPolygon;
public :
// constructor
@ -77,4 +108,6 @@ class PixRasterBaseCtrl : public Ctrl
} ; // END class PixRasterBaseCtrl
END_UPP_NAMESPACE
#endif

View file

@ -3,6 +3,8 @@
#include "PixRasterThumbsCtrl.h"
#include "PixRasterViewCtrl.h"
NAMESPACE_UPP
// initialize the control
void PixRasterCtrl::Create(PixBase *_pixBase)
{
@ -152,3 +154,4 @@ void PixRasterCtrl::Reload(void)
view->Layout();
}
END_UPP_NAMESPACE

View file

@ -7,7 +7,7 @@
#include "PixRasterBaseCtrl.h"
using namespace Upp;
NAMESPACE_UPP
class PixRasterThumbsCtrl;
class PixRasterViewCtrl;
@ -84,4 +84,6 @@ class PixRasterCtrl : public Ctrl
} ; // END Class PixRasterCtrl
END_UPP_NAMESPACE
#endif

View file

@ -1,6 +1,8 @@
#include "PixRasterThumbsCtrl.h"
#include "PixRasterCtrl.h"
NAMESPACE_UPP
// Scale factor between pane size and thumbs sizes
const int THUMBS_HSIZE_MUL = 9;
const int THUMBS_HSIZE_DIV = 10;
@ -36,10 +38,10 @@ void PixRasterThumbsCtrl::LeftDown(Point p, dword keyflags)
{
// gets point position in raster coordinates
int clickPos = vScrollBar.Get() + iscale(p.y, vScrollBar.GetPage(), GetView().GetHeight());
clickPos = iscale(clickPos, 1000, imageScale);
clickPos = ScaleToPage(clickPos);
// gets gap size between pages
int gapSize = iscale(10, 1000, imageScale);
int gapSize = ScaleToPage(10);
// gets the PixRaster object
PixBase *pixBase = pixRasterCtrl->GetPixBase();
@ -58,4 +60,9 @@ void PixRasterThumbsCtrl::LeftDown(Point p, dword keyflags)
top += pixBase->GetHeightEx(iPage) + gapSize;
}
// calls base class handler -- used for dragging
PixRasterBaseCtrl::LeftDown(p, keyflags);
} // END PixRasterThumbsCtrl::LeftDown()
END_UPP_NAMESPACE

View file

@ -7,7 +7,7 @@
#include "PixRasterBaseCtrl.h"
using namespace Upp;
NAMESPACE_UPP
// forward declaration
class PixRasterCtrl;
@ -31,8 +31,10 @@ class PixRasterThumbsCtrl : public PixRasterBaseCtrl
~PixRasterThumbsCtrl();
// left click handler --> shows requested page in viewer
void LeftDown(Point p, dword keyflags);
virtual void LeftDown(Point p, dword keyflags);
} ; // END class PixRasterThumbsCtrl
END_UPP_NAMESPACE
#endif

View file

@ -1,6 +1,8 @@
#include "PixRasterViewCtrl.h"
#include "PixRasterCtrl.h"
NAMESPACE_UPP
#define BackColor SColorFace()
///////////////////////////////////////////////////////////////////////////////////////////////
@ -188,3 +190,5 @@ void PixRasterViewCtrl::SetPage(int page)
Layout();
} // END PixRasterViewCtrl::SetPage()
END_UPP_NAMESPACE

View file

@ -5,7 +5,7 @@
#include "PixRasterBaseCtrl.h"
using namespace Upp;
NAMESPACE_UPP
// Tiff view ctrl class
class PixRasterViewCtrl : public PixRasterBaseCtrl
@ -53,4 +53,6 @@ class PixRasterViewCtrl : public PixRasterBaseCtrl
} ; // END class PixRasterViewCtrl
END_UPP_NAMESPACE
#endif

View file

@ -5,7 +5,7 @@ static void PageLayout(Pix &source, PixRaster &pixRaster)
pixRaster.Add(source);
PixRaster regions = source.GetRegionsBinary();
CHECKR(regions, "Error getting page layout");
pixRaster.Add(regions);
pixRaster.Add(regions);
}
void TestLeptonica::onPageLayout()

View file

@ -0,0 +1,40 @@
#include "TestLeptonica.h"
static void PageMarkers(Pix & source, PixRaster &pixRaster)
{
Markers *markers;
pixRaster.Add(source, true);
pixRaster.Add(source, true);
markers = pixRaster[0].GetMarkers();
markers->Add(new Marker(Point(100, 100), Point(300, 400)));
markers->Add(new Marker(Point(0, 500), Point(300, 800)));
markers = pixRaster[1].GetMarkers();
markers->Add(new Marker(Point(0, 0), Point(200, 100)));
markers->Add(new Marker(Point(400, 500), Point(900, 600)));
}
void TestLeptonica::onPageMarkers()
{
String fileName;
FileSelector fs;
Pix source;
FileIn s("/home/massimo/tmp/TestLept1.tif");
// Loads pixraster from source raster
CHECKR(source.Load(s), "Error loading image");
s.Close();
// apply line removal algothithm
pixRaster.Clear();
PageMarkers(source, pixRaster);
// refresh the PixRasterCtrl control with the new image contents
pixRasterCtrl.Reload();
pixRasterCtrl.SetPage(0);
}

View file

@ -29,6 +29,7 @@ class TestLeptonica : public WithTestLeptonicaLayout<TopWindow>
void onLineRemoval(void);
void onPageLayout(void);
void onBaseLine(void);
void onPageMarkers(void);
void onQuit(void);
// PIX raster

View file

@ -1,8 +1,9 @@
LAYOUT(TestLeptonicaLayout, 640, 400)
ITEM(Button, BaseLineButton, SetLabel(t_("Baseline test")).Tip(t_("Find baseline of text lines of a scanned page")).LeftPosZ(8, 92).TopPosZ(56, 15))
ITEM(Button, PageMarkersButton, SetLabel(t_("Page markers")).Tip(t_("Test page area marking")).LeftPosZ(8, 92).TopPosZ(80, 15))
ITEM(Button, QuitButton, SetLabel(t_("\aQuit")).LeftPosZ(8, 92).BottomPosZ(9, 15))
ITEM(PixRasterCtrl, pixRasterCtrl, SetFrame(InsetFrame()).HSizePosZ(108, 8).VSizePosZ(8, 8))
ITEM(Button, LineRemovalButton, SetLabel(t_("Line removal test")).Tip(t_("Removes horizontal lines from a scanned paper drawing")).LeftPosZ(8, 92).TopPosZ(8, 15))
ITEM(Button, PageLayoutButton, SetLabel(t_("Page layout test")).Tip(t_("Finds the layout of a page, separating graphics from text")).LeftPosZ(8, 92).TopPosZ(32, 15))
ITEM(Button, BaseLineButton, SetLabel(t_("Baseline test")).Tip(t_("Find baseline of text lines of a scanned page")).LeftPosZ(8, 92).TopPosZ(56, 15))
END_LAYOUT

View file

@ -9,6 +9,7 @@ file
LineRemoval.cpp,
PageLayout.cpp,
BaseLine.cpp,
PageMarkers.cpp,
main.cpp;
mainconfig

View file

@ -17,6 +17,7 @@ TestLeptonica::TestLeptonica()
LineRemovalButton <<= THISBACK(onLineRemoval);
PageLayoutButton <<= THISBACK(onPageLayout);
BaseLineButton <<= THISBACK(onBaseLine);
PageMarkersButton <<= THISBACK(onPageMarkers);
QuitButton <<= THISBACK(onQuit);
}