none
QImage natvis for ImageWatch RRS feed

  • Question

  • Hi.

    I have got some issues using the ImageWatch for c++ with QImage. First, here is my .natvis

      <Type Name="QImage">
        <AlternativeType Name="QImage&lt;*&gt;"/>
        <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
      </Type>
    
      <Type Name="QImage">
        <Expand>
          <Synthetic Name="[type]">
            <DisplayString>UINT8</DisplayString>
          </Synthetic>
          <Synthetic Name="[channels]">
            <DisplayString>BGRA</DisplayString>
          </Synthetic>
          <Item Name="[width]">d-&gt;width</Item>
          <Item Name="[height]">d-&gt;height</Item>
          <Item Name="[data]">d-&gt;data</Item>
          <Item Name="[stride]">d-&gt;bytes_per_line</Item>
        </Expand>
      </Type>  
    

    Now i got the error:

    "Fehler: "Klasse "QImageData"" hat keinen Member ""width"".
        Fehler beim Auswerten von "d->width" im Kontext von Typ "const ImageTest.exe!QImage"."

    Which means the d-pointer has no member "with". But in the next line i got:

    "Der Ausdruck "d->width" im Typkontext "QImage" wurde erfolgreich analysiert."

    Which means "d->with" was successfull analised.

    So my next step was that i thought "Ok, the d-pointer is a QImageData." So i also added QImageData to the natvis file.

      <Type Name="QImageData">
        <AlternativeType Name="QImageData&lt;*&gt;"/>
        <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
      </Type>
    
      <Type Name="QImageData">
        <Expand>
          <Synthetic Name="[type]">
            <DisplayString>UINT8</DisplayString>
          </Synthetic>
          <Synthetic Name="[channels]">
            <DisplayString>BGRA</DisplayString>
          </Synthetic>
          <Item Name="[width]">width</Item>
          <Item Name="[height]">height</Item>
          <Item Name="[data]">data</Item>
          <Item Name="[stride]">bytes_per_line</Item>
        </Expand>
      </Type>

    But it doesn't help.

    After that i created a small class to access the data i need.

    class MemPic
    {
    public:
        MemPic(const QImage& image)
        {
            width = image.width();
            height = image.height();
            data = image.constBits();
            bpl = image.bytesPerLine();
        }
        virtual ~MemPic() = default;
    
    private:
        int width;
        int height;
        const unsigned char* data;
        int bpl;
    };

    And inserted a definition into the .natvis.

      <Type Name="MemPic">
        <AlternativeType Name="MemPic&lt;*&gt;"/>
        <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
      </Type>
    
      <Type Name="MemPic">
        <Expand>
          <Synthetic Name="[type]">
            <DisplayString>UINT8</DisplayString>
          </Synthetic>
          <Synthetic Name="[channels]">
            <DisplayString>BGRA</DisplayString>
          </Synthetic>
          <Item Name="[width]">width</Item>
          <Item Name="[height]">height</Item>
          <Item Name="[data]">data</Item>
          <Item Name="[stride]">bpl</Item>
        </Expand>
      </Type>

    And this time it works. I can see the image in ImageWatch.

    But this is not the solution for me. Is there anything else i can do to see the image from QImage?

    Thanks

    Kai

    Monday, March 5, 2018 6:58 AM

