增加对sane单色位图的处理

This commit is contained in:
luoliangyi 2022-05-27 09:40:25 +08:00
parent 26623166b2
commit e2c6fc7c52
2 changed files with 13 additions and 5 deletions

View File

@ -2006,9 +2006,17 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
HGUInt imgType = 0;
if (sane_img->header.format == SANE_FRAME_GRAY)
imgType = HGBASE_IMGTYPE_GRAY;
else if (sane_img->header.format == SANE_FRAME_RGB)
{
if (1 == sane_img->header.depth)
imgType = HGBASE_IMGTYPE_BINARY;
else if (8 == sane_img->header.depth)
imgType = HGBASE_IMGTYPE_GRAY;
}
else if (sane_img->header.format == SANE_FRAME_RGB
&& 24 == sane_img->header.depth)
{
imgType = HGBASE_IMGTYPE_RGB;
}
HGByte *imgData = sane_img->data;
HGImageInfo imgInfo = {(HGUInt)sane_img->header.pixels_per_line, (HGUInt)sane_img->header.lines,

View File

@ -126,9 +126,6 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
else if (HGBASE_IMGTYPE_BGRA == type || HGBASE_IMGTYPE_RGBA == type)
channels = 4;
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
if (NULL == destImage || image == destImage)
{
if (HGBASE_IMGTYPE_BINARY == type)
@ -149,6 +146,9 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
return ret;
}
uint8_t* p = data + roi.top * imgInfo.widthStep + roi.left * channels;
cv::Mat img(roiHeight, roiWidth, CV_8UC(channels), p, imgInfo.widthStep);
CImageApplyAdjustColors imgApply(brightness, contrast, gamma);
imgApply.apply(img, 0);
}