Misc

_SelectColor, Heart_Analyze_New, Int_ConvertData, Int_GetAppSystemColor, Int_RescaleHist, Int_SetFocus, IsClipboardOK, Region_Set_Rotation, Sql_Connect, Sql_Disconnect, Sql_DisconnectAll, Sql_Query

Heart_Analyze_New

Description 

 Heart_Analyze_New(
   int  HA_Width,
   int  HA_Height,
   int  HA_Fps,
   int  HA_UseQualityMode,
   int  HA_OnScreen
);

This function can capture an image line by line. The result indicates the progress of an action that is being captured.

Parameters

int HA_Width

The resulting width of the captured image.

int HA_Height

The resulting height of the captured image.

int HA_Fps

The number of lines to be captured in one second.

int HA_UseQualityMode

0

The Live-Fast camera mode is used.

1

The Quality-Capture camera mode is used.

int HA_OnScreen

The progress of the acquisition:

0

Will not be displayed.

1

Will be displayed in a separate document window.

Int_ConvertData

Description 

 Int_ConvertData(
   char *IntDestC,
   char *Int_Sour,
   dword  num,
   int  type
);

This function converts data of different types to speed up the macros.

Parameters

char *IntDestC

Destination data pointer.

char *Int_Sour

Source File.

dword num

Number of values to convert. This number can not be greater than the dimensions of the data arrays.

int type

Type of data conversion.

BYTE_TO_DOUBLE

Converts type byte to type double

DWORD_TO_DOUBLE

Converts type dword to type double

WORD_TO_DOUBLE

Converts type word to type double

DOUBLE_TO_DWORD

Converts type double to type dword

Return Values

This function returns TRUE if the data were converted, else FALSE. If the data dimensions are different than is specified, the function returns FALSE too.

