C# Wpf embed images at runtime - c#

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.

Related

View content of a .resource file

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.

Embed image in file

I'm trying to figure out a way to embed an image into a file in c#.
What I'm doing is to create a file with text inside of it (it uses XML) , and I want a quite big image embedded into it which I then can read from the file along with the XML.
But how do I do that?
I can't put an image file along with the file since the file may be used on different computers and I don't want 100's of image files laying around with the files.
Any ideas would be appreciated!

How to programmatically determine if an image file is georeferenced

I have a task to programamatically scan a folder for georeferenced images. There might be a lot of images, some quite large, and some not georeferenced. The spatial information can also be either embedded or in a world file.
How can I tell programmatically (C#/WPF/ESRI Runtime) if "C:\someFolder\file.x" is georeferenced?
Thanks
First check the file type to see if it's a format that supports built in georeferencing (GeoTiff, jp2, and MrSid). Other static image files would need some sort of companion file with the georeferencing information. So for each image file you'd want to look for a matching companion file.
If you add some info on what formats the images/world files are in it'll be easier to show you some sample code.

VSTO: Is there any way to retrieve the original file name of a picture (InlineShape) that has been inserted into a document?

I am developing a Word Addin. There is a piece of functionality within the Addin that is required to retireive the original location of a picture that has been inserted into a document.
It doesn't matter if the Image file no longer exists in the original directory. I will handle that in the code.
I think there is no way to do this. I did had the same requirement to find the file name from the image in the document. So I had to insert the image with the file name in its alternative text description to achieve this.
The question got me curious, so I tried the following: add an image to a word document, save it, zip it and start looking into the xml document. The media folder contains the image as embedded in word, which at that point has been renamed and "forgot" about its origin. On the other hand, document.xml does contain a lot of information about the image enclosed in the tag, and that includes the whole path to the original picture.
I don't know if the Open XML SDK gives you directly access to this (doubt it), but worst case you should be able to get to it by digging into the file, assuming you are working with an already-saved file.
If the file is not saved yet, I don't know.
I know this is years old, but the full path of an image that has been drag&dropped into a document is available in the AlternativeText field of the InlineShape. Unfortunately you cannot get this value when it has been inserted with Insert Picture. Images that have been pasted probably vary on whether this is available, e.g. if it was pasted from a document where it was drag&dropped it's probably there, but otherwise it isn't.
This info comes from targeting Word 2010 with VSTO.

How to generate thumbnail image for a PPTX file in C#?

Is there any way to use the OpenXML library to automatically create a thumbnail image for a PPTX file? I am building a small C# ASP.NET web application that is used to build PPTX files from a library of PPTX files. One of the requirements is to show a thumbnail image for each PPTX file in the library. I would like to automate this as the people that will be using the system don't know how to create screen shots.
Pptx file already have it, unziping the file you can find id. ;)
There's a commercial library available that can generate thumbnails of slides in presentations. So at least you know it's possible: http://www.aspose.com/docs/display/slidesnet/Creating+Slides+Thumbnail+Image

Categories

Resources