diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 19a62c35d237337513b6b2d1a363a4981b1e1a71..2c897a476596e23aeb733a34f4d0f4186c5f63b9 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -5317,10 +5317,20 @@ std::string ImageSource::GetPixelMapName(PixelMap* pixelMap) IMAGE_LOGE("%{public}s error, pixelMap is null", __func__); return "undefined_"; } - std::string pixelMapStr = "w" + std::to_string(pixelMap->GetWidth()) + - "_h" + std::to_string(pixelMap->GetHeight()) + - "_streamSize" + std::to_string(sourceStreamPtr_->GetStreamSize()) + - "_mimeType" + sourceInfo_.encodedFormat; + std::string pixelMapStr = std::to_string(pixelMap->GetWidth()) + + "_x" + std::to_string(pixelMap->GetHeight()) + + "-streamsize-" + std::to_string(sourceStreamPtr_->GetStreamSize()) + + "-mimeType-"; + std::string prefix = "image/"; + size_t minFormatLength = 9; + size_t maxFormatLength = 20; + if ((!sourceInfo_.encodedFormat.empty()) && sourceInfo_.encodedFormat.size() >= minFormatLength && + sourceInfo_.encodedFormat.size() <= maxFormatLength && + sourceInfo_.encodedFormat.compare(0, prefix.size(), prefix) == 0) { + pixelMapStr += sourceInfo_.encodedFormat.substr(prefix.size()); + } else { + pixelMapStr += "undefined"; + } IMAGE_LOGD("pixelMapStr is %{public}s", pixelMapStr.c_str()); return pixelMapStr; } diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index 579fb46379c1191d602ebf6f336cae7c7b9e40d7..7dbdb8c908bc3399b8572f156516d7935a59e5c2 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -1728,7 +1728,7 @@ HWTEST_F(ImageSourceTest, End2EndTest001, TestSize.Level3) ASSERT_EQ(desiredWidth, pixelMap->GetWidth()); ASSERT_EQ(desiredHeight, pixelMap->GetHeight()); ASSERT_EQ("undefined_", imageSource->GetPixelMapName(nullptr)); - ASSERT_EQ("w400_h200_streamSize27897_mimeTypeimage/jpeg", imageSource->GetPixelMapName(pixelMap.get())); + ASSERT_EQ("400x200-streamsize-27897-mimetype-jpeg", imageSource->GetPixelMapName(pixelMap.get())); } /**