How to load .dds files into a picturebox? - c#

How do I load .dds texture files as an Image in C#? There's nothing useful on google that I could find.
The more information with samples you give me,the better it will be for me to understand it.

I had the same issue. Here is a good solution.
Source: http://www.mastropaolo.com/devildotnet/
Download Version 1.3 from that link (bottom of page)
Add the Devil.NET.dll as a reference to your application
Use the code that I have supplied below.
PictureBox1.Image = DevIL.DevIL.LoadBitmap(DDS_File_Path)
It's really that easy. We owe the DevIL .NET Wrapper creator a beer.

I think the short answer is that you don't. The documentation says that the supported formats are BMP, GIF, EXIG, JPG, PNG and TIFF.
Update: there seem to be a number of converters to be found through Google, that might help you out. Also, as Wayne suggests, look at XNA (if you didn't already). The Texture2D.FromFile method seems to handle the .dds files, but I never used it myself so I can't say if it is what you are looking for or not...

You might want to take a look at the Microsoft's XNA Game Studio SDK to load the textures in memory and possibly capture the images in a System.Drawing.Graphics usable way.

Related

How to convert Dicom to BMP image in C#?

I am currently using the evil-dicom library for opening DICOM files in c#. I am able to access the dicom file with:
var dcm = DICOMObject.Read('dicomfilename');
Then open up the pixel stream using
dcm.PixelStream
How can I save the pixelstream as a bmp image?
I never used the toolkit; but at least till Oct-2014, author of the toolkit was saying following:
Evil DICOM does not have any image classes to help with this. While that might seem strange to not include image tools in a DICOM library, it is not the original intent of the the library. Evil DICOM is more for manipulating and analysis of DICOM data. I used to have some image parts in the old library which I believe is still available on SourceForge. You can take a look, but the PixelData tag has the raw bits to put together an image. .NET has several classes that can help with that, but I don't have anything to write here in this post. If I get some time, I will write a blog post about how to do it on the website (rexcardan.com).
Source: GitHub
Apparently, it was not original intent of the toolkit to include imaging support in toolkit. Not sure if this is changed since then. Author was planning to write an article to achieve this through DotNet; not sure if he wrote any then after. Old library from SourceForge may create other issues as it might not have been updated since long.
You can find some example code here.

Dicom Images non square

I'm working with a set of DICOM images that are 512(columns) X 384(rows)
Is there a tool that would make the images 512X512? That is, filling the rows in this case to make it 512.
I've researched VTK with no luck.
Thanks!
Argh, you was almost there! In fact, VTK is not the proper tool for that. ITK is.
To be precise, VTK is for 3D visualization (that is, rendering of 3D objects), while ITK is specifically concerned for image processing.
So, using ITK, you could use a padding filter, here's a complete example from the official wiki, ready to be compiled and executed: http://public.kitware.com/pub/itk/Examples/src/Filtering/ImageGrid/PadAnImageWithAConstant/Documentation.html.
But, if you want to do the things in an easier way, I suggest MATLAB (ITK could be difficult to configure). In this case, this post could help: Padding an image in MATLAB.
Good luck!

Remove all metadata from common image formats?

I'm writing a service for a project that's going to handle our image processing. One such process is supposed to strip all metadata from the byte[] provided and return the same image as a byte[].
The method I'm currently working on involves always converting the image to a Bitmap, then converting it back to the original format and returning the data from a MemoryStream.
I haven't been able to test it yet but something tells me I'm going to experience some quality loss.
How can I remove all metadata from any image with a common format?
(bmp, gif, png, jpg, icon, tiff)
Not sure how I can narrow that down any further. Would be nice if I got some feedback regarding the downvotes.
For the lossless formats (except JPEG), your idea of loading it as a bitmap and re-saving is fine. Not sure if .NET natively supports TIFFs (I doubt it does).
For JPEGs, as you suggested there may be quality loss if you're re-compressing the file after decompressing it. For that, you might try the ExifLibrary and see if that has anything. If not, there are command line tools (like ImageMagick) that can strip metadata. (If you use ImageMagick, you're all set, since it supports all of your required formats. The command you want is convert -strip.)
For TIFFs, .NET has built-in TiffBitmapDecoder and ...Encoder classes you might be able to use; see here.
In short, using an external tool like ImageMagick is definitely the easiest solution. If you can't use an external tool, you're almost certainly going to need to special-case the formats that .NET doesn't support natively (and the lossy JPEG).
EDIT: I just read that ImageMagick doesn't do lossless stripping with JPEGs, sorry. I guess using the library I linked above, or some other JPEG library, is the best I can think of.

Decoding a PCX image in c# to display as bitmap

I have been trying to create a decoder that will stream through a pcx file and display it on screen as a bitmap. I have managed to get the information from the image header by using a binary reader, but I have now reached the part that seems to take the least amount of code, yet is also the hardest: creating an array of pixels.
I understand that i may need to add two embeddded for loops to process the data. I have looked at some C and C++ examples, but struggle to understand them. I also need to get the array to display it. if you need more code then I will share it.
I have searched far and wide and read the spec, but I don't know how to approach this. If anyone could help me, I would be very grateful.
Regards.
The .NET does not support PCX images natively, you have two choices. Read the specification and decode the image by yourself or use some library.
As suggested on bytes.com you can use Dot Net Fireball (a Free Image wrapper) and load the image like this:
Fireball.Drawing.FreeImage freeImage = new FreeImage(#"c:\test.pcx");
Image image = freeImage.GetBitmap();
http://magick.codeplex.com/
a nice wrapper working with http://imagemagick.codeplex.com/
easy to setup and get going, see samples at the bottom of the page here:
http://magick.codeplex.com/documentation

C# capture screen to small video files

Does someone knows how can I capture my computer screen to a video file? I need the file to be as small as possible. I'm using C#. Third party components also welcome.
TY
I think you are referring to creating a screen cast, if so this is the best I have used.
http://www.techsmith.com/camtasia.asp
It can produce many formats including FLV which can be configured to small file size.
You could take a look at ScapLib, and see if that suits your needs.
Directly capturing video from the desktop in .net does not seem to be a simple task. Here's an article from c-sharpcorner that might help you out: Link.

Categories

Resources