Can we insert an image in CS (VS2008) file as an reference to support the complex logic?
The code is quite complex so I want to put the UML image of that code to increase the understanding.
Ram
You can use a hyperlink in a comment.
Example:
// See reference image: http://ourserver.com/documentation/images/reference1.jpg
And it will turn into a working hyperlink that anyone can click while pressing the CTRL key
I guess you want to embed an image inside the code editor?
In Visual Studio you can't do that (maybe there exists a 3rd party plugin which i'm not aware of).
All you can do is to embed some ascii art or add the image as separate file to your project and reference it in your comment.
Yes you can embed image inside the code editor. But the only extension I know it is Image Insertion extension for Visual Studio 2010.
You can get it from Visual Studio Gallery.
You can but for that you will need to create a static byte array and manually fill the array from the bytes of the image file like: static byte[] img = new byte[]{/*all image file bytes*}
I would suggest you to add the image as a resource to the assembly and then you can read it at runtime and do the required processing.
Related
In my C# WPF application the user have the possibility to import pictures.
Currently the source of the image is referenced to the picture path.
When the picture will be deleted or moved, then my reference is not valid anymore.
How is it managed in applications like Word or Photoshop? Is it possible to embed
the picture at runtime in my custom file? Or should these files copied to a
"image database"?
In Microsoft Word (docx) format. When you paste images in the document, it saves them as file(s). Try this:
Rename the .docx to .zip extension
Extract the zip archive
Now, navigate to the following and you can see all the embeded images here:
You can do something similar for your app. Without knowing the full context and design details its difficult to answer where should the images go.
Generally speaking, images should/could be co-located with the rest of the data that image compliments.
I have a .NET executable and I need to view the resources attached to it. I extracted .resource file from .NET executable using DotNetResourcesExtract utility but I don't now how to view content of .resource file.
Could someone explain how to view this file?
Not sure you're using it correctly...
Assuming your storing images there.
You can simply do:
Image resfile = ProjectName.Properties.Resources.resourceName;
So if resfile is an image, you can put it into an Image control.
so, if you have an image control on your form you can simply do:
imageControl.Image = ProjectName.Properties.Resources.resourceName;
If it's a text file or any other type of file - again, you can access it the same way. If it's a binary file, the ProjectName.Properties.Resources.resourceName will be a byte array, so you 'll need to load it in the correct manner.
Is that what you're wanting? Otherwise indicate what type of file are you trying to extract from your resource file.
According to MSDN The .resx (XML-based resource format) files are
converted into common language runtime binary .resources files
that can be embedded in a runtime binary executable or compiled into
satellite assemblies.
Getting to the point: How to view this?
Well, Since it's a binary file which contains resource(images etc.) therefore you could always use Windows resources editing/extracting applications.
eg. Restorator, Resource Hacker to name a few.
Meanwhile, have look at this Stackoverflow post. which sound almost similar.
I am new in monogame.
I loaded an image using Texture2D background;, then go to LoadContent() method and code background = Contect.Load<Texture2D>("background");. I then imported the image in the Content folder.
After that, I compiled it and got this error:
Unable to load background assets
I checked the Image, and it was background.bmp.
I'll keep on looking for a solution for this.
If you have a solution for me please give me a link.
Any help is appreciated. And by the way, I use Visual C# Express 2010.
Basically you have 2 options, you can either add the content to the Content folder directly (if I understand correctly that's what you have done) or you can pre-compile the assets into XNB files first.
If you are using content directly you will need to add the file extension in code like so:
background = Contect.Load<Texture2D>("background.bmp");
And you'll also need to make sure you set the file to Content / Copy if newer in the properties window inside Visual Studio.
As a side note, if you are going to stick with this method I suggest you save your images as PNG files instead of BMP because PNG has lossless compression and supports transparency.
Alternately, you can pre-compile your content files first to store them in a more optimal file format. See https://github.com/mono/MonoGame/wiki/MonoGame-Content-Processing
Right click on the picture, go to Property and you will see. Copy to output. The default is don't copy you need to turn to Copy Always
Currently I'm loading the image from the local disk but I would like to embed the image into the program, I have added the image epsonScanner.png to the project and it appears in Solution Explorer how can add this to the array?
images.Add(Image.FromFile(#"E:\epsonScanner.png"));
you should add the image file (epsonScanner.png) to the c# project not just as solution item. after you added, right click on it and set compile as Embedded Resource in the properties window.
after that you retrieve the image from the assembly resources and not by file path, check here for full example on how to do it:
Load image from resources area of project in C#
You can do it in the way you described and answer is already there, but i think it may be easier and cleaner to add Resource item to your project and place images there.
How to create and use resources in .NET
http://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.80%29.aspx
You can use Bitmap.FromFile(string fileName) method.
try This.
List<Image> imageList = new List<Image>();
imageList.Add(Bitmap.FromFile(YourFilePath));
1)
I'm trying to set the thumbnail image that you see in explorer for a pdf.
At the moment, all the thumbnails are just the Abode PDF logo ... I'd like to set it to an image of my choice.
I have looked at the Win 7 shell pack api, and cannot find any way to set the image, only ways to extract the (default) image.
Can this even be done, or is it the adobe dll that sets the thumbnail??
2)
Also, related I think, is there a way to set the 'explorer star rating' from code?
Any pointers are appreciated!
For first one, there has to be shell extension that provides thumbnail image (see http://msdn.microsoft.com/en-us/library/bb774614.aspx and http://msdn.microsoft.com/en-us/library/aa969351.aspx)
Check this part of code project article series - "A tutorial on writing an extension to customize the icons displayed for a file type"