//Int_ConvertData example - this example measures time of data conversion.
dword         dwrd[100000],t1,t2,ta,tb,tc,td,cnst;
double        dbl[100000];
word          wrd[100000];
byte          byt[100000];
char          buf[1000],st1[256],st2[256],st3[256],st4[256],caption[256];
cnst=100000;
SetCommandText("Working...");
strcpy(caption, "    LIM API Example - Int_ConvertData\tConverting byte -to-> double.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);  
t1 = Get_Time();
Int_ConvertData(dbl,byt,cnst,BYTE_TO_DOUBLE);
t2 = Get_Time();
ta = t2 - t1;
strcpy(caption, "    LIM API Example - Int_ConvertData\tConverting dword -to-> double.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);  
t1 = Get_Time();
Int_ConvertData(dbl,dwrd,cnst,DWORD_TO_DOUBLE);
t2 = Get_Time();
tb = t2 - t1;
strcpy(caption, "    LIM API Example - Int_ConvertData\tConverting word -to-> double.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);  
t1 = Get_Time();
Int_ConvertData(dbl,wrd,cnst,WORD_TO_DOUBLE);
t2 = Get_Time();
tc = t2 - t1;
strcpy(caption, "    LIM API Example - Int_ConvertData\tConverting double -to-> dword.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);  
t1 = Get_Time();
Int_ConvertData(dwrd,dbl,cnst,DOUBLE_TO_DWORD);
t2 = Get_Time();
td = t2 - t1;
strcpy(caption, "    LIM API Example - Int_ConvertData\tEnd of conversion.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);  
sprintf(st1,"   Byte to double(%i items): %i [ms]\n","cnst,ta");
sprintf(st2,"   Dword to double(%i items): %i [ms]\n","cnst,tb");
sprintf(st3,"   Word to double(%i items): %i [ms]\n","cnst,tc");
sprintf(st4,"   Double to dword(%i items): %i [ms]\n","cnst,td");
sprintf(buf,"%s%s%s%s","st1,st2,st3,st4");

See Also 
Int_CloseTextWindow

Int_GetAppSystemColor

Description 

 Int_GetAppSystemColor(
   int  Int_Index
);

This function returns a color based on its (Windows API) index. System colors are overwritten inside the application for the purposes of switching between dark and light schemes.

Parameters

int Int_Index

Index parameter.

Int_RescaleHist

Description 

 Int_RescaleHist(
   double *Int_InX,
   double *Int_InY,
   int  Int_DimIn,
   double *Int_OutX,
   double *Int_OutY,
   int  Int_DimOut,
   double  Int_Smooth
);

This function rescales the histogram data using the spline interpolation.

Parameters

double *Int_InX

Source x - values of the histogram. This array must be filled on input.

double *Int_InY

Source y - values of the histogram. This array must be filled on input.

int Int_DimIn

Source dimension. Must be the same as the dimensions of the source x and y arrays.

double *Int_OutX

Output x - values of the rescaled histogram. This array must be filled on input.

double *Int_OutY

Output y - values of the rescaled histogram. This array must be filled on input.

int Int_DimOut

Output dimension. Must be the same as the dimensions of the output x and y arrays.

double Int_Smooth

Smoothing parameter. Determines how smooth the output data will be. The greater value is the smoother the data will be. The value cannot be less then zero.

Return Values

The return value is nonzero if the function is successful. Otherwise, it is zero.

//Int_RescaleHist example - horizontal spline by 5 points.
int              xs,ys,width,height;
int              xi[5],yi[5];  
int              i,j,dimOut;
double           x[5],y[5];
double           outx[50],outy[50],min,dist;
dword            keys[1],key; 
char             caption[256]; 
dimOut = 20;
keys[0] = VK_LBUTTON;
Get_Size(SIZE_PICWND,&xs,&ys,&width,&height);
SetCommandText("Working...");
strcpy(caption,"API Example - Int_RescaleHist function.");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
Wait(2);
strcpy(caption,"   application API Example - Int_RescaleHist function.\tDefine 5 points on the screen for horizontal interpolation.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
for(i=0;i<5;i=i+1)
   {
   key = 0;
   while(key != keys[0])
   key = Int_GetEvents(&keys,1);
   Int_GetMousePos(xi,yi);
   Int_DrawMarker(xi[0],yi[0],MARKER_TO_SCREEN,1,MARKER_SMALL,RGB_RED,1);
   x[i] = xi[0];
   y[i] = height - yi[0];
   }
for(i=0;i<4;i=i+1)
   {
   for(j=i;j<5;j=j+1)
   {
   if(x[i]>x[j])
   {
   min = x[j];
   x[j] = x[i];
   x[i] = min;
   min = y[j];
   y[j] = y[i];
   y[i] = min;
   }
   if(x[i]==x[j])
   x[j] = x[j] + 1;
   }
   }
dist = x[4] - x[0];
dist = dist / (dimOut-1);
outx[0] = x[0];
for(i=1;i<dimOut;i=i+1)
   {
   outx[i] = outx[i-1] + dist;
   if(outx[i]>x[4])
   outx[i]=x[4];
   }
strcpy(caption,"   application API Example - Int_RescaleHist function.\tComputing interpolation.   ");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
if(!Int_RescaleHist(x,y,5,outx,outy,dimOut,1))
   WaitText(0,"Bad parametres!");
for(i=0;i<dimOut;i=i+1)
   {
   xi[0] = outx[i];
   yi[0] = height - outy[i];
   Int_DrawMarker(xi[0],yi[0],MARKER_TO_SCREEN,1,MARKER_SMALL,RGB_BLUE,1);
   }
Int_CloseTextWindow();
Int_SetFocus

Description 

 Int_SetFocus(
   int  wnd
);

This function sets the input focus to a given window. All subsequent keyboard messages are directed to this window. The window, if any, that previously had the input focus loses it.

Parameters

int wnd

Window to receive focus.

WINDOW_MAIN

Sets the focus to the main window.

WND_1

Sets the focus to the window, which was created by the Int_CreateWindow function with the same constant.

WND_2

Sets the focus to the window, which was created by the Int_CreateWindow function with the same constant.

WND_3

Sets the focus to the window, which was created by the Int_CreateWindow function with the same constant.

WND_4

Sets the focus to the window, which was created by the Int_CreateWindow function with the same constant.

WINDOW_LISTBOX

Sets the focus to the window, which was created by the Int_ListCreateWindow function.

WINDOW_TEXT

Sets the focus to the window, which was created by the Int_CreateTextWindow function.

WINDOW_GRAPH

Sets the focus to the window, which was created by the Int_GSCreateWindow function.

WINDOW_QUERY

Sets the focus to the window, which was created by the Int_Query function.

10 - 30

Sets the focus to the other windows.

Return Values

This function returns constant of the window which had the focus. If the function was not successful the value -1 is returned.

//Int_SetFocus example - swapping of overlapped windows.
int          xs,ys,width,height;
int          i,j,pw,ph;
char         b1[1000],b2[1000],b3[1000],b4[1000],caption[256];
dword        key,keys[10];
keys[0] = VK_END;
keys[1] = VK_F1;
keys[2] = VK_F2;
keys[3] = VK_F3;
keys[4] = VK_F4;
Enable_Interrupt_InScript(1);
SetCommandText("Working...");
strcpy(caption,"API Example - Int_SetFocus function.");
Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
Wait(2);
strcpy(b1,"You are currently running\nAPI Example");
strcpy(b2,"Example values:\nResults of the measurement No.1 :\n200.51\t400.03\t126.09");
strcpy(b3,"Example values:\nA : 10\nB : 15\nC : 1001\nD : 1200");
strcpy(b4,"Example text:\n1.)Type of segmentation\n2.)Type of filtering\n3.)Type of measurements");
Get_Size(SIZE_MAINWND,&xs,&ys,&width,&height);
pw=width/3;
ph=height/4;
Int_CreateWindow(WND_1,"First window.",1,0,0,pw,ph,b1,0,1,0.00000,0,0,1,"Arial,BI,14");
Int_CreateWindow(WND_2,"Second window.",1,0,0,pw,ph,b2,0,1,0.00000,0,0,1,"Arial,B,10");
Int_CreateWindow(WND_3,"Third window.",1,0,0,pw,ph,b3,0,1,0.00000,0,0,1,"Arial,B,10");
Int_CreateWindow(WND_4,"Fourth window.",1,0,0,pw,ph,b4,0,1,0.00000,0,0,1,"Arial,B,10");
Int_PostMessage(VK_F1,0);   
while(key!=keys[0])
   {
   key=Int_GetEvents(keys,5);
   if(key==keys[1])
   {
   strcpy(caption,"   First window\tTo change window press F2,F3,F4. To exit press END.   ");
   Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
   Int_SetFocus(WND_1);
   Int_SetFocus(WINDOW_MAIN);
   }
   if(key==keys[2])
   {
   strcpy(caption,"   Second window\tTo change window press F1,F3,F4. To exit press END.   ");
   Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
   Int_SetFocus(WND_2);
   Int_SetFocus(WINDOW_MAIN);
   }
   if(key==keys[3])
   {
   strcpy(caption,"   Third window\tTo change window press F1,F2,F4. To exit press END.   ");
   Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
   Int_SetFocus(WND_3);
   Int_SetFocus(WINDOW_MAIN);
   }
   if(key==keys[4])
   {
   strcpy(caption,"   Fourth window\tTo change window press F1,F2,F3. To exit press END.   ");
   Int_CreateTextWindow(caption,0,RGB(0,0,128),RGB_WHITE,100);
   Int_SetFocus(WND_4);
   Int_SetFocus(WINDOW_MAIN);
   }
   }
for(i=1;i<5;i=i+1)
   {
   Int_SetFocus(i);
   Int_PostMessage(VK_ALT|VK_F4,0);
   }
Int_CloseTextWindow();

Note

Constants 10 - 30 are intended for later system development.

IsClipboardOK

Description 

 IsClipboardOK();

This function checks, if the clipboard contains bitmap data.

Return Values

LOWORD of return value is width of bitmap and HIWORD of return value is height of bitmap. If no bitmap data is available in the clipboard, return value is zero.

Region_Set_Rotation

Description 

 Region_Set_Rotation(
   int  Mode
);

This function enables/disables rotation during interactive region pasting.

Parameters

int Mode

Mode

0

Disables rotation.

1

Enables rotation.

See Also 
Region_Cut, _Region_Copy, Region_Paste, Region_Copy, Region_Info, _Region_Settings, _Region_Cut

Sql_Connect

Description 

dword Sql_Connect(
   char *ConnectionString,
   char *Sql_User,
   char *Password
);

This function connects to SQL database.

Parameters

char *ConnectionString

Connection string. See MS ADO Connection String property: http://msdn2.microsoft.com/cs-cz/library/ms675810(en-us,VS.85).aspx

char *Sql_User

User name.

char *Password

User password.

Return Values

dword

This function returns connection handle if succeeds otherwise returns 0.

int connection, recNum, i, recLen, delimiter;
char columns[1000];
char values[2000];
char buf[2000];
char bufW[2000];
char* record;
recLen = 100;
delimiter = 124; // '|'
connection = Sql_Connect("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\database.mdb;", "", "");
recNum = Sql_Query(connection, "select * from table1", columns, 1000, values, 10, recLen, delimiter);
sprintf(bufW, "%s\n", "columns");
WideCharToMultiByte(buf, bufW);
WriteFile("c:\data.txt", buf, strlen(bufW));
for (i = 0; i < recNum; i = i + 1)
   {
   record = values+(i*recLen);
   sprintf(bufW, "%s\n", "record");
   WideCharToMultiByte(buf, bufW);
   WriteFile("c:\~tmp.txt", buf, strlen(bufW));
   AppendFile("c:\data.txt", "c:\~tmp.txt");
   }
DeleteFile("c:\~tmp.txt");
Sql_Disconnect(connection);

See Also 
Sql_Query, Sql_Disconnect, Sql_DisconnectAll

Sql_Disconnect

Description 

 Sql_Disconnect(
   dword  ConnectionHandle
);

This function disconnects the database connection specified by the ConnectionHandle.

Parameters

dword ConnectionHandle

Handle specifying the database connection.

See Also 
Sql_Connect, Sql_Query, Sql_DisconnectAll

Sql_DisconnectAll

Description 

 Sql_DisconnectAll();

This function closes all open database connections.

See Also 
Sql_Connect, Sql_Query, Sql_Disconnect

Sql_Query

Description 

int Sql_Query(
   dword  ConnectionHandle,
   char *Query,
   char *ColumnNames,
   int  ColumnNamesSizes,
   char *Values,
   int  RecordCount,
   int  RecordSize,
   int  Separator
);

This function sends a query to a database.

Parameters

dword ConnectionHandle

Handle specifying the database connection.

char *Query

Query to be executed.

char *ColumnNames

Buffer designed for table columns names separated by Separator. It is an output parameter.

int ColumnNamesSizes

Size of buffer ColumnNames.

char *Values

Buffer designed for record values. It is output parameter.

int RecordCount

Maximal count of returned record.

int RecordSize

Size of the record.

int Separator

Field separator. Separates names in ColumnNames and fields in records in Values. Records are separated with two Separators.

Return Values

int

If function succeeds, it returns the number of returned records (greater or equal to zero). If function fails, the return value is -1.

Note

See example in Sql_Connect

See Also 
Sql_Connect, Sql_Disconnect, Sql_DisconnectAll

_SelectColor

Description 

int _SelectColor();

This function opens the color selection dialog box. The selected color is returned as a 32-bit value.

Return Values

int

Selected color.