diff --git a/OAT.xml b/OAT.xml
index d67e400bc372ac849900ce07f0c81f76db998731..8931cb6663beaf00250f1e94c4ec2d99da3815ef 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -68,6 +68,9 @@ Note:If the text contains special characters, please escape them according to th
+
+
+
diff --git a/frameworks/innerkitsimpl/test/BUILD.gn b/frameworks/innerkitsimpl/test/BUILD.gn
index 2417e83dcde8db045f552c3159161e8668bbdaa6..8b1c23759160d642f12ab21a32cdf04d91f81611 100644
--- a/frameworks/innerkitsimpl/test/BUILD.gn
+++ b/frameworks/innerkitsimpl/test/BUILD.gn
@@ -158,7 +158,8 @@ ohos_unittest("imagesourcetest") {
if (DUAL_ADAPTER) {
sources += [
"$image_subsystem/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_bmp_test.cpp",
- # "$image_subsystem/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp",
+ "$image_subsystem/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp",
+
# "$image_subsystem/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_wbmp_test.cpp",
]
}
diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp
index f6c1f075d5c1a13a80bb402c903193bc557c2e26..65d7f62ba2cac540930447d17aca9b91618ec4b4 100644
--- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp
+++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_raw_test.cpp
@@ -30,6 +30,7 @@ using namespace OHOS::Media;
namespace OHOS {
namespace Multimedia {
static const std::string IMAGE_INPUT_DNG_PATH = "/data/local/tmp/image/test.dng";
+static const std::string IMAGE_INPUT_RAW_PATH = "/data/local/tmp/image/raw1.dng";
static const std::string IMAGE_OUTPUT_DNG_FILE_PATH = "/data/test/test_raw_file.jpg";
class ImageSourceRawTest : public testing::Test {
@@ -64,7 +65,7 @@ HWTEST_F(ImageSourceRawTest, RawImageDecode001, TestSize.Level3)
ASSERT_EQ(errorCode, SUCCESS);
ASSERT_NE(pixelMap, nullptr);
ASSERT_NE(pixelMap.get(), nullptr);
- ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_OPAQUE);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
/**
* @tc.steps: step3. compress the pixel map to jpeg file.
* @tc.expected: step3. pack pixel map success and compare the jpeg compress file size.
@@ -100,7 +101,7 @@ HWTEST_F(ImageSourceRawTest, RawImageDecode002, TestSize.Level3)
ASSERT_EQ(errorCode, SUCCESS);
ASSERT_NE(pixelMap, nullptr);
ASSERT_NE(pixelMap.get(), nullptr);
- ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_OPAQUE);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
/**
* @tc.steps: step3. compress the pixel map to jpeg file.
* @tc.expected: step3. pack pixel map success and compare the jpeg compress file size.
@@ -135,7 +136,7 @@ HWTEST_F(ImageSourceRawTest, RawImageDecode003, TestSize.Level3)
std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
ASSERT_EQ(errorCode, SUCCESS);
ASSERT_NE(pixelMap.get(), nullptr);
- ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_OPAQUE);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
}
/**
@@ -165,7 +166,7 @@ HWTEST_F(ImageSourceRawTest, RawImageDecode004, TestSize.Level3)
ASSERT_EQ(errorCode, SUCCESS);
ASSERT_NE(pixelMap, nullptr);
ASSERT_NE(pixelMap.get(), nullptr);
- ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_OPAQUE);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
/**
* @tc.steps: step3. compress the pixel map to jpeg file.
* @tc.expected: step3. pack pixel map success and compare the jpeg compress file size.
@@ -386,5 +387,125 @@ HWTEST_F(ImageSourceRawTest, RawImageDecode010, TestSize.Level3)
ASSERT_NE(errorCode, SUCCESS);
ASSERT_EQ(pixelMap.get(), nullptr);
}
+
+/**
+ * @tc.name: RawImageDecode011
+ * @tc.desc: Decode raw image from file source stream(BGRA_8888)
+ * @tc.type: FUNC
+ */
+HWTEST_F(ImageSourceRawTest, RawImageDecode011, TestSize.Level3)
+{
+ /**
+ * @tc.steps: step1. create image source by correct file path and format hit.
+ * @tc.expected: step1. create image source success.
+ */
+ uint32_t errorCode = 0;
+ SourceOptions opts;
+ opts.formatHint = "image/raw";
+ std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_RAW_PATH, opts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(imageSource.get(), nullptr);
+ /**
+ * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888.
+ * @tc.expected: step2. decode image source to pixel map success.
+ */
+ DecodeOptions decodeOpts;
+ decodeOpts.desiredPixelFormat = PixelFormat::BGRA_8888;
+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(pixelMap, nullptr);
+ ASSERT_NE(pixelMap.get(), nullptr);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
+}
+
+/**
+ * @tc.name: RawImageDecode012
+ * @tc.desc: Decode raw image from file source stream(RGB_565)
+ * @tc.type: FUNC
+ */
+HWTEST_F(ImageSourceRawTest, RawImageDecode012, TestSize.Level3)
+{
+ /**
+ * @tc.steps: step1. create image source by correct file path and format hit.
+ * @tc.expected: step1. create image source success.
+ */
+ uint32_t errorCode = 0;
+ SourceOptions opts;
+ opts.formatHint = "image/raw";
+ std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_RAW_PATH, opts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(imageSource.get(), nullptr);
+ /**
+ * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888.
+ * @tc.expected: step2. decode image source to pixel map success.
+ */
+ DecodeOptions decodeOpts;
+ decodeOpts.desiredPixelFormat = PixelFormat::RGB_565;
+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(pixelMap, nullptr);
+ ASSERT_NE(pixelMap.get(), nullptr);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
+}
+
+/**
+ * @tc.name: RawImageDecode013
+ * @tc.desc: Decode raw image from file source stream(RGBA_8888)
+ * @tc.type: FUNC
+ */
+HWTEST_F(ImageSourceRawTest, RawImageDecode013, TestSize.Level3)
+{
+ /**
+ * @tc.steps: step1. create image source by correct file path and format hit.
+ * @tc.expected: step1. create image source success.
+ */
+ uint32_t errorCode = 0;
+ SourceOptions opts;
+ opts.formatHint = "image/raw";
+ std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_RAW_PATH, opts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(imageSource.get(), nullptr);
+ /**
+ * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888.
+ * @tc.expected: step2. decode image source to pixel map success.
+ */
+ DecodeOptions decodeOpts;
+ decodeOpts.desiredPixelFormat = PixelFormat::RGBA_8888;
+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(pixelMap, nullptr);
+ ASSERT_NE(pixelMap.get(), nullptr);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
+}
+
+/**
+ * @tc.name: RawImageDecode014
+ * @tc.desc: Decode raw image from file source stream(RGBA_F16)
+ * @tc.type: FUNC
+ */
+HWTEST_F(ImageSourceRawTest, RawImageDecode014, TestSize.Level3)
+{
+ /**
+ * @tc.steps: step1. create image source by correct file path and format hit.
+ * @tc.expected: step1. create image source success.
+ */
+ uint32_t errorCode = 0;
+ SourceOptions opts;
+ opts.formatHint = "image/raw";
+ std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_RAW_PATH, opts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(imageSource.get(), nullptr);
+ /**
+ * @tc.steps: step2. decode image source to pixel map using pixel format BGRA_8888.
+ * @tc.expected: step2. decode image source to pixel map success.
+ */
+ DecodeOptions decodeOpts;
+ decodeOpts.desiredPixelFormat = PixelFormat::RGBA_F16;
+ std::unique_ptr pixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
+ ASSERT_EQ(errorCode, SUCCESS);
+ ASSERT_NE(pixelMap, nullptr);
+ ASSERT_NE(pixelMap.get(), nullptr);
+ ASSERT_EQ(pixelMap->GetAlphaType(), AlphaType::IMAGE_ALPHA_TYPE_PREMUL);
+}
} // namespace Multimedia
} // namespace OHOS
diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp
index b26901a95229961d7fc5f4e8dc58863aa3f43140..832ad73e8c184ac807808222b41aa9e824f80bd9 100644
--- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp
+++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp
@@ -135,7 +135,7 @@ static const map FORMAT_NAME = {
{ SkEncodedImageFormat::kPKM, "" },
{ SkEncodedImageFormat::kKTX, "" },
{ SkEncodedImageFormat::kASTC, "" },
- { SkEncodedImageFormat::kDNG, "" },
+ { SkEncodedImageFormat::kDNG, "image/raw" },
{ SkEncodedImageFormat::kHEIF, "image/heif" },
};
diff --git a/test/resource/image/images/raw1.dng b/test/resource/image/images/raw1.dng
new file mode 100644
index 0000000000000000000000000000000000000000..3526ebd0480c71ce3597e35fadd3577a27aefbba
--- /dev/null
+++ b/test/resource/image/images/raw1.dng
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:b31308dad0084e91b1a75fa748bf12740d1f7ee76b5fa43dc7750129192053d5
+size 79893208
diff --git a/test/resource/image/ohos_test.xml b/test/resource/image/ohos_test.xml
index 60e0760430451665fe4837fa4158215eceb10cc0..412e6b78991cc51429dcfaf6ed494da9bbc6e495 100644
--- a/test/resource/image/ohos_test.xml
+++ b/test/resource/image/ohos_test.xml
@@ -35,6 +35,7 @@
+