TagGroupGetTagType返回错误的类型 [英] TagGroupGetTagType returns wrong type

查看:115
本文介绍了TagGroupGetTagType返回错误的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,这是我无法解决的我的旧问题的特定问题.

Basically this is the specific question for my older question which I just can't solve.

为我的开发提供了示例图像.该图像包含(我想代表)TagGrop,该图像显示有关如何创建图像的信息.

I was given an example image for my development. This image contains a (I guess representative) TagGrop that displays the information about how the image is created.

我的问题是,此TagGroup元素的TagGroupGetTagType()对于本身为TagGroups的元素返回3.但是TagGroups具有类型0(由我本人和@BmyGuest在链接的问题中确认).下图显示了示例脚本的输出以及标签编辑器对话框.可以看到,每个元素的类型都是3,包括TagGroups(例如 Acquision )或其他元素.

My problem is, that TagGroupGetTagType() of the elements of this TagGroup returns 3 for elements that are TagGroups itself. But TagGroups have the type 0 (confirmed by myself and @BmyGuest in the linked question). The following image shows the output of my example script together with the tag editor dialog. As one can see that every element has the type 3, including TagGroups like Acquision or others.

上面的图像是使用以下脚本创建的:

The image above has been created with the following script:

clearResults();

image img;
img.GetFrontImage();
TagGroup tg = img.ImageGetTagGroup();

TagGroupOpenBrowserWindow(tg, 0);

for(number i = 0; i < tg.TagGroupCountTags(); i++){
    String label = tg.TagGroupGetTagLabel(i);
    number type = tg.TagGroupGetTagType(i, 0);

    result("Index " + label + " has type " + type + "\n");
}

我做错了什么?为什么这不起作用?有什么方法可以获取正确的类型?

What am I doing wrong? Why does this not work? Is there any way to get the correct type?

这可能与文件有关,因此我创建了一个示例文件,该文件缺少某些索引(以保护给我此文件的人员的隐私).实际上,发布的输出是使用此文件创建的.因此,同样的问题也会发生.可以从 https://www.file-upload下载该文件. net/download-14020685/example.dm4.html .

This may be related to the file so I created an example file which is missing some of the indices (for protecting the privacy of the people who gave me this file). The posted output is in fact created with this file. So the same problem occurres. This file can be downloaded from https://www.file-upload.net/download-14020685/example.dm4.html.

(对于不希望从随机页面下载文件的人,您可以在此处获取base64编码的文件内容:推荐答案

确认和确认;解决方法

A confirmation & Workaround

使用您的脚本和提供的文件,我可以准确地再现结果.

Using your script and provided file, I can exactly reproduce the result.

此外,如果我运行以下脚本(在GMS 3.4中):

Moreover, if I run the following script (in GMS 3.4):

image img := RealImage("Test",4,10,10)
taggroup newTG = NewTagGroup()
newTG.TagGroupSetTagAsString("Test","oh")
img.imagegettaggroup().TagGroupSetTagAsTagGroup("TG",newTG)
img.ShowImage()

然后运行您的脚本,我得到:

And then run your script, I get:

Index GMS Version has type 0
Index TG has type 0

但是,如果我保存文件,然后再次打开它并运行您的脚本,我会突然得到:

However, if I save the file and then open it up again and run your script, I suddenly get:

Index GMS Version has type 3
Index TG has type 3

因此,某些事情已经明显改变并且关闭了.我尝试了一些较旧的数据(所有数据均保存在GMS 3.x中),并且我总是获得TagGroups的类型3.我找不到由GMS 2.x或GMS 1.x保存的数据,但假定其中一个或两个都返回类型0.

So, something has clearly changed and is off. I tried some older data (all saved with GMS 3.x) and I always get a type 3 for TagGroups. I could not find data saved by GMS 2.x or GMS 1.x but would assume either or both would return type 0.

我还注意到,命令TagGroupGetTagTypeLength在保存之前返回0,但是对于加载的图像返回1,我认为这可能是相关的.

I've also noticed that the command TagGroupGetTagTypeLength returns 0 before saving, but 1 for the loaded image, and I think that might be related.

但是您可以使用一种解决方法,它可以解决您的实际问题. 对于TagGroup(和TagList),您可以通过实际尝试将标签作为TagGroup的方式来替换对类型的检查,如:

But there is a workaround you can use, which might solver your actual question. For TagGroups (and TagLists) you can replace your check for the type by an actual attempt to get the tag as a TagGroup, as in:

clearResults();

image img;
img.GetFrontImage();
TagGroup tg = img.ImageGetTagGroup();

TagGroupOpenBrowserWindow(tg, 0);

for(number i = 0; i < tg.TagGroupCountTags(); i++){
    String label = tg.TagGroupGetTagLabel(i);
    number typeL = tg.TagGroupGetTagTypeLength(i);
    number type = tg.TagGroupGetTagType(i, 0);

    result("Index " + label + " has " + typeL + " types. Type = " + type + "\n");
    TagGroup tgtest
    if ( tg.TagGroupGetIndexedTagAsTagGroup(i,tgtest) )
        Result("\tIt is as TagGroup (or TagList)!\n")
}

这篇关于TagGroupGetTagType返回错误的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