How to look at Bitmap objects in Visual Studio debugger?
Asked Answered
G

8

33

I am building a C# app that creates many bitmaps (System.Drawing.Image). Having the bitmaps seen in the debugger as pictures, would be of enormous help. The debugger has native support for XML files. Is there a way to see the pictures?

Gmur answered 20/4, 2012 at 13:5 Comment(3)
+1 good question, this would be awesome in apps like hawkeye.codeplex.com, research.microsoft.com/en-us/projects/debuggercanva, whats this about XML files - do you have a link?Winou
XML preview is natively supported by VS on any string. Just hover over any System.String in the debugger, you will see a magnifier icon. There you may choose the visualization types. XML is one of them.Gmur
I usually use something like bitmap.Save(@"C:\test.bmp") from the Immediate Window to view my bitmaps when debugging, although I know this isn't ideal when debugging a large number of bitmaps :)Strother
W
16

There is no debugger visualizer by default for Bitmap, so you might want to give this one a try: http://imagedebugvisualizer.codeplex.com/

Willner answered 20/4, 2012 at 13:7 Comment(3)
Is there one for later versions of Visual Studio?Fireback
For VS 2015/2017: marketplace.visualstudio.com/…Bloodstain
The link is dead since CodePlex was shutdown.Glasshouse
M
14

Another open source image and bitmap visualizer which works in Visual Studio 2019:

https://github.com/Jaex/ImageVisualizer

Screenshot from it:

Mozart answered 17/4, 2016 at 11:55 Comment(2)
Does your visualizer work with WPF images as well? The documentation on github has no hints about that.Dorsad
Only GDI Image/Bitmap.Mozart
P
5

I did it this way before I read Rachel's comment above which would have been much easier....

You could Base64 encode it - in your immediate Window:

System.IO.MemoryStream stream = new System.IO.MemoryStream();
yourImage.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] bytes = stream.ToArray();
base64string = System.Convert.ToBase64String(bytes);

Then copy and paste the value of base64string into your favourite base64 debugger, e.g.

https://codebeautify.org/base64-to-image-converter

Papagena answered 6/11, 2017 at 12:23 Comment(0)
F
2

This program works for me in 2013 and should work from 2010 - 15 http://bytescout.com/products/developer/bitmapvisualizer/index.html

Fireback answered 30/4, 2014 at 16:30 Comment(5)
Not working for me on VS2013 Ultimate Update 2. :( Someone left a review saying the same: visualstudiogallery.msdn.microsoft.com/…Compo
update: the current version (as of October 2015) of this plugin works with VS2013 and VS2015 now. Disclosure: I work for ByteScoutAcescent
I've just installed it in VS2010 and it works perfectly. If there are some limitations in Trial version I don't find them anywhere. @EugeneM could you please tell us ?Stuckup
@Stuckup it is a free plugin!Acescent
Ok thanks :). That was also my guess but it's absolutely not clear on your company website due to the "Download free trial" button and "FREE for commercial and non-commercial use" warning.Stuckup
D
0

Try BitMapVisualizer by ByteScout http://bytescout.com/products/developer/bitmapvisualizer/index.html

Trial version is for free

Deipnosophist answered 3/10, 2014 at 11:1 Comment(0)
Q
0

Another good option is Bitmap & BitmapSource Visualizer for Visual Studio 2013. It also has bonus as source code (I used it for recompiling into 4.5 framework due to problems with 3.5 in my machine).

By default it adds Width and Height information about image (in contrast of Bytescout plugin, which adds more info), but you can add any information through code - there just simple String.Format using.

Quinquennium answered 25/9, 2015 at 15:1 Comment(0)
I
0

The answers are good but yet another alternative is to write your own debugger visualizer, which is supported by VS for a long time. There is a good old CodeProject article showing how to write a debugger visualizer:

https://www.codeproject.com/Articles/24211/Graphics-Debugger-Visualizer

Using this method I had also written other visualizers before such as DataTable visualizer. Not just for Bitmap visualizer, this is up to your custom needs and you can write any visualizer.

The process is pretty easy: Write your visualizer, compile it as a DLL and drop it into your VS\Common7\Packages\Debugger\Visualizers folder.

Issie answered 22/11, 2022 at 12:42 Comment(0)
B
0

06.2024 update

Image Watch for Visual Studio 2022 by Microsoft Can be found directly under Extensions in VS 2022

Behling answered 6/6 at 11:22 Comment(2)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewHeadband
"Image Watch" is for c++ Code. The question was for C#.Loy

© 2022 - 2024 — McMap. All rights reserved.