QImage垂直翻转
QImage flipped vertically
大家好,我有一个map_server,读取PGM文件,但在QImage上打印出它的翻转图像。下面是我的代码
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" );
高度的"for循环"从"0"到极限(高度),我可以假设它在极限中读取的图片,直到"0"。
由于声誉的关系,我不能提供图片。但我仍然希望我能在这方面得到一些帮助。
谢谢!
JeremyEthanKoh .
在JPG和BMP之间转换时,扫描线以y反转,这是特定于BMP格式的。看来你的QImage是一个RGB的24像素位图,你直接写在它的像素图逐行。只需将Y:
中的扫描线反转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( height-i-1 ), lineImage, width * 3 );
}
}
相关文章:
- QScrollArea:由垂直滚动条引起的水平滚动条
- 垂直方向的 Gtk3+ 旋转按钮 (c/c++)
- 以线程安全的方式调用"QQuickPaintedItem::updateImage(const QImage&image)"(no QThread)
- 按钮悬停在 QT 中垂直布局的选项卡小部件中不起作用
- 将 cv::mat 转换为 QImage
- OnVScroll : 从 CSpinButtonCtrl 或垂直滚动条调用?
- 将 QImage 从 c++ 客户端发送到 python 服务器
- PyQT - 在 QTableWidget 单元格中显示垂直文本
- 如何确定两条直线是否(几乎)垂直/正交
- Read OpenCV Mat 16bit to QImage 8bit Greyscale
- 翻转 ppm 图像C++麻烦
- 指向纹理数据的指针-垂直翻转数据
- stb_image在加载 opengl 纹理的图像时不会垂直翻转
- 如何翻转QImage
- 我应该垂直翻转加载了stb_image的图像的线条以在OpenGL中使用吗
- 2D 阵列垂直翻转
- 垂直翻转图像
- glm::lookAt 垂直相机翻转时 z <= 0
- QImage垂直翻转
- 如何在YUV到RGB转换期间垂直翻转缓冲区