我从这里在可扩展性部分尝试了第一个示例:
http://research.microsoft.com/en-us/um/redmond/groups/ivm/imagewatchhelp/imagewatchhelp.htm#_Toc351981452

这是我的代码:

#include <memory>
struct My8BitRGBImage
{
    unsigned int ncols;
    unsigned int nrows;
    unsigned char* data;
};

void main()
{
    unsigned int ncols = 100;
    unsigned int nrows = 100;
    unsigned int bufferSize = ncols * nrows * 3;
    unsigned char * data = new unsigned char[bufferSize];
    memset(data, 0, bufferSize);
    My8BitRGBImage image = { ncols, nrows, data };
}

当我在最后一行中断并尝试观看图像时,我变得无效:
Image

在ImageWatch.log上,似乎My8BitRGBImage已正确注册:
+ Parsing ImageWatchFrameBuffer.natvis ...
+ Found type My8BitRGBImage ...
+ -> Registering My8BitRGBImage

ImageWatchFrameBuffer.nativs看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

  <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1"
                MenuName="Add to Image Watch"/>

  <Type Name="My8BitRGBImage">
    <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
  </Type>

  <Type Name="My8BitRGBImage">
    <Expand>
      <Synthetic Name="[type]">
        <DisplayString>UINT8</DisplayString>
      </Synthetic>
      <Synthetic Name="[channels]">
        <DisplayString>RGB</DisplayString>
      </Synthetic>
      <Item Name="[width]">ncols</Item>
      <Item Name="[height]">nrows</Item>
      <Item Name="[data]">data</Item>
      <Item Name="[stride]">ncols*3</Item>
    </Expand>
  </Type>

</AutoVisualizer>

复制示例中的粘贴。
我正在使用VS2015更新1。
可能是什么问题呢?

最佳答案

使用

<Item Name="[channels]">3</Item>

代替
<Synthetic Name="[channels]">
    <DisplayString>RGB</DisplayString>
</Synthetic>

关于c++ - 图片观看显示无效图片,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41088475/

10-16 16:43