Hello guys, I've a map_server that reads in a PGM file yet prints out a flipped image of it on a QImage. Here is my code.
int width = msg->info.width;
int height = msg->info.height;
const std::vector<int8_t>& data (msg->data);
unsigned char *p, *q;
if( mapImage == NULL ) {
lineImage = new unsigned char[ width * 3 ];
mapImage = new QImage( width, height, QImage::Format_RGB888 );
}
if( mapImage != NULL ) {
for( int i = 0; i < height; i++ ) {
q = lineImage;
p = ( unsigned char * )&data[ i * width ];
for( int j = 0; j < width; j++ ) {
*q++ = *p;
*q++ = *p;
*q++ = *p;
p++;
}
memcpy( mapImage->scanLine( i ), lineImage, width * 3 );
}
}
printf( "Map received!\n" );
The "for loop" for height takes in from "0" till the limit(height) and I can assume that the picture it reads in the limit, till "0".
I can't provide Images due to the reputation. But I still hope I could garner some help in this...
Thanks!
JeremyEthanKoh.