1 Preparation for Raster Editing
Table of Contents
The buffer used for raster editing is specified in terms of the number of primitives. This should be done before the first makeprim call.
Since each primitive requires only 28 bytes of memory, you can specify a few thousand to a few million.
If the number of inserted primitives exceeds the buffer and causes a buffer overflow, you will need to:
- Save the current buffer using the undo function.
- Expand the buffer, re-execute makeprim, and restore the buffer.
Although this process is inefficient, it can be managed.
// Set the upper limit of the number of insertable primitives
// If the limit is reached, an error will be returned by medit_insert or medit_separate
// In such cases, discard the class temporarily, re-create it, then call msetinsertmax and re-insert
// Input:
// int insertmax; The default value is 0. In a typical A3, 400dpi Japanese document, 10000 is sufficient.
void msetinsertmax(int insertmax){minsertmax = insertmax;}
Sample code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Specify a 20-digit code supplied by the license manager or the path to a license code file to initialize the library
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// If using a license code file path: CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Background is 0, foreground is 1 in the monochrome image
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
2 Delete Primitives
Table of Contents
This function deletes the specified primitive or all primitives belonging to the specified cluster.
You can also specify whether to reflect the changes in the original image or not.
// Delete primitive/cluster
// Input
// int flag; 1...reflect changes in the image data/0...don't reflect changes
// PRIMITIVE* prim; primitive (don't make a copy, use the address)
// Return
// 0 normal termination
// negative error
int medit_delete(int flag,PRIMITIVE* prim);
int medit_delete(int flag,CLUSTER* pcluster);
Sample code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Initialize the library by specifying the 20-digit code supplied by the licenser or the path to the license code file
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// If using the license code path, use CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
// 1...Select primitives or extract clusters
// 2...Delete selected primitives and reflect changes in the original image
int i1 = pjocrprim->medit_delete(1,prim);
if(i1 < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
2 Primitive Insertion
Table of Contents
The primitive to be inserted is created by creating an instance of another CJocrPrim using makeprim, etc.
It is also possible to obtain the new address of the inserted primitive.
You can also specify whether or not to reflect it in the original image.
Even if the inserted primitive overlaps with other primitives in the insertion destination, they are separated as separate primitives in the data.
// Insert a primitive (if this is pjocrprim, it will be a copy)
// Input
// int flag; 1...Reflect in the image data/0...Do not reflect
// CJocrPrim* pjocrprim; The instance of CJocrPrim to which the prim belongs
// PRIMITIVE* prim; Primitive (copy is not allowed because the address is used)
// CLUSTER* pcluster; Cluster (copy is not allowed because the address is used)
// int left, top; Destination of movement
// Output
// PRIMITIVE*&priminsert; Address of the inserted primitive
// Return Value
// 0 Normal termination
// Negative Error
int medit_insert(int flag,CJocrPrim* pjocrprim,PRIMITIVE* prim,int left,int top,PRIMITIVE*& priminsert);
int medit_insert(int flag,CJocrPrim* pjocrprim,CLUSTER* pcluster,int left,int top);
// Clusterize all primitives
// Used for rendering and cluster movement
int mallprim2cluster();
Sample code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Initialize the library by specifying a 20-digit code supplied from the licenser or the path to the license code file
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// If it is the path to the license code, CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
// 1... Makeprim using another instance pjocrprim1 for the image to be inserted
// 2... Use makeallprim2cluster to merge all primitives into one cluster
// 3... Insert the cluster at the specified position
int i1 = pjocrprim->medit_insert(1,pjocrprim1,pcluster,100,100);
if(i1 < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
2 Primitive Movement
Table of Contents
Specify the address of the primitive or the cluster that is a set of primitives to move the primitive or the primitive set (cluster).
You can also specify whether to reflect it in the original image.
Even if the position overlaps with other primitives at the moving destination, they are separated as different primitives on the data.
// Move the primitive / cluster (It is better to use this instead of copy + delete since it is costly)
// Input
// int flag; 1...Reflect in the image data / 0...Do not reflect
// PRIMITIVE* prim; Primitive (copying is not allowed as it uses addresses)
// CLUSTER* pcluster; Cluster (copying is not allowed as it uses addresses)
// int left, top; Destination of movement
// Return Value
// 0 Normal termination
// Negative Error
int medit_move(int flag, PRIMITIVE* prim, int left, int top);
int medit_move(int flag, CLUSTER* pcluster, int left, int top);
Sample Code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Initialize the library by specifying a 20-digit code supplied from the licenser or the path of the license code file
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// In case of license code path, CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background as 0 and foreground as 1
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
// 1... Primitive selection or cluster extraction operation
// 2... Move the specified primitive and reflect it in the original image
int i1 = pjocrprim->medit_move(1, prim, 100, 100);
if(i1 < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
2 Primitive Cutting (Width 0)
Table of Contents
Cut the primitive by specifying clusters and one or more line segments. In the case of cutting with a width of 0, it may not be visible in the image, but it is cut in the data structure. By moving or deleting, you can confirm that it is cut.
// Split cluster (Pixel data does not change. There is no visible breakage)
// (Note that this process is computationally expensive: Reinitialization is faster if there are many targets to split)
// 1...Copy the target primitive as a cluster
// Input
// int linenum; Number of cutting lines
// int* px1; Starting and ending coordinates of cutting lines (linenum each)
// int* py1;
// int* px2;
// int* py2;
// CLUSTER* pcluster; Cluster to be cut
// Return value
// 0 Normal termination
// Negative Error
int medit_separate(int linenum,int* px1,int* py1,int* px2,int* py2,CLUSTER* pcluster);
Sample code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Initialize the library by specifying a 20-digit code provided by the licenser or the path of the license code file.
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// If it is the license code path, use CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background 0 and foreground 1
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
// 1...Cluster extraction operation
// 2...Cut the specified cluster
int x1[1];
int y1[1];
int x2[1];
int y2[1];
x1[0] = 100;
y1[0] = 100;
x2[0] = 200;
y2[0] = 200;
int i1 = pjocrprim->medit_separate(1,x1,y1,x2,y2,pcluster);
if(i1 < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
2 Primitive Severance (Gap Width 1)
Table of Contents
Severs the primitives by specifying a cluster and one or more line segments. With a severance of width 1, the cutting is visually noticeable in the image.
// Divides the cluster (no pixel data change occurs. No visible cutting on display)
// (Note: The processing cost is high. If there are many divisions, reinitialization is faster)
// 1...Copies the target primitive as a cluster
// Input
// int linenum; Number of cutting lines
// int* px1; Coordinates of the starting point and ending point of the cutting line (linenum for each)
// int* py1;
// int* px2;
// int* py2;
// CLUSTER* pcluster; Cluster to be severed
// Return value
// 0 Normal termination
// Negative Error
int medit_sever(int linenum,int* px1,int* py1,int* px2,int* py2,CLUSTER* pcluster);
Sample code
#include "ocrdef.h"
#include "ocrco.h"
#include "cjocrprim.h"
#include "errcode.h"
...
....
// Initializes the library by specifying a 20-digit code provided from the licenser or a path to the license code file
CJocrPrim* pjocrprim = new CJocrPrim("ABCDEFGHJKLMNPQ23456");
// If using a license code path: CJocrPrim* prim = new CJocrPrim("C:\\Program Files\\Foo\\primitive.kcd");
pjocrprim->msetdocument(mdata,0,mwidth,mheight); // Monochrome image with background of 0 and foreground of 1
pjocrprm->msetdpi(400);
pjocrprm->msetinsertmax(10000);
ret = pjocrprim->makeprim();
if(ret < 0) {
Error;
}
// 1...Cluster extraction operation
// 2...Sever the specified cluster
int x1[1];
int y1[1];
int x2[1];
int y2[1];
x1[0] = 100;
y1[0] = 100;
x2[0] = 200;
y2[0] = 200;
int i1 = pjocrprim->medit_sever(1,x1,y1,x2,y2,pcluster);
if(i1 < 0) {
Error;
}
delete pjocrprim;
...
Table of Contents
manual homepage
user's manual