1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #23446 from tantei3:bmp_fix

**Merge with extra**: https://github.com/opencv/opencv_extra/pull/1050

For 32 bits per pixel with 3 or 4 channel destination images, apply scale factor and mask to parse BMP files correctly

closes #23445 

### Pull Request Readiness Checklist
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
tantei3
2023-04-06 17:04:36 +05:30
committed by GitHub
parent 9742c73254
commit 8336a96cb9
3 changed files with 89 additions and 23 deletions
+31
View File
@@ -331,6 +331,37 @@ TEST(Imgcodecs_Bmp, read_32bit_xrgb)
ASSERT_EQ(data[3], 255);
}
TEST(Imgcodecs_Bmp, rgba_scale)
{
const string root = cvtest::TS::ptr()->get_data_path();
const string filenameInput = root + "readwrite/test_rgba_scale.bmp";
Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
ASSERT_FALSE(img.empty());
ASSERT_EQ(CV_8UC4, img.type());
uchar* data = img.ptr();
ASSERT_EQ(data[0], 255);
ASSERT_EQ(data[1], 255);
ASSERT_EQ(data[2], 255);
ASSERT_EQ(data[3], 255);
img = cv::imread(filenameInput, IMREAD_COLOR);
ASSERT_FALSE(img.empty());
ASSERT_EQ(CV_8UC3, img.type());
data = img.ptr();
ASSERT_EQ(data[0], 255);
ASSERT_EQ(data[1], 255);
ASSERT_EQ(data[2], 255);
img = cv::imread(filenameInput, IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
ASSERT_EQ(CV_8UC1, img.type());
data = img.ptr();
ASSERT_EQ(data[0], 255);
}
#ifdef HAVE_IMGCODEC_HDR
TEST(Imgcodecs_Hdr, regression)