Apply Custom Layout to Image in DigitalMicrograph GMS3

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 03:09:27

问题


I have an image in DigitalMicrograph GMS3 (v 3.21.1374.0) which i have applied a custom databar to (trying to learn how to do this via script here: add / apply custom databar to image in DigitalMicrograph GMS3)

I have a custom layout that I can add manually by doing the following:

  1. Right click on the image
  2. Hover on layout (in context menu)
  3. Left click "Apply Layout..."
  4. Select the custom layout in dialog that pops up (the one I want is called "CheckLayout")
  5. Click OK

How do I do this with a script? I know how to get the image and the imagedisplay objects but that is as far as I get.

//main - get front image and apply custom layout
image Img := GetFrontImage()
imageDisplay imgDisplay = Img.ImageGetImageDisplay(0)

//apply custom layout to image here

Any ideas?


回答1:


The layout is a property of an ImageDocument not an image. The correct way of doing this (provided there exists a layout of name 'MyLayout') is:

ImageDocument doc = GetFrontImageDocument()
doc.ImageDocumentApplyLayout("MyLayout")

You might additionally be interested in the commands:

void ImageDocumentApplyLayout( ImageDocument, String )
void ImageDocumentRemoveDatabar( ImageDocument )
Number ImageDocumentGetLayoutCount( ImageDocument )
String ImageDocumentGetLayoutName( ImageDocument, Number )

as used in

ImageDocument doc = GetFrontImageDocument()
number nLO = doc.ImageDocumentGetLayoutCount()
Result( "\n Layouts in document:" +  nLO )
For( number i=0; i<nLO; i++)
{
    string layoutName = doc.ImageDocumentGetLayoutName(i)
    Result( "\n\t"+i+":"+layoutName)
}


来源:https://stackoverflow.com/questions/50822112/apply-custom-layout-to-image-in-digitalmicrograph-gms3

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!