ganapathi
15th October 2015, 07:22
Hi
I am sending an image in bl via network as shown below:
******sender.cpp file**********
Sender::Sender(int no)
{
socket = new QUdpSocket( this );
a = 0;
img_block = 0;
block_size = 20;
num = no;
if(num == 1)
image = new QImage("C:/Users/Public/Pictures/Sample Pictures/Desert.jpg" );
if( image->isNull() )
qDebug() << "Failed to open test.jpg" ;
QTimer *timer = new QTimer( this );
timer->isSingleShot();
QTimer::singleShot(1000, this, SLOT(broadcastLine()) );
connect( this, SIGNAL(done()), this, SLOT(broadcastLine()) );
}
void Sender::broadcastLine()
{
QByteArray buffer( block_size+3*image->width(), 0 );
QDataStream stream( &buffer, QIODevice::WriteOnly );
stream.setVersion( QDataStream::Qt_5_5 );
stream << (quint16)image->width() << (quint16)image->height();
stream << img_block;
for( int x=0; x<image->width(); ++x )
{
for(int y=block_size*a; y <block_size+(block_size*a);y++)
{
if( y < image->height())
{
QRgb rgb = image->pixel( x, y );
stream << (quint8)qRed( rgb ) << (quint8)qGreen( rgb ) << (quint8)qBlue( rgb );
}
else
{
img_block = y = a = 0;
img_block = -block_size;
}
}
}
if(num==1)
socket->writeDatagram( buffer, QHostAddress::Broadcast,9988 );
img_block = img_block + block_size;
a++;
emit done();
}
The above program works for block_size< 20 but not for 32 which I am interested. I dont have even the slightest idea of whats happening and even how to debug this?
Regards
I am sending an image in bl via network as shown below:
******sender.cpp file**********
Sender::Sender(int no)
{
socket = new QUdpSocket( this );
a = 0;
img_block = 0;
block_size = 20;
num = no;
if(num == 1)
image = new QImage("C:/Users/Public/Pictures/Sample Pictures/Desert.jpg" );
if( image->isNull() )
qDebug() << "Failed to open test.jpg" ;
QTimer *timer = new QTimer( this );
timer->isSingleShot();
QTimer::singleShot(1000, this, SLOT(broadcastLine()) );
connect( this, SIGNAL(done()), this, SLOT(broadcastLine()) );
}
void Sender::broadcastLine()
{
QByteArray buffer( block_size+3*image->width(), 0 );
QDataStream stream( &buffer, QIODevice::WriteOnly );
stream.setVersion( QDataStream::Qt_5_5 );
stream << (quint16)image->width() << (quint16)image->height();
stream << img_block;
for( int x=0; x<image->width(); ++x )
{
for(int y=block_size*a; y <block_size+(block_size*a);y++)
{
if( y < image->height())
{
QRgb rgb = image->pixel( x, y );
stream << (quint8)qRed( rgb ) << (quint8)qGreen( rgb ) << (quint8)qBlue( rgb );
}
else
{
img_block = y = a = 0;
img_block = -block_size;
}
}
}
if(num==1)
socket->writeDatagram( buffer, QHostAddress::Broadcast,9988 );
img_block = img_block + block_size;
a++;
emit done();
}
The above program works for block_size< 20 but not for 32 which I am interested. I dont have even the slightest idea of whats happening and even how to debug this?
Regards