首页 > 解决方案 > CleanImage() 的相反命令是什么

问题描述

CleanImage( BasicImage ) 允许在不出现对话框的情况下删除图像:“你想保存...”

除了向整个图像(8k x 8k)添加零之外,还有对应的部分吗?像:

脏图像(基本图像)

谢谢!

标签: dm-script

解决方案


不,这样的命令不存在,但它也不是真的有用。对 imageDocument 的
任何操作都会自动将其标记为(即需要保存),因此您可以通过添加/删除标签轻松地做到这一点;临时设置一个像素值;移动窗户等

该命令CleanImage()实际上只是一个便利功能。实际属性“与存储的文件不同”ImageDocument的属性,即保存到磁盘的内容。

因此,该命令实际上并没有对没有ImageDocument的图像做任何事情,即从未显示、保存或ImageGetOrCreateImageDocument()调用过它们的图像变量。你可以在这里看到这个:

image img := RealImage( "test", 4, 100, 100 )
If ( TwoButtonDialog("Show?","Yes","No") )
    img.ShowImage()

If ( TwoButtonDialog("Try closing before cleaning?","Yes","No") )
    img.CloseImage()
else
{
    img.CleanImage()
    img.CloseImage()
}

该命令真正匹配:

void ImageDocumentClean( ImageDocument imgDoc )

检查 imageDocument 是否需要保存的命令是

Boolean ImageDocumentIsDirty( ImageDocument img_doc )

因此,更典型的是,人们会使用这些命令,就像我在下面的脚本中所做的那样。


The following script shows how you can easily "dirty" an imageDocument just by re-setting one of the pixels value. Note that this script works independently of having the image displayed, because we explicitly create the ImageDocument.

Result( "\n Create Image... ")
image img := RealImage( "test", 4, 100, 100 )
Result( "\n Get it's ImageDocument... ")
imageDocument doc = img.ImageGetOrCreateImageDocument()

Result( "\n Is it dirty? --> " + (doc.ImageDocumentIsDirty()?"Yes, dirty":"No, clean"))
Result( "\n Clean it!" )
doc.ImageDocumentClean()
Result( "\n Is it dirty? --> " + (doc.ImageDocumentIsDirty()?"Yes, dirty":"No, clean"))
Result( "\n Make it dirty by setting the first pixel value to the value it has..." )
img.SetPixel(0,0,img.GetPixel(0,0))
Result( "\n Is it dirty? --> " + (doc.ImageDocumentIsDirty()?"Yes, dirty":"No, clean"))

However, I am curious in when such a functionality would ever be needed?


推荐阅读