DevIL.NET
DEVIL.NET has been included in the main DEVIL distribution
Go to the DevIL image library website for the entire package. Here after you can find the older releases and, when a new one will get released, the newer ones.
WHAT IS DEVIL.NET ?
I’ve written a small wrap around the DevIL image library .
As for the .NET viewer, this is a “2 hour project” – that is a project I’ve written in 2 hours before going to sleep.. so no warranty is included!
NOTE : This project is intentionally minimalist. If you want a more complete wrapper over DevIL, have a look at the Tao.Framework.
It allows any .NET program (VB.NET, C#, etc) to open and save files in all formats supported by the DevIL library. Also it opens them as System.Drawing.Bitmap objects, so that it works optimally with existing code.
As now it supports loading in bmp cut dcx dds ico gif jpg lbm lif mdl pcd pcx pic png pnm psd psp raw sgi tga tif wal act pal and Doom graphics
And saving in : bmp dds jpg pcx png pnm raw sgi tga tif pal
Using it is simple.
As an example you can load/save a picture in a picturebox using (C# and VB.NET):
// C#
System.Drawing.Bitmap bmp = DevIL.DevIL.LoadBitmap(filename);
pictureBox1.Image = bmp;
‘ VB.NET
Dim bmp as System.Drawing.Bitmap
bmp = DevIL.DevIL.LoadBitmap(filename)
pictureBox1.Image = bmp
And you can save the picturebox image using :
// C#
System.Drawing.Bitmap bmp = (System.Drawing.Bitmap)pictureBox1.Image;
DevIL.DevIL.SaveBitmap(filename, bmp);
‘ VB.NET
Dim bmp as System.Drawing.Bitmap
bmp = pictureBox1.Image
DevIL.DevIL.SaveBitmap(filename)
LICENSE & VERSION
C++.NET (Managed C++) Source is included and released under a choice of BSD or LGPL license. You can contact me for additional licensing options if you need them. Binaries are provided in the package, compatible with every version of .NET Framework (from 1.0 to 3.0).
SAMPLES
You can download samples for DevIL.NET library. The sample program is a small utility which acts as a viewer and a converter of image files, written in both C# and VB.NET.
RELEASE NOTES
I’ve done many tries and it seems the stride in .NET framework for 32bit images is always 4*width. While this can be expected, effectively the stride could have any value. As now the code relies heavily on a predictable stride to optimize memory copies.. please report me any bug (marcoPLEASEDELTHIS@mastropaolo.com), especially if you think a different stride is in place.
UPDATES
- March 4th, 2007 : Release Version 1.3
- July 12th, 2005 : Fixed a minor bug in initialization, uploaded samples
- August 23th, 2005 : Release Version 1.1
- December 8th, 2004 : Release Version 1.0
VERSION 1.1 CHANGES
- Fixed a bad bug when loading non true color images (above all GIFs)
- Implemented a new LoadBitmapAndScale which allows for the bitmap to be scaled directly in DevIL.NET
- Started to implement some error handling…
- note: From version 1.1, DevIL.NET may require ILU.dll to be installed in addition to DevIL.DLL. Since having an additional DLL is always a burden, ILU.dll is loaded dinamically and it’s not required unless the scale/resize feature is used
VERSION 1.2 CHANGES
- Support for VS2005, .NET Framework 2.0 on x86 platforms
- NOTE : When using Devil.NET 1.2 on VS2005, remind to set your projects to use the x86 CPU. Otherwise the program may fail to run on x64 platforms.
VERSION 1.3 CHANGES
- Fixed the infamous vertical flip bug
- The v-flip can be done both in ILU code or .NET framework (depending on whether ILU.DLL has been loaded or not; you can load ILU.DLL either by loading an image with scale options or through the LoadILU method).
- A DevIL.NET2.DLL exists. This is a framework 2.0/3.0 only version which is just a bit smaller than the “every” framework version.
Download Library Version 1.3
Download Library Version 1.2
Download Library Version 1.1
Download Library Version 1.0
Download VC++ sources and project
Download C# and VB.NET Samples
View the source online
Have a problem:
When developing with VS 2005, .NET 2.0 and trying to use assembly DevIL.NET2 (DevIL version 1.3) have an exception during loading application:
System.IO.FileLoadException was unhandled
Message=”Could not load file or assembly ‘DevIL.NET2, Version=1.1.2619.31671, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)”
Source=”WindowsApplication1″
FileName=”DevIL.NET2, Version=1.1.2619.31671, Culture=neutral, PublicKeyToken=null”
FusionLog=”"
StackTrace:
at WindowsApplication1.Form1.button2_Click(Object sender, EventArgs e)
…
I was trying to put all DevIL DLL-files to system directories or referenced paths, but it changes nothing.
What could be done to fix it? Till using DevIL 1.1 fraework assembly.
I have the same problem ..
i use c++ create a windows form project compiler with /clr learn your dll programming method
[my project full source link]
http://www.box.net/shared/1klh60ipx8
when unicode string convert to wchar_t format
call ilLoadImage returns the error message “IL_COULD_NOT_OPEN_FILE” .
but i try your DEVIL.NET dll lib to load image is success
i don’t know what happen … can’t you help me …
download my project to try…please …
if (!s_bInitDone)
{
System::String^ s = Application::StartupPath + “\\DevIL.dll”;
if( System::IO::File::Exists(s) == false )
{
MessageBox::Show(“DevIL.dll not found”);
return nullptr;
}
ilInit();
s_bInitDone = true;
}
s_iImageID = GenerateSingleImage();
ilBindImage(s_iImageID);
wchar_t* wstring = sysstr2wstr(i_szFileName);
if( !ilLoadImage( wstring ) )
{
ChkAlarmMsg(GetErrorCode());
return nullptr;
}
HAve you tried rebuilding it from the sources ?
Downloaded the DevIl files, downloaded the Library Ver 1.3 files, downloaded the ImageView sample program.
I am using VB 2005 Express.
The ImageView sample program will not run from the Bin or Obj\Release folders. I get the following error,
************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly ‘DevIL.NET, Version=1.0.2019.10125, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.
File name: ‘DevIL.NET, Version=1.0.2019.10125, Culture=neutral, PublicKeyToken=null’
at ImageViewVb.frmImageView.mnuFileOpen_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItem.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Command.DispatchID(Int32 id)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I tried loading the sln or vbproj files into VB 2005, and I got two errors, both the same:
Name ‘DevIl’ is not declared, on lines 149 and 172.
How can I get the project to work? How can I get the sample program to work?
many thanks
Wibs
More Loader Lock info…
If I don’t have the DevIL.dll file present in the execution folder, I get the system file not found exception.
If I do have it present (along with DevIL.Net.dll which is part of my assembly), then I get the loader lock issue.
I’m getting the Loader Lock problem, too.
I rebuilt the ImageViewCs with VS2005 8.0.50727.42 under MS .Net Framework version 2.0.50727
As soon as I hit ‘Open’, I get the loader lock issue below…
Managed Debugging Assistant ‘LoaderLock’ has detected a problem in ‘D:\Projects\BreakAway\ThirdPartyLibs\DevILDotNet_1.3\ImageViewCs\bin\Debug\ImageViewCs.vshost.exe’.
Additional Information: DLL ‘D:\Projects\BreakAway\ThirdPartyLibs\DevILDotNet_1.3\ImageViewCs\bin\Debug\DevIL.NET.dll’ is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
However, if I continue after the ‘break / continue’ dialog shows up, everything seems to work fine.
Hi,
I’ve got same problem, at first message “Loader lock”, deactivate it (CTRL+D then E), but now I’ve got FileNotFoundException error, I have copied the dll to all pathes and the file exists
thx for help
Micha
Ciao
I was never able to reproduce the “LoaderLock was detected” thing
I’ll try to look into it.
Hi
Another problem I am seeing if if I run my app through Visual Studio, everything works fine, but if I copy it to another computer and try it, as soon as it calls into you library, the application crashes
Anyone else had this? Any ideas how I can get around this?
Thanks
Kevin
Hi
I am trying to use your wonderful DevIL.NET, but whenever I run my C# app in the debugger I get a:
LoaderLock was detected
Message: DLL ‘\bin\Debug\DevIL.NET.dll’ is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
This is making me sad
From reading the Microsoft docs it sounds like you might be doing bad things in your dll.
http://msdn2.microsoft.com/en-us/library/ms172219(vs.80).aspx
Any ideas how I can get around this?
Thanks
Kevin
>> Is there any chance to have the ability to run on x64 platforms?
At the moment, DevIL (the underlaying library) is not compatible (as far as I know, I might be wrong of course) with x64 platforms.
When it will be, code in DevIL.net will be checked and recompiled accordingly
In the meantime, you can of course create all the .net projects you want using 32bit framework.
Thanks! the library is great!
Is there any chance to have the ability to run on x64 platforms?
In Mono this will generate an error “need to implement compare 1b” at compile time.
Hi! Im using this great library but i have a problem saving a bmp as CPX. The CPX file generated is not a valid file. If you try to open’it with Photoshop u can see.
Can u help me?
hi.
thanks for your lib.
I am need work with your library in compact freamwork(WinCE 5.0)
Please help me.
It’s quite strange because if DevIL loads them fine, they should load fine even here.
Can you send me one of those tgas by email ?
marco __AT__ mastropaolo.com
Hey there, great work on this tool.
I seem to be having a problem loading many of my images into a c# PictureBox. For many of my tga files the PictureBox simply does not show the image, remains blank. It loads only some of them.
I also tried using your ImageViewCs sample program just to make sure I didn’t screw something up, and same thing. No errors are thrown, it’s just that the PictureBox becomes blank loaded these particular tga files. They have some kind of complex colors or something?
What’s weird is I can load them using DevIL, and then immediately save them to another location, and then I can open those saved tga files and the look fine. So I’m thinking it’s something with .NET’s PictureBox… got any ideas what I can do to fix this?
[...] ive code library that supports lots of different formats, including TGA. I also found this link to a managed wrapper that will load image files with DevIL and put them into .NETs Bitmap object. Usi [...]
Well, to be true the “standard” is usually to start top-left (the same arrangement of all graphics buffers in hardware).
The bottom-left (which is cartesian-correct btw) is a legacy of IBM OS/2 which “required” its formats (DIB aka BMP) to be cartesian correct on the 1st quadrant.
BTW, the DDS was invented by S3 Graphics for their Savage chipset (it was infact known as S3C) and is very hardware dependent (so no surprise it starts topleft).
TGAs, on the other hand, could start both top-left or bottom-left (or even top-right and bottom-right), there is a bit on the 18th byte of the file header for that.
So, probably, Devil.NET is bugged (or, well, probably the blame should be on DevIL itself and not on the port) in that it does not respect the flip bit in some image formats like TGA and TIFFs. In the future I will try to correct this at least on TGAs by an optional check for byte18 flip. Today I sadly still have no time :’( :’( :’(
[edit]
Now that the bug is fixed, I know I was to blame
There is an “origin” attribute in DevIL and a flip is needed if you assume (like usually it is) an upper-left origin.
DevIL.Net is a great idea – I’ve been using it for a while now to load a TGA in to a picture box. It’s a little large just for that task, but that’s because of DevIL itself. The only thing this is missing (for me) is MipMap generation when you save as DDS
At the moment I’m trying to convert TGAs to DDS files using DirectX, but the additional dependancies are going to run at about 1.5MB!
As for people having the upside-down TGA issues – you wouldn’t happen to be converting from DDS, would you? Microsoft, in all it’s typical ‘standards’-ness, has DDS images starting at the top left instead of the bottom left like most images, hence why DDS images are generally ‘upside down’ compared to their relevant TGA etc. It’s a minor annoyance, but such is Microsoft.
Now to read up on the BSD license and see what it means I can do in relation to modifying the code to support MipMap generation
go here tags won’t show
http://msdn.microsoft.com/vstudio/express/support/issues/
the tags got removed from my reply the line should have tags I hope his post will show them
“x86″
When useing this on a x64 platform useing vb express 2005 you will need this solution to get this to work
Express Edition:
The VB and C# Express products to not expose the Target property inside the development environment. You will need to carefully modify the project file using a text or XML editor.
Close the project and/or solution
Select Open File from the File menu
Navigate to the project directory, and highlight the project file
Press the Open button, the project file should open in the XML editor
Locate the first section and add the following line: x86
Save the project file
Reopen the project and/or solution using Open Project/Solution from the File menu
Continue with development, debugging, and testing
Is there any chance of there being some kind of parameter access for the image settings? It’d be great to be able to enable and disable things like the compression on an SGI or TIFF image through DevIL.
Seems that when I use your ImageViewCs project to load SGI images, they are loaded upside down. I can tell you that all the SGI files I’ve used have RLE compression on them, which could be the reason for this.
Oh well, I wrote a method to draw Doom graphics into a bitmap, so I should be able to use this to convert from Doom to other formats.
Chris, I will do the possible. But for a number of reasons my free time is now something like less than a minute a week
This is awesome, however, any news on TGA files being inverted? I would like to get this fixed. Thanks
It seems it cannot find devil.dll in the natural dll searching path. Try to copy it in the directory of your executable, in a directory in your %PATH% or in windows\system32.
Another reason could be you have Windows x64 and working with Any Cpu target. In that case, force x86
Hi, i am using VS 2005 and i have referenced the lib. but i get this error.
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Any ideas?
You can do a simple for loop yourself (load n images in an std::vector and then show them in sequence), but that would hardly be memory efficient and quick. Another chance you have is using some SDK specifically created for movies. Apple Quicktime SDK is quite hard to use but offers an ActiveX control which is actually easy to use and powerful albeit limited in some functionality
I don’t know anything about DirectShow but it might be a better integrated solution. Anyway, on http://developer.apple.com/quicktime/activexcontrol.html you can find an example of the Quicktime ActiveX for C# and VB.NET (you can either port the code to C++/CLI or create a DLL in C# and reference it from C++).
Happy coding
HI again,
Thanks- now it works fine!
I’m kinda new to VC++ and .Net programming- so thanks again.
The same problem as justin0000- Targa’s are upside down (but not, it would seem rotated through 180 degress!).
Just thought I’d report it.
Also, is there a way with DevIL to load a sequence of images and manipulate them and play them back?
To Deet Thought :
It depends if you are working on a .NET project, a native project or a mixed mode project. If you are working on a .NET project, simply right click on the project, select “References” then Browse and browse to the devil.net dll library. If you are working on a mixed mode project, use #import and import the dll file.
Of course if you are working on a pure native project you should better use the original devil library and not the .NET one
To justin0000 :
For doom graphics, I have never tested them, as soon as I have the time (around in the first days of March
) I will do some tests, sorry
The mirrored image is a known issue (even if it usually happens top-down). It seems to be a problem with the original devil library but it might be my fault, it’s in the “things to investigate” list
I am writing a tool to edit Doom .WAD files and was thinking of using this to display graphic lumps. I built the test app in VB.NET with version 1.1 and I have a couple problems:
1. I can’t get doom graphics to show up when loaded from either the raw format of in wad format.
2. Sometimes the image is mirrored
What can I do about this? Here is a like to the program I’m working on BTW : http://mysite.verizon.net/resor22h/pages/zWad.htm
HI all
Just a question- I’m using VC++2005 Express Edition (i’m gonna get the std ed soon…), and I can’t get this thing to work at all.
Do I not need a Devil.net.h file to #include? And a .lib file?
If I just #include Devil.Net.dll, I get a whole stream of errors, and I’ve tried to build the .dll, but VC++ won’t let me (I am using version 1.2), it brings up bizarre errors.
Does this work with VC++.Net, or only C# and VB? (It says any .Net language…)?
Any help would be great!
DT.
The Tao Framework ( http://www.mono-project.com/Tao ) implements P/Invoke .NET bindings to the DevIL library for DevIL compability in .NET 1.1, .NET 2.0 and Mono (Tao.DevIl).
[...] Devil.NET Version 1.2 I’ve released a version 1.2 of Devil.NET. It works with .NET framework 2.0, under Visual Studio 2005. Please, note that i [...]
I think it’s the DevIL library.. most probably it doesn’t support an alpha channel on TIFF images.
You can try using DevIL to read the DDS which is quite a complex format and then create the TIFF manually (the uncompressed 32bit TIFF is quite a simple format, mainly a direct dump of picture data after the header, like for uncompressed TGAs
)
Sorry for late approval and answer, as you can read on the main page.
Hey, the work youve done with this is brilliant. Saved alot of time, but I have a problem. I’m trying to use this to convert DDS to TIFF, but when I do it with images with alpha channels, it makes the alpha area into a transparency and removes the colour data, but it converts to a TGA file perfectly. I wasnt sure whether this was something to do with your wrapper or the DevIL library, so I thought i’d ask here first.
Any way to change this?
I also have the same problem with framework 2.0. Please reply me if you have tested it in VS2005.
Thanks
I’ve just installed VS 2005 the other day. As soon as I can I’ll try that
It’s the new, stricter debugger.
For now I can do this in the ide:
Debug –> Exceptions –> Managed Debugging Assistants –> Uncheck Loader Lock
and it will compile.
If I try and use it with the 2.0 framework I get this:
“DLL ‘C:\Documents and Settings\Mr. Spoons\Local Settings\Application Data\Temporary Projects\tga\bin\Debug\DevIL.NET.dll’ is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.”
eek!
Well, actually I have this feeling that all this is some bug in my library
I will check the code asap
Finally, I created a new .NET managed c++ class library project, pasted your code in, made it compile, and voila! Not it works fine in Debug configuration.
BUT: In the Release configuration, I had to switch the Debuggable Assembly option ( Properties / Linker / Debugging / Debuggable Assembly ) to “Runtime tracking and disable optimizations (/ASSEMBLYDEBUG)” for this to work. I don’t understand why, but that did the trick…
I hate Visual Studio.
I just got this weird problem with your LoadBitmapAndScale function :
I added DevIL.NET project to my solution, then added it’s reference in my other project. Everything works fine in DEBUG mode, but as soon as I START WITHOUT DEBUGGING or by clicking on the executable, I catch this Exception:
“Object reference not set to an instance of an object”
And the stacktrace reveals that it’s the pBmp object that has been deallocated by the garbage collector before the call to UnlockBits funtion.
I’m totally new to this managed c++ code and I don’t know what to do. I tried adding/removing some __gc keywords with no success.
Please help!
Thanks,
Etienne.
[...] le/resize feature is used Also the Visual C++ project is available for download now. Go get it here!
update:I’ve found a small bug in the LoadAndScale function (the filter setting [...]
I will add the sln/vcproj to the sources as soon as I find the problem with your gif
Edit : the problem was found and the fix will come in a few days.
Grazie mille, Marco
One litte problem, loading gif images width you library and sample is unsuccesfull. Can you do some thing?
It seems that any gif image is loaded, but i also include an url
to a simple gif so you can try with the same image I tried.
http://research.lumeta.com/ches/map/gallery/i-isp-ss.gif
Thanks a lot!
By Davide
Beatiful porting!
How about publishing also the .NET project used porting DevIL Library?
Hi Davide
[...] library (most notably it can open PSD, PSP, TGA and DDS). Also it is very simple to use. Check it out here! This entry was posted on T [...]