Showing
1 changed file
with
16 additions
and
10 deletions
| @@ -16,7 +16,7 @@ import { topicInfoView } from './topicInfoView'; | @@ -16,7 +16,7 @@ import { topicInfoView } from './topicInfoView'; | ||
| 16 | import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer'; | 16 | import { DateFormatUtil, PlayerConstants, WDPlayerController } from 'wdPlayer'; |
| 17 | import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList'; | 17 | import { AudioDataList } from 'wdBean/src/main/ets/bean/morningevening/AudioDataList'; |
| 18 | import { image } from '@kit.ImageKit'; | 18 | import { image } from '@kit.ImageKit'; |
| 19 | -import { getPicture, imageNet2PixelMap } from '../../utils/ImageUtils'; | 19 | +import { findMaxPixel, getPicture, imageNet2PixelMap, traverseAllPixel } from '../../utils/ImageUtils'; |
| 20 | import { effectKit } from '@kit.ArkGraphics2D'; | 20 | import { effectKit } from '@kit.ArkGraphics2D'; |
| 21 | import { window } from '@kit.ArkUI'; | 21 | import { window } from '@kit.ArkUI'; |
| 22 | import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; | 22 | import { PeopleShipMainViewModel } from '../../viewmodel/PeopleShipMainViewModel'; |
| @@ -25,7 +25,7 @@ import { viewColumInsightIntentShare } from '../../utils/InsightIntentShare' | @@ -25,7 +25,7 @@ import { viewColumInsightIntentShare } from '../../utils/InsightIntentShare' | ||
| 25 | import { common } from '@kit.AbilityKit'; | 25 | import { common } from '@kit.AbilityKit'; |
| 26 | import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils' | 26 | import TrackingPageBrowseUtils from '../../utils/TrackingPageBrowseUtils' |
| 27 | import {TrackConstants,TrackParamConvert}from 'wdTracking/Index' | 27 | import {TrackConstants,TrackParamConvert}from 'wdTracking/Index' |
| 28 | -import { ColorUtils } from '../../utils/ColorUtils'; | 28 | +import { ColorHsv, ColorRgb, ColorUtils } from '../../utils/ColorUtils'; |
| 29 | import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'; | 29 | import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'; |
| 30 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' | 30 | import { EmitterEventId, EmitterUtils } from 'wdKit/Index' |
| 31 | 31 | ||
| @@ -238,14 +238,20 @@ export struct MorningEveningPaperComponent { | @@ -238,14 +238,20 @@ export struct MorningEveningPaperComponent { | ||
| 238 | private async pickColor(imageSource: image.ImageSource | undefined) { | 238 | private async pickColor(imageSource: image.ImageSource | undefined) { |
| 239 | if (imageSource) { | 239 | if (imageSource) { |
| 240 | const pixelMap: image.PixelMap = await imageNet2PixelMap(imageSource); | 240 | const pixelMap: image.PixelMap = await imageNet2PixelMap(imageSource); |
| 241 | - effectKit.createColorPicker(pixelMap, (err, colorPicker) => { | ||
| 242 | - let color = colorPicker.getMainColorSync(); | ||
| 243 | - console.log(TAG, "compInfoBean compStyle = " + color) | ||
| 244 | - // color = ColorUtils.getMorningEveningPaperRgb({red:color.red,green:color.green,blue:color.blue,alpha:color.alpha}) | ||
| 245 | - // 将取色器选取的color示例转换为十六进制颜色代码 | ||
| 246 | - this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16); | ||
| 247 | - console.log(TAG, "compInfoBean compStyle = " + this.mixedBgColor) | ||
| 248 | - }); | 241 | + let allPixels: number[] = await traverseAllPixel(pixelMap); |
| 242 | + let maxPixel: number = findMaxPixel(allPixels); | ||
| 243 | + let rgb: ColorRgb = ColorUtils.numberToRgb(maxPixel); | ||
| 244 | + let hsv: ColorHsv = ColorUtils.rgb2hsv(rgb); | ||
| 245 | + rgb = ColorUtils.hsv2rgb(hsv); | ||
| 246 | + this.mixedBgColor = "#" + rgb.red.toString(16) + rgb.green.toString(16) + rgb.blue.toString(16); | ||
| 247 | + // effectKit.createColorPicker(pixelMap, (err, colorPicker) => { | ||
| 248 | + // let color = colorPicker.getMainColorSync(); | ||
| 249 | + // console.log(TAG, "compInfoBean compStyle = " + color) | ||
| 250 | + // // color = ColorUtils.getMorningEveningPaperRgb({red:color.red,green:color.green,blue:color.blue,alpha:color.alpha}) | ||
| 251 | + // // 将取色器选取的color示例转换为十六进制颜色代码 | ||
| 252 | + // this.mixedBgColor = "#" + color.alpha.toString(16) + color.red.toString(16) + color.green.toString(16) + color.blue.toString(16); | ||
| 253 | + // console.log(TAG, "compInfoBean compStyle = " + this.mixedBgColor) | ||
| 254 | + // }); | ||
| 249 | } | 255 | } |
| 250 | } | 256 | } |
| 251 | 257 |
-
Please register or login to post a comment