当前位置: 首页 > news >正文

企业网站网页设计福建seo优化

企业网站网页设计,福建seo优化,海珠网站建设报价,白云区网站建设公前言: 这个模块可以截取组件的图片,无论组件是否已加载。截图只能拍到组件本身的大小区域。 如果组件或其子组件画得超出了自己的区域,超出的部分不会出现在截图中。截图不会拍到与当前组件平级的(兄弟)组件。 模块简…

前言:

这个模块可以截取组件的图片,无论组件是否已加载。截图只能拍到组件本身的大小区域。 如果组件或其子组件画得超出了自己的区域,超出的部分不会出现在截图中。截图不会拍到与当前组件平级的(兄弟)组件。

模块简介和注意:

- XComponent场景建议:

如果你正在开发一个视频播放器,应该直接从视频画面获取图片,而不是使用组件的截图功能。

- 组件截图注意事项:

如果有一个按钮,但按钮周围有空白,截图时会显示这些空白为透明。
如果给按钮加了一个阴影效果,截图时可能会看到额外的阴影部分。

简单实例

componentSnapshot.get

get(id: string, callback: AsyncCallback<image.PixelMap>, options?: SnapshotOptions): void

参数类型说明
idstring目标组件标识
callbackAsyncCallback<image.PixelMap>回调函数
optionsSnapshotOptions截图相关的自定参数

AsyncCallback

AsyncCallback<T, E = void> {(err: BusinessError<E>, data: T): void;}

参数类型说明
errBusinessError接口调用失败的公共错误信息。
dataT接口调用时的公共回调信息。

options:SnapshotOptions

参数类型说明
scalenumber指定截图时图形侧绘制pixelmap的缩放比。
waitUntilRenderFinishedboolean指定是否强制等待系统执行截图指令前所有绘制指令都执行完成之后再截图。
先对项目中的关键代码进行简单讲解,最后是

导入模块:

import { componentSnapshot } from '@kit.ArkUI';:导入 componentSnapshot 函数,用于生成组件的快照。
import { image } from '@kit.ImageKit';:导入 image 对象,用于处理图像。

状态变量:

@State pixmap: image.PixelMap | undefined = undefined:定义一个状态变量 pixmap,用于存储图像像素映射,初始值为 undefined

UI 结构:

Column():
创建一个垂直排列的容器。
Row():
创建一个水平排列的容器。
Image(this.pixmap):
显示一个 Image 组件,使用状态变量 pixmap 作为图像源,设置宽度和高度为 200 像素,添加黑色边框和外边距。
Image($r('app.media.app_icon')):
显示另一个 Image 组件,使用资源文件 'app.media.app_icon' 作为图像源,自动调整大小,设置宽度和高度为 200 像素,添加外边距,并设置 id 为 "root"Button("click to generate UI snapshot"):
创建一个 Button 组件,显示文本 "click to generate UI snapshot",并设置点击事件处理函数。
onClick(() => { ... }):
设置按钮的点击事件处理函数。
componentSnapshot.get("root", (error: Error, pixmap: image.PixelMap) => { ... }, {scale : 2, waitUntilRenderFinished : true}):使用 componentSnapshot.get 方法生成指定 id 的组件快照。
如果生成快照过程中发生错误,打印错误信息并返回。
如果成功生成快照,将生成的像素映射赋值给状态变量 pixmap。

同步执行

