diff --git a/app/scanner/mainwindow.cpp b/app/scanner/mainwindow.cpp index 7bfcdc7d..6b93f779 100644 --- a/app/scanner/mainwindow.cpp +++ b/app/scanner/mainwindow.cpp @@ -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, diff --git a/modules/imgproc/HGImgProc.cpp b/modules/imgproc/HGImgProc.cpp index 7b7a4b7c..56ebc1c0 100644 --- a/modules/imgproc/HGImgProc.cpp +++ b/modules/imgproc/HGImgProc.cpp @@ -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); }