首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将一个图像显示在另一个图像上?

如何将一个图像显示在另一个图像上?
EN

Stack Overflow用户
提问于 2021-07-14 02:58:43
回答 1查看 70关注 0票数 1

我希望在dm3图像上添加水印,并能够指定水印的大小和位置。

代码语言:javascript
复制
image front := GetFrontImage()
ImageDocument imageDoc = GetFrontImageDocument()
ImageDisplay imgDisplay = ImageGetImageDisplay(front,0)

image img2 := OpenImage("WaterMark.jpg")
imageDoc.ImageDocumentAddImage( img2 )

但是,水印图像没有显示在此脚本中的图像上。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-14 07:48:06

您需要更好地理解组件的概念。ImageDisplays和注释都是组件。ImageDocument是一个容器(要序列化到磁盘),它包含一个或多个组件,最典型的是仅包含一个imageDisplay。所有组件都可以有子组件,因此图像上的任何注释实际上都是ImageDisplay组件上的注释组件。这也适用于显示在图像上的其他图像。您希望将ImageDisplay添加为另一个ImageDisplay的子级,例如:

代码语言:javascript
复制
image img:= realImage("Test",4,500,500)
img = icol
img.ShowImage()

image icon := realImage("Icon",4,100,100)
icon = iradius

// Adding icon onto parent, it will be 0/0 aligned
imageDisplay parentDisp = img.ImageGetImageDisplay(0)
imageDisplay childDisp = icon.NewImageDisplay("best")
parentDisp.ComponentAddChildAtEnd(childDisp)

// Move icon to bottom right corner. 10% (of icon size) shifted inward
number nx = 500 // x-position at which control point of component should be placed
number ny = 500 // y-position at which control point of component should be placed
number rx = 1.1 // relative x position of control point of component within component rect. (0.0=left 1.0=right)
number ry = 1.1 // relative y position of control point of component within component rect. (0.0=top 1.0=bottom)
number doH = 1  // command will shift horizontally (true/false)
number doV = 1  // command will shift vertically (true/false)
childDisp.ComponentPositionAroundPoint(nx,ny, rx,ry, doH,doV)

OKDialog("Now show move/scaling by transformation.")
// Scale and position componets on their parents.
number offsetX = -200   // x shift of component in parent's coordinate system
number offsetY = -100   // y shift of component in parent's coordinate system
number scaleX = 0.8     // x-scale (relative) of component
number scaleY = 0.8     // y-scale (relative) of component. Note: Not all components can scale x/y indepently
childDisp.ComponentTransformCoordinates(offsetX,offsetY,scaleX,scaleY)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68371462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档