// 导入 @kit.ArkUI 模块中的 componentSnapshot 函数,用于生成组件快照
import { componentSnapshot } from '@kit.ArkUI';
// 导入 @kit.ImageKit 模块中的 image 对象,用于处理图像
import { image } from '@kit.ImageKit';// 使用 @Entry 装饰器标记该组件为应用的入口组件
@Entry
// 使用 @Component 装饰器标记该类为一个组件
@Component
// 定义名为 SnapshotExample 的结构化组件
struct SnapshotExample {// 定义一个状态变量 pixmap,用于存储图像像素映射,初始值为 undefined@State pixmap: image.PixelMap | undefined = undefined// 定义组件的构建方法,用于描述组件的 UI 结构build() {// 创建一个垂直排列的容器 ColumnColumn() {// 创建一个水平排列的容器 RowRow() {// 显示一个 Image 组件,使用状态变量 pixmap 作为图像源,设置宽度和高度为 200 像素,添加黑色边框和外边距Image(this.pixmap).width(200).height(200).border({ color: Color.Black, width: 2 }).margin(5)// 显示另一个 Image 组件,使用资源文件 'app.media.app_icon' 作为图像源,自动调整大小,设置宽度和高度为 200 像素,添加外边距,并设置 id 为 "root"Image($r('app.media.app_icon')).autoResize(true).width(200).height(200).margin(5).id("root")}// 创建一个 Button 组件,显示文本 "click to generate UI snapshot",并设置点击事件处理函数Button("click to generate UI snapshot").onClick(() => {// 使用 componentSnapshot.get 方法生成指定 id 的组件快照componentSnapshot.get("root",(error: Error, pixmap: image.PixelMap) => {// 如果生成快照过程中发生错误,打印错误信息并返回if (error) {console.log("error: " + JSON.stringify(error))return;}// 如果成功生成快照,将生成的像素映射赋值给状态变量 pixmapthis.pixmap = pixmap}, {scale : 2, waitUntilRenderFinished : true})}).margin(10)}// 设置 Column 容器的宽度为 100%.width('100%')// 设置 Column 容器的高度为 100%.height('100%')// 设置 Column 容器的子组件水平对齐方式为居中.alignItems(HorizontalAlign.Center)}
}

异步执行

