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!
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.
This might not be the best place. I don't have a problem with some code but rather looking for a code idea.
I want to be able to scan a file to a see if the file contains multiple files within, hidden or not.
For example: Take a movie with mp4 extension that movie has a video stream and an audio stream and/or srt file embedded. you can hide a zip file behind a jpeg file using standard cmd command line.
So I want to be able to scan a file for those multiple hidden files/streams inside. Is there such a way and can anyone guide me packages or code snippet or website?
So far I haven't found anything cause I don't know what too google for.
If I want to export my things i did inside of my app, I need to save two pictures and one text file. This is obviously annoying for the user, as he needs to move three files around.
If I put pictures into a word file and save it as a .docx, I can open it as a ZipFile and see that it actually just contains a lot of xml files and the pictures I added.
I want my app to do the same, create a .myappextension file that contains the other 3 files. But I have no idea how to achieve this. My output would be one string and two images, which I can all save on their own already. Before actually saving it I have an IRandomAccessStream.
In short, can I compile three IRandomAccessStreams into one file?
Just create a zip file, as long as System.IO.Compression namespace's classes are available for uwp.
System.IO namespaces for UWP apps
I have prevented my program from saving images downloaded as files. (They are saved in Image variables instead). However, my application is slowed down significantly because the PDFsharp libraries save the image files anyway before drawing them to the PDF document. This is done deep within a hierarchy of calls by its functions.
Is there a simple fix to get around this?
JPEG images are simply copied into the PDF file, all other image formats have to be converted to the PDF format. AFAIK PDFsharp does not save the images to the local file system, however they are saved into a memory stream during the conversion.
There is a simple fix to get around this: write a better conversion and submit it to the PDFsharp team.
I think PDFSharp always need to save first. It cannot handle byte image that will used to import an image. I recently encountered it when I also coded and used pdfsharp. My process is to save an image then import to code in pdfsharp. I have a part that I need to delete all temporary images.
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.