提交 45fc9c4e 编写于 作者: X xing-tai-zhang

Description: Fix the problem that the image does not display after inputting...

Description: Fix the problem that the image does not display after inputting the correct path information
IssueNo: https://gitee.com/openharmony/graphic_ui/issues/I5HZE8
Feature or Bugfix: Bugfix
Binary Source:No
Signed-off-by: Nxing-tai-zhang <zhangxingtai@huawei.com>
上级 ee4ffae0
......@@ -132,24 +132,36 @@ bool Image::SetLiteSrc(const char* src)
return false;
}
size_t strLen = strlen(src) + 1;
const char* suffixName = ".bin";
size_t strLen = strlen(src) + strlen(suffixName) + 1;
char* imagePath = static_cast<char*>(UIMalloc(static_cast<uint32_t>(strLen)));
if (imagePath == nullptr) {
return false;
}
if (IsImgValid(ptr)) {
const char* suffixName = "bin";
if (memcpy_s(imagePath, strLen, src, strLen) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr;
return false;
}
(ptr - src + imagePath)[1] = '\0'; // remove suffix
if (strcat_s(imagePath, strLen, suffixName) != EOK) {
if (strcat_s(imagePath, strLen, suffixName) != EOK) { // The format is xxx.xxx.bin
UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr;
return false;
}
if (access(imagePath, F_OK) != EOK) { // Check whether the xxx.xxx.bin file exists
if (memcpy_s(imagePath, strLen, src, strLen) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr;
return false;
}
(ptr - src + imagePath)[0] = '\0'; // remove suffix
if (strcat_s(imagePath, strLen, suffixName) != EOK) { // The format is xxx.bin
UIFree(reinterpret_cast<void*>(imagePath));
imagePath = nullptr;
return false;
}
}
} else {
if (memcpy_s(imagePath, strLen, src, strLen) != EOK) {
UIFree(reinterpret_cast<void*>(imagePath));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册