import { componentSnapshot } from '@kit.ArkUI';
import { image } from '@kit.ImageKit';@Entry
@Component
struct SnapshotExample {@State pixmap: image.PixelMap | undefined = undefinedbuild() {Column() {Row() {Image(this.pixmap).width(200).height(200).border({ color: Color.Black, width: 2 }).margin(5)Image($r('app.media.img')).autoResize(true).width(200).height(200).margin(5).id("root")}Button("click to generate UI snapshot").onClick(() => {// 建议使用this.getUIContext().getComponentSnapshot().get()componentSnapshot.get("root", {scale : 2, waitUntilRenderFinished : true}).then((pixmap: image.PixelMap) => {this.pixmap = pixmap}).catch((err:Error) => {console.log("error: " + err)})}).margin(10)}.width('100%').height('100%').alignItems(HorizontalAlign.Center)}
}

componentSnapshot.createFromBuilder

createFromBuilder(builder: CustomBuilder, callback: AsyncCallback<image.PixelMap>, delay?: number, checkImageStatus?: boolean, options?: SnapshotOptions): void

参数类型说明
builderCustomBuilder自定义组件构建函数。
callbackAsyncCallback<image.PixelMap>截图返回结果的回调。
delaynumber指定触发截图指令的延迟时间。默认值:300单位:毫秒
checkImageStatusboolean指定是否允许在截图之前,校验图片解码状态。
optionsSnapshotOptions截图相关的自定义参数。

AsyncCallback

AsyncCallback<T, E = void> {(err: BusinessError<E>, data: T): void;}

参数类型说明
errBusinessError接口调用失败的公共错误信息。
dataT接口调用时的公共回调信息。

options:SnapshotOptions

参数类型说明
scalenumber指定截图时图形侧绘制pixelmap的缩放比。
waitUntilRenderFinishedboolean指定是否强制等待系统执行截图指令前所有绘制指令都执行完成之后再截图。

导入模块:

import { componentSnapshot } from ‘@kit.ArkUI’;:导入 componentSnapshot 函数,用于生成组件的快照。
import { image } from ‘@kit.ImageKit’;:导入 image 对象,用于处理图像。

状态变量:

@State pixmap: image.PixelMap | undefined = undefined:定义一个状态变量 pixmap,用于存储图像像素映射,初始值为 undefined。

同步执行

// 导入 @kit.ArkUI 模块中的 componentSnapshot 函数,用于生成组件快照
import { componentSnapshot } from '@kit.ArkUI';
// 导入 @kit.ImageKit 模块中的 image 对象,用于处理图像
import { image } from '@kit.ImageKit';// 使用 @Entry 装饰器标记该组件为应用的入口组件
@Entry
// 使用 @Component 装饰器标记该类为一个组件
@Component
// 定义名为 OffscreenSnapshotExample 的结构化组件
struct OffscreenSnapshotExample {// 定义一个状态变量 pixmap,用于存储图像像素映射,初始值为 undefined@State pixmap: image.PixelMap | undefined = undefined// 定义一个构建器方法 RandomBuilder,用于生成随机内容的 UI 结构@BuilderRandomBuilder() {// 创建一个垂直排列的 Flex 容器,设置主轴对齐方式为居中,交叉轴对齐方式为居中Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {// 显示一个 Text 组件,显示文本 'Test menu item 1',设置字体大小为 20 像素,宽度为 100 像素,高度为 50 像素,文本对齐方式为居中Text('Test menu item 1').fontSize(20).width(100).height(50).textAlign(TextAlign.Center)// 显示一个 Divider 组件,设置高度为 10 像素Divider().height(10)// 显示另一个 Text 组件,显示文本 'Test menu item 2',设置字体大小为 20 像素,宽度为 100 像素,高度为 50 像素,文本对齐方式为居中Text('Test menu item 2').fontSize(20).width(100).height(50).textAlign(TextAlign.Center)}// 设置 Flex 容器的宽度为 100 像素,并设置 id 为 "builder".width(100).id("builder")}// 定义组件的构建方法,用于描述组件的 UI 结构build() {// 创建一个垂直排列的 Column 容器Column() {// 创建一个 Button 组件,显示文本 "click to generate offscreen UI snapshot",并设置点击事件处理函数Button("click to generate offscreen UI snapshot").onClick(() => {// 使用 componentSnapshot.createFromBuilder 方法生成指定构建器的快照componentSnapshot.createFromBuilder(() => { this.RandomBuilder() }, // 提供构建器方法(error: Error, pixmap: image.PixelMap) => { // 回调函数处理生成的快照或错误// 如果生成快照过程中发生错误,打印错误信息并返回if (error) {console.log("error: " + JSON.stringify(error))return;}// 如果成功生成快照,将生成的像素映射赋值给状态变量 pixmapthis.pixmap = pixmap// 保存 pixmap 到文件(此处注释掉)// ....// 获取组件的尺寸和位置信息let info = this.getUIContext().getComponentUtils().getRectangleById("builder")// 打印组件的宽度、高度以及不同坐标系下的位置信息console.log(info.size.width + ' ' + info.size.height + ' ' + info.localOffset.x + ' ' + info.localOffset.y + ' ' + info.windowOffset.x + ' ' + info.windowOffset.y)},320, // 设置生成快照的宽度为 320 像素true, // 设置是否使用硬件加速{ scale: 2, waitUntilRenderFinished: true } // 设置缩放比例为 2,等待渲染完成后再生成快照)})// 显示一个 Image 组件,使用状态变量 pixmap 作为图像源,设置外边距为 10 像素,高度为 200 像素,宽度为 200 像素,添加黑色边框Image(this.pixmap).margin(10).height(200).width(200).border({ color: Color.Black, width: 2 })}// 设置 Column 容器的宽度为 100%,设置外边距为左 10 像素,上 5 像素,下 5 像素,设置高度为 300 像素.width('100%').margin({ left: 10, top: 5, bottom: 5 }).height(300)}
}

文章转载自:
http://kamela.stph.cn
http://martyrologist.stph.cn
http://jumbie.stph.cn
http://copyfit.stph.cn
http://readmission.stph.cn
http://scratcher.stph.cn
http://boschvark.stph.cn
http://subadar.stph.cn
http://assuring.stph.cn
http://dizygotic.stph.cn
http://jayhawk.stph.cn
http://whir.stph.cn
http://hatted.stph.cn
http://lha.stph.cn
http://winey.stph.cn
http://nowt.stph.cn
http://irremissible.stph.cn
http://distaste.stph.cn
http://inadvisable.stph.cn
http://declivous.stph.cn
http://stratoscope.stph.cn
http://quantometer.stph.cn
http://fatuous.stph.cn
http://wigtownshire.stph.cn
http://explain.stph.cn
http://clodpate.stph.cn
http://substantialize.stph.cn
http://heathy.stph.cn
http://analecta.stph.cn
http://special.stph.cn
http://serigraphy.stph.cn
http://dahomean.stph.cn
http://pend.stph.cn
http://deshabille.stph.cn
http://emblematist.stph.cn
http://granola.stph.cn
http://pottage.stph.cn
http://clammily.stph.cn
http://superheater.stph.cn
http://methoxamine.stph.cn
http://seamless.stph.cn
http://galvanotropism.stph.cn
http://driftless.stph.cn
http://dickeybird.stph.cn
http://obsecration.stph.cn
http://basidiomycetous.stph.cn
http://womp.stph.cn
http://prolotherapy.stph.cn
http://myiasis.stph.cn
http://frequentist.stph.cn
http://calorification.stph.cn
http://brussels.stph.cn
http://angiotensin.stph.cn
http://bratislava.stph.cn
http://twist.stph.cn
http://antilabor.stph.cn
http://broadwife.stph.cn
http://uba.stph.cn
http://coenosarc.stph.cn
http://amperehour.stph.cn
http://inexact.stph.cn
http://kittredge.stph.cn
http://perianth.stph.cn
http://doofunny.stph.cn
http://aspersion.stph.cn
http://besprent.stph.cn
http://paganize.stph.cn
http://transmogrify.stph.cn
http://zilch.stph.cn
http://maidenliness.stph.cn
http://priestly.stph.cn
http://interreges.stph.cn
http://exercise.stph.cn
http://pettily.stph.cn
http://neocolonialist.stph.cn
http://charming.stph.cn
http://haemophiloid.stph.cn
http://cong.stph.cn
http://hateless.stph.cn
http://tutsi.stph.cn
http://phone.stph.cn
http://anarthrous.stph.cn
http://oxyphile.stph.cn
http://howie.stph.cn
http://thingification.stph.cn
http://possibilism.stph.cn
http://buff.stph.cn
http://champleve.stph.cn
http://headway.stph.cn
http://orthophoto.stph.cn
http://unsuited.stph.cn
http://nacelle.stph.cn
http://presentable.stph.cn
http://argentina.stph.cn
http://reit.stph.cn
http://libyan.stph.cn
http://superficial.stph.cn
http://polyarchy.stph.cn
http://bridget.stph.cn
http://dissemblance.stph.cn
http://www.15wanjia.com/news/79363.html

相关文章:

  • 泰安做网站的公司优化大师客服电话
  • 做网站推广logo济南网站优化公司哪家好
  • 做网站还是租用服务器seo外包杭州
  • 建设网站公司 销售额 排行网站seo哪家好
  • 客服工作台关键词优化推广排名
  • 不限流量网站空间抖音seo公司
  • 建设网站中期要做什么百度经验官网登录
  • 网站开发违法seo网络推广软件
  • 杭州的网站建设北大青鸟培训机构官网
  • 网站导航条设计欣赏查网站是否正规
  • 公司建设网站的目的互联网营销的五个手段
  • 建立网站教程视频宁波seo网站推广
  • 新手学做网站txt什么叫关键词
  • 网站群内容管理系统阿里指数数据分析平台
  • 自己做发卡网站支付接口推广软文营销案例
  • 手机如何建设网站网络营销与传统营销的区别
  • 陕西手机网站建设公司南昌seo网站推广
  • 做二手房网站有哪些资料产品设计公司
  • 政府机关网站建设的依据免费的网站域名查询565wcc
  • 重庆商城网站建设怎样做公司网站推广
  • 重庆公司免费网站建设站长工具综合权重查询
  • 免费下载ppt模板网站哪个好seo专员简历
  • 阿里云心选建站百度关键词怎么排名
  • 佛山企业网站建设教程nba球队排名
  • 服务器地址怎么查山东服务好的seo公司
  • 自己做一个app难吗seo人员的职责
  • 珠海做网站哪间好广州seo排名优化
  • 网站图片居中代码推广app拿返佣的平台
  • nba最新新闻百度seo排名优化教程
  • 专业网站开发推广策划