summaryrefslogtreecommitdiffstats
path: root/src/barcode/barcode.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
commit2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch)
tree18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/barcode/barcode.cpp
parent1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff)
downloadtellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz
tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip
TQt4 port tellico
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/barcode/barcode.cpp')
-rw-r--r--src/barcode/barcode.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/barcode/barcode.cpp b/src/barcode/barcode.cpp
index 2427f4e..1c2d1f2 100644
--- a/src/barcode/barcode.cpp
+++ b/src/barcode/barcode.cpp
@@ -15,8 +15,8 @@
// includes code from http://v4l2spec.bytesex.org/spec/a16323.htm
-#include <qimage.h>
-#include <qmutex.h>
+#include <tqimage.h>
+#include <tqmutex.h>
#include "barcode.h"
#include <stdlib.h>
@@ -53,13 +53,13 @@ void barcodeRecognitionThread::run()
Barcode_EAN13 old;
while (!stop) {
- QImage img;
+ TQImage img;
m_barcode_img_mutex.lock();
if (m_barcode_img.isNull())
img = m_barcode_v4l->grab_one2();
else {
img = m_barcode_img;
- m_barcode_img = QImage();
+ m_barcode_img = TQImage();
}
m_barcode_img_mutex.unlock();
@@ -69,7 +69,7 @@ void barcodeRecognitionThread::run()
// //DEBUG
if (!img.isNull()) {
- QImage preview = img.scale( 320, 240, QImage::ScaleMin );
+ TQImage preview = img.scale( 320, 240, TQ_ScaleMin );
emit gotImage( preview );
Barcode_EAN13 barcode = recognize( img );
if (barcode.isValid() && (old != barcode)) {
@@ -94,7 +94,7 @@ void barcodeRecognitionThread::stop()
}
-void barcodeRecognitionThread::recognizeBarcode( QImage img )
+void barcodeRecognitionThread::recognizeBarcode( TQImage img )
{
// attention! This function is called from GUI context
m_barcode_img_mutex.lock();
@@ -102,7 +102,7 @@ void barcodeRecognitionThread::recognizeBarcode( QImage img )
m_barcode_img_mutex.unlock();
}
-Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img )
+Barcode_EAN13 barcodeRecognitionThread::recognize( TQImage img )
{
// PARAMETERS:
int amount_scanlines = 30;
@@ -110,7 +110,7 @@ Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img )
int h = img.height();
// the array which will contain the result:
- QValueVector< QValueVector<int> > numbers( amount_scanlines, QValueVector<int>(13,-1) ); // no init in java source!!!!!!!!!
+ TQValueVector< TQValueVector<int> > numbers( amount_scanlines, TQValueVector<int>(13,-1) ); // no init in java source!!!!!!!!!
// generate and initialize the array that will contain all detected
// digits at a specific code position:
@@ -170,14 +170,14 @@ Barcode_EAN13 barcodeRecognitionThread::recognize( QImage img )
void barcodeRecognitionThread::printArray( int array[10][13][2], int level )
{
for (int i = 0; i < 10; i++) {
- QCString temp;
+ TQCString temp;
temp.setNum( i );
fprintf( stderr, temp + " : " );
for (int j = 0; j < 13; j++) {
if (array[i][j][level] == -1)
fprintf( stderr, "x " );
else {
- QCString temp;
+ TQCString temp;
temp.setNum( array[i][j][level] );
fprintf( stderr, temp + " " );
}
@@ -186,20 +186,20 @@ void barcodeRecognitionThread::printArray( int array[10][13][2], int level )
}
}
-barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( QImage img, int x1, int x2, int y )
+barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( TQImage img, int x1, int x2, int y )
{
- QValueVector<QRgb> raw_path(x2-x1+1);
+ TQValueVector<TQRgb> raw_path(x2-x1+1);
for (int x=x1; x<=x2; x++)
raw_path[x-x1] = img.pixel(x,y);
// convert the given path into a string of black and white pixels:
- QValueVector<int> string = transformPathToBW( raw_path );
+ TQValueVector<int> string = transformPathToBW( raw_path );
// convert the string of black&white pixels into a list, containing
// information about the black and white fields
// first indes = field nr.
// second index: 0 = color of the field
// 1 = field length
- QValueVector< QValueVector<int> > fields = extractFieldInformation( string );
+ TQValueVector< TQValueVector<int> > fields = extractFieldInformation( string );
// try to recognize a EAN13 code:
Barcode_EAN13 barcode = Decoder_EAN13::recognize( fields );
@@ -207,7 +207,7 @@ barcodeRecognition::Barcode_EAN13 barcodeRecognitionThread::recognizeCode( QImag
return barcode;
}
-void barcodeRecognitionThread::addNumberToPossibleNumbers( QValueVector<int> number, int possible_numbers[10][13][2], bool correct_code )
+void barcodeRecognitionThread::addNumberToPossibleNumbers( TQValueVector<int> number, int possible_numbers[10][13][2], bool correct_code )
{
int i;
bool digit_contained;
@@ -278,7 +278,7 @@ void barcodeRecognitionThread::sortDigits( int possible_numbers[10][13][2] )
Barcode_EAN13 barcodeRecognitionThread::extractBarcode( int possible_numbers[10][13][2] )
{
// create and initialize the temporary variables:
- QValueVector<int> temp_code(13);
+ TQValueVector<int> temp_code(13);
for (int i = 0; i < 13; i++)
temp_code[i] = possible_numbers[0][i][0];
@@ -295,13 +295,13 @@ Barcode_EAN13 barcodeRecognitionThread::extractBarcode( int possible_numbers[10]
Barcode_EAN13 barcodeRecognitionThread::detectValidBarcode ( int possible_numbers[10][13][2], int max_amount_of_considered_codes )
{
// create and initialize the temporary variables:
- QValueVector<int> temp_code(13);
+ TQValueVector<int> temp_code(13);
for ( int i = 0; i < 13; i++ )
temp_code[i] = possible_numbers[0][i][0];
int alternative_amount = 0;
- QValueVector<int> counter( 13 ); // no init in java source!!!
+ TQValueVector<int> counter( 13 ); // no init in java source!!!
int counter_nr = 11;
// check if there is at least one complete code present:
@@ -367,12 +367,12 @@ Barcode_EAN13 barcodeRecognitionThread::detectValidBarcode ( int possible_number
bool barcodeRecognitionThread::isValid( int numbers[13] )
{
- QValueVector<int> temp(13);
+ TQValueVector<int> temp(13);
for (int i=0; i<13; i++)
temp[i] = numbers[i];
return isValid( temp );
}
-bool barcodeRecognitionThread::isValid( QValueVector<int> numbers )
+bool barcodeRecognitionThread::isValid( TQValueVector<int> numbers )
{
Q_ASSERT( numbers.count() == 13 );
// calculate the checksum of the barcode:
@@ -393,17 +393,17 @@ bool barcodeRecognitionThread::isValid( QValueVector<int> numbers )
return (numbers[12] == checksum_digit);
}
-QValueVector<int> barcodeRecognitionThread::transformPathToBW( QValueVector<QRgb> line )
+TQValueVector<int> barcodeRecognitionThread::transformPathToBW( TQValueVector<TQRgb> line )
{
int w = line.count();
- QValueVector<int> bw_line(w,0);
+ TQValueVector<int> bw_line(w,0);
bw_line[0] = 255;
// create greyscale values:
- QValueVector<int> grey_line(w,0);
+ TQValueVector<int> grey_line(w,0);
int average_illumination = 0;
for (int x = 0; x < w; x++) {
- grey_line[x] = (qRed(line.at(x)) + qGreen(line.at(x)) + qBlue(line.at(x))) / 3;
+ grey_line[x] = (tqRed(line.at(x)) + tqGreen(line.at(x)) + tqBlue(line.at(x))) / 3;
average_illumination = average_illumination + grey_line[x];
}
average_illumination = average_illumination / w;
@@ -452,7 +452,7 @@ QValueVector<int> barcodeRecognitionThread::transformPathToBW( QValueVector<QRgb
}
}
- QValueVector<int> ret(w,0);
+ TQValueVector<int> ret(w,0);
for (int i=0; i<w; i++)
ret[i] = bw_line[i];
@@ -469,12 +469,12 @@ QValueVector<int> barcodeRecognitionThread::transformPathToBW( QValueVector<QRgb
return ret;
}
-QValueVector< QValueVector<int> > barcodeRecognitionThread::extractFieldInformation( QValueVector<int> string )
+TQValueVector< TQValueVector<int> > barcodeRecognitionThread::extractFieldInformation( TQValueVector<int> string )
{
- QValueVector< QValueVector<int> > temp_fields( string.count(), QValueVector<int>(2,0) );
+ TQValueVector< TQValueVector<int> > temp_fields( string.count(), TQValueVector<int>(2,0) );
if (string.count() == 0)
- return QValueVector< QValueVector<int> >();
+ return TQValueVector< TQValueVector<int> >();
int field_counter = 0;
int last_value = string.at(0);
@@ -513,13 +513,13 @@ Barcode_EAN13::Barcode_EAN13()
}
//ok
-Barcode_EAN13::Barcode_EAN13( QValueVector<int> code )
+Barcode_EAN13::Barcode_EAN13( TQValueVector<int> code )
{
setCode( code );
}
//ok
-void Barcode_EAN13::setCode( QValueVector<int> code )
+void Barcode_EAN13::setCode( TQValueVector<int> code )
{
if (code.count() != 13) {
m_numbers.clear();
@@ -553,18 +553,18 @@ bool Barcode_EAN13::isValid() const
}
//ok
-QValueVector<int> Barcode_EAN13::getNumbers() const
+TQValueVector<int> Barcode_EAN13::getNumbers() const
{
return m_numbers;
}
//ok
-QString Barcode_EAN13::toString() const
+TQString Barcode_EAN13::toString() const
{
- QString s;
+ TQString s;
for (int i = 0; i < 13; i++)
if ((m_numbers[i] >= 0) && (m_numbers[i] <= 9))
- s += QString::number(m_numbers[i]);
+ s += TQString::number(m_numbers[i]);
else
s += '?';
return s;
@@ -583,17 +583,17 @@ bool Barcode_EAN13::operator!= ( const Barcode_EAN13 &code )
}
//ok
-Barcode_EAN13 Decoder_EAN13::recognize( QValueVector< QValueVector<int> > fields )
+Barcode_EAN13 Decoder_EAN13::recognize( TQValueVector< TQValueVector<int> > fields )
{
// try to extract the encoded information from the field series:
- QValueVector<int> numbers = decode( fields, 0, fields.count() );
+ TQValueVector<int> numbers = decode( fields, 0, fields.count() );
Barcode_EAN13 barcode( numbers );
// return the results:
return barcode;
}
-QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > fields, int start_i, int end_i )
+TQValueVector<int> Decoder_EAN13::decode( TQValueVector< TQValueVector<int> > fields, int start_i, int end_i )
{
// determine the length of the path in pixels
int length = 0;
@@ -617,11 +617,11 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
// consistency checks:
if (fields.count() <= 0)
- return QValueVector<int>();
+ return TQValueVector<int>();
if (start_i > end_i - 3)
- return QValueVector<int>();
+ return TQValueVector<int>();
if (end_i - start_i < 30)
- return QValueVector<int>(); // (just a rough value)
+ return TQValueVector<int>(); // (just a rough value)
// relevant indexes:
int start_sentinel_i;
@@ -634,7 +634,7 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
float unit_length;
// results:
- QValueVector<int> numbers( 13, -1 ); // the java source does no initialization
+ TQValueVector<int> numbers( 13, -1 ); // the java source does no initialization
// determine the relevant positions:
@@ -657,7 +657,7 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
#endif
if (start_sentinel_i < 0)
- return QValueVector<int>();
+ return TQValueVector<int>();
// calculate the other positions:
left_numbers_i = start_sentinel_i + 3;
@@ -666,7 +666,7 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
end_sentinel_i = right_numbers_i + 6 * 4;
if (end_sentinel_i + 3 > end_i)
- return QValueVector<int>();
+ return TQValueVector<int>();
// calculate the average (pixel) length of a bar that is one unit wide:
// (a complete barcode consists out of 95 length units)
@@ -680,10 +680,10 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
fprintf( stderr, "unit_width: %f\n", unit_length );
#endif
- QValueVector< QValueVector<int> > current_number_field( 4, QValueVector<int>(2,0) );
+ TQValueVector< TQValueVector<int> > current_number_field( 4, TQValueVector<int>(2,0) );
if (left_numbers_i + 1 > end_i)
- return QValueVector<int>();
+ return TQValueVector<int>();
// test the side from which we are reading the barcode:
@@ -773,7 +773,7 @@ QValueVector<int> Decoder_EAN13::decode( QValueVector< QValueVector<int> > field
return numbers;
}
-MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector<int> > fields, int code_table_to_use)
+MatchMakerResult Decoder_EAN13::recognizeNumber( TQValueVector< TQValueVector<int> > fields, int code_table_to_use)
{
// convert the pixel lenghts of the four black&white fields into
// normed values that have together a length of 70;
@@ -799,7 +799,7 @@ MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector<int>
int odd_min_difference_index = 0;
if ((code_table_to_use == BOTH_TABLES)||(code_table_to_use == EVEN_TABLE)) {
- QValueVector<int> even_differences(10,0);
+ TQValueVector<int> even_differences(10,0);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 4; j++) {
@@ -818,7 +818,7 @@ MatchMakerResult Decoder_EAN13::recognizeNumber( QValueVector< QValueVector<int>
}
if ((code_table_to_use == BOTH_TABLES) || (code_table_to_use == ODD_TABLE)) {
- QValueVector<int> odd_differences(10,0);
+ TQValueVector<int> odd_differences(10,0);
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 4; j++) {