All replies

  • Since this issue is more related to QImage which belongs to QT, I recommend you post this issue at QT forum where you will get more professional support.

    Your understanding and cooperation will be grateful.

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, March 6, 2018 8:34 AM
  • Hi,

    thanks for your answer. I will post it also on Qt Forum.

    But i think it's not only releated to Qt and QImage.

    Because my .natvis is working for the normal watch window. I Can see  witdth, height, data... everythink like i have configured in the natvis. The only Problem is the ImageWatch. I don't see the image because ImageWatch said that the entity don't have this property. The normal watch window said that the statement was sucessfull analysed. 

    It's:

    d-pointer has no member "with".

    from ImageWatch

    versus

    "d->with" was successfull analised

    from normal watch window.

    So, i think it's more related to ImageWatch.

    Regards,

    Kai

    Tuesday, March 6, 2018 11:04 AM
  • I hate to say it, but your replies are incompetent.
    Friday, March 16, 2018 8:17 AM
  • Hi Violet Giraffe,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 20, 2018 8:57 AM
    Moderator
  • Hi Violet Giraffe,

    Maybe QImageData doesn’t have a “width” member, but rather a “width()” function? That’s the only thing that I can think of. Or you have some typos so maybe they spelled “width” wrong in natvis. Looks like their output is showing “with”.

    In addition, debugging open sourcing ImageWatch would be a good idea, but I got the information is that open sourcing ImageWatch is on product team radar, but in the early stages yet.

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 26, 2018 2:57 AM
    Moderator
  • Has there been any solution to this problem?
    Monday, September 30, 2019 8:30 AM
  • Without digging too deep (yet) I think this fails because the QImage data is stored in a struct member 1 level deep.  I hope to take a look and see if d->width, d->height, etc will work with natvis + ImageWatch accessing the buried members.

    https://www.linkedin.com/in/visualbill/

    • Proposed as answer by Bill Luter Friday, August 14, 2020 5:58 PM
    • Unproposed as answer by Bill Luter Friday, August 14, 2020 5:59 PM
    Sunday, October 13, 2019 12:34 AM
  • If anyone but me is still interested in this topic, I am partially there:

    The following natvis works (for only a few formats - not all have been added) in VS 2017 but alas I still cannot display the image in ImageWatch.  If anyone has a tip let me know.

      <Type Name="QImageData">
        <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
      </Type>
        <Type Name="QImageData">
            <DisplayString>{{UINT8, 3 x {width} x {height}}}</DisplayString>
            <Expand>
                <Synthetic Name="[type]">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]">
                    <DisplayString>3</DisplayString>
                </Synthetic>
                <Item Name="[width]">width</Item>
                <Item Name="[height]">height</Item>
                <Item Name="[data]">data</Item>
                <Item Name="[stride]" >bytes_per_line</Item>
            </Expand>
        </Type>
      <Type Name="QImage">
        <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" />
      </Type>
      <!--
              Format_Invalid,
            Format_Mono,
            Format_MonoLSB,
            Format_Indexed8,
            Format_RGB32,
            Format_ARGB32,
            Format_ARGB32_Premultiplied,
            Format_RGB16,
            Format_ARGB8565_Premultiplied,
            Format_RGB666,
            Format_ARGB6666_Premultiplied,
            Format_RGB555,
            Format_ARGB8555_Premultiplied,
            Format_RGB888,
            Format_RGB444,
            Format_ARGB4444_Premultiplied,
            Format_RGBX8888,
            Format_RGBA8888,
            Format_RGBA8888_Premultiplied,
            Format_BGR30,
            Format_A2BGR30_Premultiplied,
            Format_RGB30,
            Format_A2RGB30_Premultiplied,
            Format_Alpha8,
            Format_Grayscale8,
            Format_RGBX64,
            Format_RGBA64,
            Format_RGBA64_Premultiplied,
            Format_Grayscale16,
      -->
        <Type Name="QImage">
            <DisplayString Condition="d-&gt;format==0">{{{d-&gt;format,en}, INVALID}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==1">{{{d-&gt;format,en}, UINT8,  1 x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==2">{{{d-&gt;format,en}, UINT8,  1 x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==3">{{{d-&gt;format,en}, UINT8,  1 x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==4">{{{d-&gt;format,en}, UINT8,  1 x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==5">{{{d-&gt;format,en}, UINT8,  1 x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <DisplayString Condition="d-&gt;format==13">{{{d-&gt;format,en}, UINT8,  RGB x {d-&gt;width} x {d-&gt;height}}}</DisplayString>
            <Expand>
                <Synthetic Name="[type]" Condition="d-&gt;format==0">
                    <DisplayString>INVALID</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==1">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==2">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==3">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==4">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==5">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[type]" Condition="d-&gt;format==13">
                    <DisplayString>UINT8</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==0">
                    <DisplayString>INVALID</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==1">
                    <DisplayString>1</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==2">
                    <DisplayString>1</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==3">
                    <DisplayString>1</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==4">
                    <DisplayString>4</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==5">
                    <DisplayString>4</DisplayString>
                </Synthetic>
                <Synthetic Name="[channels]" Condition="d-&gt;format==13">
                    <DisplayString>RGB</DisplayString>
                </Synthetic>
                <Item Name="[width]">d-&gt;width</Item>
                <Item Name="[height]">d-&gt;height</Item>
                <Item Name="[data]">d-&gt;data</Item>
                <Item Name="[stride]" >d-&gt;bytes_per_line</Item>
                <Synthetic Name="[format]">
                    <DisplayString>{d-&gt;format,en}</DisplayString>
                </Synthetic>
            </Expand>
        </Type>

    Friday, August 14, 2020 6:01 PM