Signed-off-by: weishaoxiong <weishaoxiong1@huawei.com>

fix:CreatePixelMap
This commit is contained in:
weishaoxiong
2022-07-12 14:52:08 +08:00
parent b3fc123dfe
commit 9631cedb2e
+11 -6
View File
@@ -444,14 +444,19 @@ bool WallpaperService::MakeCropWallpaper(int wallpaperType)
int32_t pictrueWidth = wallpaperPixelMap->GetWidth();
int pyScrWidth = GetWallpaperMinWidth();
int pyScrHeight = GetWallpaperMinHeight();
if (pictrueHeight > pyScrHeight || pictrueWidth > pyScrWidth) {
bool bHeightFlag = false, bWidthFlag = false;
if (pictrueHeight > pyScrHeight) {
decodeOpts.CropRect.top = (pictrueHeight - pyScrHeight)/HALF;
decodeOpts.CropRect.width = pyScrWidth;
decodeOpts.CropRect.left = (pictrueWidth - pyScrWidth)/HALF;
decodeOpts.CropRect.height = pyScrHeight;
decodeOpts.desiredSize.width = pyScrWidth;
decodeOpts.desiredSize.height = pyScrHeight;
bHeightFlag = true;
}
if (pictrueWidth > pyScrWidth) {
decodeOpts.CropRect.left = (pictrueWidth - pyScrWidth)/HALF;
bWidthFlag = true;
}
decodeOpts.CropRect.height = bHeightFlag ? pyScrHeight : pictrueHeight;
decodeOpts.desiredSize.height = decodeOpts.CropRect.height;
decodeOpts.CropRect.width = bWidthFlag ? pyScrWidth : pictrueHeight;
decodeOpts.desiredSize.width = decodeOpts.CropRect.width;
wallpaperPixelMap = imageSource->CreatePixelMap(decodeOpts, errorCode);
if (errorCode != 0) {
ret = false;