如何将一张图片显示在另一张图片之上?

How to display one image on top of another?

我想在dm3图片上加水印,并且可以指定水印的大小和位置

image front := GetFrontImage()
ImageDocument imageDoc = GetFrontImageDocument()
ImageDisplay imgDisplay = ImageGetImageDisplay(front,0)

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

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

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

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)