在QT中处理图像像素对齐问题
#Basler相机采集的图片,像素不对齐的图片要转为对齐时需要进行像素对齐操作,示例代码如下:
bool HikVision::performPr(QImage &image, PrConfig *prConfig, PRResultImageInfo **resultImageInfo, PRResultStruct &prResult)
{
SCTimer sct(QString("performPr: %1").arg(prConfig->prName()), hikCate());
HikPrConfig *hikPrConfig = qobject_cast<HikPrConfig *>(prConfig);
SC_ASSERT(hikPrConfig != nullptr);
SC_ASSERT(image.format() == QImage::Format_Indexed8);
char *rawImgBuffer = nullptr;
bool useRawImgBuffer = (image.width() != image.bytesPerLine());
if (useRawImgBuffer)
{
rawImgBuffer = new char[image.width() * image.height()];
SC_ASSERT(rawImgBuffer != nullptr);
for (int y = 0; y < image.height(); y++)
{
memcpy(rawImgBuffer + y * image.width(), image.scanLine(y), image.width());
}
}