summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatěj Týč <bubla@users.sourceforge.net>2009-02-15 22:02:15 +0000
committerMatěj Týč <bubla@users.sourceforge.net>2009-02-15 22:02:15 +0000
commit7a10d4df8a9596f5d753cbc491d105aee63918fb (patch)
tree30ac783b636dbc76ccacbb0a11f894d09384a306
parent2f9630e946b829acf67fdcd3ba775e3f90d42695 (diff)
downloaddevil-7a10d4df8a9596f5d753cbc491d105aee63918fb.tar.gz
added ilur, improved documentation, slightly modified the examples build system
-rw-r--r--DevIL/ChangeLog7
-rw-r--r--DevIL/Makefile.am6
-rw-r--r--DevIL/TODO1
-rw-r--r--DevIL/bin/Makefile.am104
-rw-r--r--DevIL/configure.ac3
-rw-r--r--DevIL/data/DevIL.pc.in10
-rw-r--r--DevIL/devil.pc12
-rw-r--r--DevIL/docs/DevIL_manual.texi133
-rw-r--r--DevIL/examples/Makefile.am88
-rw-r--r--DevIL/src-IL/Makefile.am6
-rw-r--r--DevIL/src-ILU/Makefile.am6
-rw-r--r--DevIL/src-ILU/ilur/ilur.c508
-rw-r--r--DevIL/src-ILUT/Makefile.am6
13 files changed, 706 insertions, 184 deletions
diff --git a/DevIL/ChangeLog b/DevIL/ChangeLog
index c1af540c..38c37b51 100644
--- a/DevIL/ChangeLog
+++ b/DevIL/ChangeLog
@@ -440,3 +440,10 @@ Up to 2009-01-02 (since 1.7.5 release) Denton Woods <doomwiz@users.sf.net>
* EXR files can now be loaded as file streams and lumps.
* Changed iNeuQuant to take number of colors in palette.
* Compiled MNG support back in.
+
+2009-02-15 Matěj Týč <bubla@users.sf.net>
+ * src-ILU/ilur: Added the ilur - commandline ILU frontend
+ * bin, examples/Makefile.am: Moved examples's Makefile.am to bin
+ directory. Added ilur to it.
+ * docs/DevIL_manual.texi: Made slight syntax corrections, fixed the
+ sample program and added functions index
diff --git a/DevIL/Makefile.am b/DevIL/Makefile.am
index 825b5308..e39ea0f0 100644
--- a/DevIL/Makefile.am
+++ b/DevIL/Makefile.am
@@ -1,10 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = lib docs test data
-
-if BUILD_EXAMPLES
-SUBDIRS += examples
-endif #BUILD_EXAMPLES
+SUBDIRS = lib bin docs test data
#SUBDIRS = src-IL src-ILU src-ILUT include
#DIST_SUBDIRS = src-IL src-ILU src-ILUT include
diff --git a/DevIL/TODO b/DevIL/TODO
index 37eca64c..bc76ca03 100644
--- a/DevIL/TODO
+++ b/DevIL/TODO
@@ -240,7 +240,6 @@ For 1.7.0
Matej:
- Make a test suite (IL ok, now ILU tests)
-- Make a simple command-line ILU frontend (iller)
- Make DevIL parts that require external libraries modular
- Make the library include files correct (fix the config.h problem)
- Look into TIFF loading (support for images with greater bpp should be possible)
diff --git a/DevIL/bin/Makefile.am b/DevIL/bin/Makefile.am
new file mode 100644
index 00000000..63f3a258
--- /dev/null
+++ b/DevIL/bin/Makefile.am
@@ -0,0 +1,104 @@
+all_include = $(srcdir)/../include
+devildir = @datadir@/devil
+examplesdir = $(devildir)/examples
+example_srcdir = ../examples
+
+AM_CPPFLAGS = -I $(all_include)
+
+il_library = ../lib/libIL.la
+ilu_library = ../lib/libILU.la
+ilut_library = ../lib/libILUT.la
+
+EXTRA_DIST =
+
+bin_PROGRAMS =
+examples_PROGRAMS =
+
+if BUILD_ILU
+bin_PROGRAMS += ilur
+endif #BUILD_ILU
+
+ilur_SOURCES = ../src-ILU/ilur/ilur.c
+ilur_LDADD = $(ilu_library)
+
+if BUILD_EXAMPLES
+
+examples_PROGRAMS += IL_override IL_read IL_simple
+
+if BUILD_ILUT
+
+examples_PROGRAMS += ILUT_cpp_wrapper
+
+if USE_ALLEGRO
+examples_PROGRAMS += ILUT_allegro
+endif #USE_ALLEGRO
+
+if USE_DIRECTX
+examples_PROGRAMS += ILUT_d3d ILUT_windows
+endif #USE_DIRECTX
+
+if USE_SDL
+examples_PROGRAMS += ILUT_sdl
+endif #USE_SDL
+
+if USE_W32
+examples_PROGRAMS += ILUT_animation
+endif #USE_W32
+
+if HAVE_GLUT
+if USE_X11
+examples_PROGRAMS += ILUT_gl ILUT_volume
+endif #USE_X11
+endif #HAVE_GLUT
+
+endif #BUILD_ILUT
+
+endif #BUILD_EXAMPLES
+
+ILUT_allegro_SOURCES = $(example_srcdir)/allegro_example/allegtest.c
+ILUT_allegro_CFLAGS = $(alleg_CFLAGS)
+ILUT_allegro_LDFLAGS = $(ilut_library)
+
+ILUT_sdl_SOURCES = $(example_srcdir)/sdl_example/sdl_test.c
+ILUT_sdl_CFLAGS = $(SDL_CFLAGS)
+ILUT_sdl_LDFLAGS = $(ilut_library)
+
+ILUT_animation_SOURCES = $(example_srcdir)/animation_example/AnimTest.cpp $(example_srcdir)/animation_example/resource.h $(example_srcdir)/animation_example/AnimTest.rc
+#ILUT_animation_CFLAGS =
+ILUT_animation_LDFLAGS = $(ilut_library)
+EXTRA_DIST += $(example_srcdir)/animation_example/OpenIL.ico
+
+ILUT_d3d_SOURCES = $(example_srcdir)/direct3d_example/d3dtest.cpp
+ILUT_d3d_LDFLAGS = $(ilut_library)
+
+ILUT_cpp_wrapper_SOURCES = $(example_srcdir)/cpp_wrapper_example/il_wrap.cpp
+ILUT_cpp_wrapper_LDFLAGS = $(ilut_library)
+
+IL_override_SOURCES = $(example_srcdir)/override_example/iotest.c
+
+ILUT_gl_SOURCES = $(example_srcdir)/opengl_example/gltest.c $(example_srcdir)/opengl_example/gltest.h
+ILUT_gl_LDFLAGS = $(ilut_library)
+
+IL_read_SOURCES = $(example_srcdir)/register_read_example/readtest.c
+
+IL_simple_SOURCES = $(example_srcdir)/simple_example/simple.c
+
+if BUILD_ILU
+IL_override_LDFLAGS = $(ilu_library)
+IL_read_LDFLAGS = $(ilu_library)
+IL_simple_LDFLAGS = $(ilu_library)
+else #not BUILD_ILU
+IL_override_LDFLAGS = $(il_library)
+IL_read_LDFLAGS = $(il_library)
+IL_simple_LDFLAGS = $(il_library)
+endif #not BUILD_ILU
+
+ILUT_volume_SOURCES = $(example_srcdir)/volume_example/3dtest.h $(example_srcdir)/volume_example/3dtest.c
+ILUT_volume_LDFLAGS = $(ilut_library)
+
+ILUT_windows_SOURCES = $(example_srcdir)/windows_example/BatchConv.cpp $(example_srcdir)/windows_example/WindowsTest.cpp $(example_srcdir)/windows_example/WindowsTest.h $(example_srcdir)/windows_example/resource.h $(example_srcdir)/windows_example/WindowsTest.rc
+ILUT_windows_LDFLAGS = $(ilut_library)
+EXTRA_DIST += $(example_srcdir)/windows_example/resources/OpenIL.ico
+
+.rc.o:
+ $(RC) $(RCFLAGS) $< -o $@
diff --git a/DevIL/configure.ac b/DevIL/configure.ac
index 27be946d..46effeff 100644
--- a/DevIL/configure.ac
+++ b/DevIL/configure.ac
@@ -404,11 +404,10 @@ dnl note: keep the list on one line separated by single spaces
dnl (otherwise MSYS compilation breaks)
AC_CONFIG_FILES([Makefile
lib/Makefile
+ bin/Makefile
test/Makefile
- examples/Makefile
docs/Makefile
data/Makefile
- data/DevIL.pc
data/IL.pc data/ILU.pc data/ILUT.pc
test/format_test/format_checks.sh])
dnl projects/Makefile])
diff --git a/DevIL/data/DevIL.pc.in b/DevIL/data/DevIL.pc.in
deleted file mode 100644
index 4b6f9c58..00000000
--- a/DevIL/data/DevIL.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-
-Name: DevIL
-Description: Developer's Image Library - monolithic build (not sure what may be included)
-Version: @VERSION@
-URL: http://openil.sourceforge.net
-Libs: -L@libdir@ -lDevIL
-Libs.private: @IL_LIBS@ @ILU_LIBS@
-Cflags: -I@includedir@ @IL_CFLAGS@
diff --git a/DevIL/devil.pc b/DevIL/devil.pc
deleted file mode 100644
index 4726313e..00000000
--- a/DevIL/devil.pc
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=/usr
-exec_prefix=/usr
-libdir=/usr/lib
-includedir=/usr/include
-
-Name: Developers Image Library
-Description: An image library.
-Requires:
-Version: 1.7.5
-Libs: -L${libdir} -Wl,--export-dynamic -lalleg-4.2.2 -lalleg_unsharable
--lIL -lILU -lILUT
-Cflags: -I${includedir}
diff --git a/DevIL/docs/DevIL_manual.texi b/DevIL/docs/DevIL_manual.texi
index e5fc7358..97f5b8e7 100644
--- a/DevIL/docs/DevIL_manual.texi
+++ b/DevIL/docs/DevIL_manual.texi
@@ -35,10 +35,9 @@ This is a manual describing IL part of DevIL -- handling images.
* Index:: Complete index.
@end menu
-@node Introduction
+@anchor{Introduction}
@chapter Introduction
@section General introduction
-@cindex index entry, another
Developer's Image Library was previously called OpenIL, but due to trademark issues, OpenIL is now known as DevIL.
@@ -232,7 +231,7 @@ Note: Those examples are actually linked against @code{ILU}, but this is only be
@item OpenGL
@end itemize
-@node Basic usage
+@anchor{Basic usage}
@chapter Basic usage
You must initialize DevIL, or it will most certainly crash.
You need to initialize each library (IL, ILU, and ILUT) separately.
@@ -241,6 +240,7 @@ For example, ILUT is dependent on ILU and IL, so you have to initialize IL and I
@section Initializing DevIL
+@findex ilInit
@subsection IL Initialization
Simply call the @code{ilInit} function with no parameters:
@@ -249,6 +249,7 @@ Simply call the @code{ilInit} function with no parameters:
ilInit();
@end example
+@findex iluInit
@subsection ILU Initialization
Call the @code{iluInit} function with no parameters:
@@ -285,6 +286,7 @@ ILvoid ilBindImage(ILuint Image);
ILvoid ilDeleteImages(ILsizei Num, ILuint *Images);
@end example
+@findex ilGenImages
@subsection Generating Image Names
Use @code{ilGenImages} to generate a set of image names. @code{ilGenImages} accepts an array of ILuint to receive the generated image names.
There are no guarantees about the order of the generated image names or any other predictable behaviour like this.
@@ -292,6 +294,7 @@ If @code{ilDeleteImages} is called on an image name, @code{ilGenImages} will ret
This conserves memory and is generally quick.
The only guarantee is that each member of the Images parameter (up to Num number of them) will have a new, unique value.
+@findex ilBindImage
@subsection Binding Image Names
@code{ilBindImage} binds the current image to the image described by the image name in Image.
DevIL reserves the number zero for the default base image.
@@ -301,6 +304,7 @@ An image must always be bound before you call any functions that operate on imag
When DevIL creates a new image, the image has the default properties of with a bit depth of 8.
DevIL creates a new image when you call @code{ilBindImage} with an image name that has not been generated by @code{ilGenImages} or when you call @code{ilGenImages} specifically.
+@findex ilDeleteImages
@subsection Deleting Image Names
@code{ilDeleteImages} is the exact opposite of @code{ilGenImages} and even accepts the exact same parameters. @code{ilDeleteImages} deletes image names to free memory for subsequent operations.
You should always call @code{ilDeleteImages} on images that are not in use anymore.
@@ -322,6 +326,7 @@ ILboolean ilLoadF(ILenum Type, ILHANDLE File);
ILboolean ilLoadL(ILenum Type, ILvoid *Lump, ILuint Size);
@end example
+@findex ilLoadImage
@subsection Loading from Files -- @code{ilLoadImage}
@code{ilLoadImage} is the main DevIL loading function.
All you do is pass @code{ilLoadImage} the filename of the image you wish to load. @code{ilLoadImage} takes care of the rest. @code{ilLoadImage} allows users to transparently load several different image formats uniformly.
@@ -340,6 +345,7 @@ If a valid image header is found, @code{ilLoadImage} passes control to the appro
@item Returns @code{IL_FALSE}.
@end enumerate
+@findex ilLoad
@subsection Loading from Files -- @code{ilLoad}
DevIL's other file loading function is @code{ilLoad}. @code{ilLoad} is similar to @code{ilLoadImage} in many respects but different in other ways. @code{ilLoad} accepts two parameters: the type of image and the filename of the image.
@@ -351,6 +357,7 @@ Only use this if you know what type of images you will be loading and want to by
If @code{IL_TYPE_UNKNOWN} is specified for Type, @code{ilLoad} behaves exactly like @code{ilLoadImage}.
Refer to the previous section for detailed behaviour of these two functions.
+@findex ilLoadF
@subsection Loading from File Streams -- @code{ilLoadF}
DevIL's file stream loading function is @code{ilLoadF}.
@code{ilLoadF} is exactly equivalent to @code{ilLoad}, but instead of accepting a const char pointer, @code{ilLoadF} accepts an @code{ILHANDLE}.
@@ -359,6 +366,7 @@ Under normal circumstances, File will be a @code{FILE} struct pointer defined in
@xref{registration}, for instructions on how to use your own file handling functions and file handles.
+@findex ilLoadL
@subsection Loading from Memory Lumps -- @code{ilLoadL}
DevIL's file handling is abstracted to allow loading images from memory called ``lumps''. @code{ilLoadL} handles loading from lumps.
You must specify a valid type as the first parameter and the lump as the second parameter.
@@ -379,13 +387,16 @@ ILuint ilSaveL(ILenum Type, ILvoid *Lump, ILuint Size);
DevIL's saving functions are identical to the loading functions, despite the fact that they save images instead of load images.
-Typically, the user does not know exactly how large the output image will be. If you pass NULL for @code{Lump} and 0 for @code{Size} to @code{ilSaveL}, @code{ilSaveL} will return the buffer size needed to save an image of @code{Type}. When a buffer is passed for @code{Lump}, the return value is how many bytes were written to the buffer.
+Typically, the user does not know exactly how large the output image will be.
+If you pass NULL for @code{Lump} and 0 for @code{Size} to @code{ilSaveL}, @code{ilSaveL} will return the buffer size needed to save an image of @code{Type}.
+When a buffer is passed for @code{Lump}, the return value is how many bytes were written to the buffer.
Note that not all formats that have load support have also save support (@pxref{file_formats})
-@node Image Management
+@anchor{Image Management}
@chapter Image Management
+@findex ilTexImage
@anchor{ilTexImage reference}
@section Defining Images
@code{ilTexImage} is used to give the current bound image new attributes that you specify.
@@ -426,6 +437,7 @@ ILuint ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff,
ILenum Type, ILvoid * Data);
@end example
+@findex ilGetData
@subsection The Quick Method
Use @code{ilGetData} to get a direct pointer to the current bound image's data pointer.
Do not ever try to delete this pointer that is returned.
@@ -433,6 +445,7 @@ To get information about the image data, use @code{ilGetInteger}.
@code{ilGetData} will return NULL and set an error of @code{IL_ILLEGAL_OPERATION} if there is no currently bound image.
+@findex ilCopyPixels
@subsection The Flexible Method
Use @code{ilCopyPixels} to get a portion of the current bound image's data or to get the current image's data with in a different format / type.
DevIL takes care of all conversions automatically for you to give you the image data in the format or type that you need.
@@ -464,6 +477,7 @@ ILvoid ilSetPixels(ILuint XOff, ILuint YOff, ILuint ZOff,
ILenum Type, ILvoid *Data);
@end example
+@findex ilSetData
@subsection The Quick Method
Use @code{ilSetData} to set the image data directly.
DevIL will copy the data provided in the Data parameter to the image’s data, so you need not worry about DevIL trying to delete your pointer later on.
@@ -473,8 +487,9 @@ You must provide image data in the exact same format, type, width, height, depth
@code{ilSetData} will return @code{IL_FALSE} and set an error of @code{IL_INVALID_PARAM} if Data is @code{NULL}.
+@findex ilSetPixels
@subsection The Flexible Method
-Use ilSetPixels to set a portion of the current bound image’s data or to set the current image’s data with data of a different format / type.
+Use @code{ilSetPixels} to set a portion of the current bound image’s data or to set the current image’s data with data of a different format / type.
Specify the data block, where you want to put it and what kind of data it is, and DevIL takes care of all conversions automatically for you.
The data block can range from a single line to a rectangle, all the way to a cube.
@@ -499,12 +514,14 @@ ILboolean ilBlit(ILuint Src, ILint DestX, ILint DestY, ILint DestZ,
ILuint Height, ILuint Depth);
@end example
+@findex ilCopyImage
@subsection Direct Copying
Use @code{ilCopyImage} to create a copy of an image. @code{ilCopyImage} will copy the image specified by the image name in Src to the currently bound image. @code{ilCopyImage} can be useful when you want to apply an effect to an image but want to preserve the original.
The image bound before calling @code{ilCopyImage} will still be bound after @code{ilCopyImage} exits.
If you specify an image name in Src that has not been generated by @code{ilGenImages} or @code{ilBindImage}, @code{ilCopyImage} will set the @code{IL_INVALID_PARAM} error and return @code{IL_FALSE}.
+@findex ilBlit
@subsection Blitting
@code{ilBlit} copies a portion of an image over to another image.
This is similar to blitting performed in graphics libraries, such as StretchBlt in the Windows API.
@@ -524,6 +541,7 @@ A description of the various @code{ilBlit} parameters follows:
@item @code{Depth}: How many pixels to copy in the z direction of the source image.
@end itemize
+@findex ilOverlay
@subsection Overlaying
@code{ilOverlay} is essentially the same as @code{ilBlit}, but it copies the entire image over, instead of just a portion of the image. @code{ilOverlay} is more of a convenience function, since you can obtain the same results by calling @code{ilBlit} with SrcX, SrcY and SrcZ set to zero, with the Width, Height and Depth parameters set to the source image's height, width and depth, respectively. @code{ilOverlay} is missing six parameters that @code{ilBlit} has:
@@ -583,6 +601,7 @@ ILenum ilGetError(ILvoid);
const char* iluErrorString(ILenum Error);
@end example
+@findex ilGetError
@section Error Detection
Problems can always occur in any software application, and DevIL is no different.
DevIL keeps track of all non-fatal errors that have occurred during its operation.
@@ -592,6 +611,7 @@ Most errors reported are not harmful, and DevIL operation can continue, except f
@xref{error_codes}, for error codes that can be returned by @code{ilGetError}.
+@findex iluErrorString
@section Error Strings
@code{iluErrorString} returns a human readable error string from any error that @code{ilGetError} can return.
This is useful for when you want to display what kind of error happened to the user.
@@ -616,8 +636,9 @@ This section will give a comparison of the utility functions against the below f
@center @image{images/sample_original,5cm}
@center @emph{Original, unmodified image}
+@findex iluAlienify
@section Alienifying
-iluAlienify is a filter I created purely by accident, when I was attempting to write colour matrix code.
+@code{iluAlienify} is a filter I created purely by accident, when I was attempting to write colour matrix code.
The effect @code{iluAlienify} gives to an image is a green and purple tint.
On images with humans in them, @code{iluAlienify} generally makes the people look green, hence the fabricated term ``alienify''. @code{iluAlienify} does not accept any parameters.
The figure below illustrates this effect on the DevIL logo.
@@ -625,11 +646,13 @@ The figure below illustrates this effect on the DevIL logo.
@center @image{images/sample_alienified,5cm}
@center @emph{``Alienified'' image}
+@findex iluBlurAverage
+@findex iluBlurGaussian
@section Blurring
ILU has two blurring functions – @code{iluBlurAverage} and @code{iluBlurGaussian}. Blurring can be used for a simple motion blur effect or something as sophisticated as concealing the identity of a person in an image.
Both of these functions use a convolution filter and multiple iterations to blur an image.
Gaussian blurs look more natural than averaging blurs, because the center pixel in the convolution filter ``weighs'' more.
-For an in-depth description of convolution filters, see the excellent @emph{Elementary Digital Filtering} article at http://www.gamedev.net/reference/programming/features/edf/.
+For an in-depth description of convolution filters, see the excellent @emph{Elementary Digital Filtering} article at @url{http://www.gamedev.net/reference/programming/features/edf/,gamedev.net}.
@code{iluBlurAverage} and @code{iluBlurGaussian} are functionally equivalent.
Both functions accept a single parameter.
@@ -642,6 +665,7 @@ Increase the number of iterations to increase the blurriness of an image.
@center @image{images/sample_blur_gauss,5cm}
@center @emph{Gaussian blurred with 10 iterations applied}
+@findex iluContrast
@section Contrast
ILU can apply more colour contrast to your image by brightening the lights and darkening the darks via @code{iluContrast}. This effect can make a dull image livelier and ``stand out'' more.
@@ -657,6 +681,7 @@ Values outside of the 0.0 to 1.7 range will give undefined results. -0.5 to 0.0
@center @image{images/sample_contrast_16,5cm}
@center @emph{Contrast of 1.7}
+@findex iluEqualize
@section Equalization
Sometimes it may be useful to equalize an image – that is, bring the extreme colour values to a median point. @code{iluEqualize} darkens the bright colours and lightens the dark colours, reducing the contrast in an image or ``equalizing'' it.
The below figure shows the results of applying @code{iluEqualize} to the DevIL image.
@@ -664,6 +689,7 @@ The below figure shows the results of applying @code{iluEqualize} to the DevIL i
@center @image{images/sample_equalized,5cm}
@center @emph{Equalized image}
+@findex iluGammaCorrect
@section Gamma Correction
@code{iluGammaCorrect} applies gamma correction to an image using an exponential curve.
The single parameter @code{iluGammaCorrect} accepts is the gamma correction factor you wish to use.
@@ -677,14 +703,16 @@ Anything above 1.0 brightens the image, but values too large may saturate the im
@c @center @image{images/sample_gamma_20,5cm}
@c @center @emph{Result of gamma correction of 2.0}
+@findex iluNegative
@section Negativity
@code{iluNegative} is a very basic function that inverts every pixel's colour in an image.
For example, pure white becomes pure black, and vice-versa.
-The resulting colour of a pixel can be determined by this formula: new_colour = ~old_colour (where the tilde is the negation of the set of bits). @code{iluNegative} does not accept any parameters and is reversible by calling it again.
+The resulting colour of a pixel can be determined by this formula: @code{new_colour = ~old_colour} (where the tilde is the negation of the set of bits). @code{iluNegative} does not accept any parameters and is reversible by calling it again.
@c @center @image{images/sample_negative,5cm}
@c @center @emph{@code{iluNegative} example}
+@findex iluNoisify
@section Noise
ILU can add ``random'' noise to any image to make it appear noisy.
The function, @code{iluNoisify}, simply uses the standard libc @code{rand} function after initializing it with a seed to @code{srand}. If your program depends on a different seed to @code{rand}, reset it after calling @code{iluNoisify}. The seed ILU uses is the standard @code{time(NULL)} call.
@@ -702,6 +730,7 @@ Colours change by both negative and positive values, so some pixels may be darke
@c @item @emph{Result of @code{iluNoisify} with a 0.50 tolerance} @tab @tab @emph{Result of @code{iluNoisify} with a 1.0 tolerance}
@c @end multitable
+@findex iluPixelize
@section Pixelization
@code{iluPixelize} creates pixelized images by averaging the colour values of blocks of pixels.
The single parameter passed to @code{iluPixelize} determines the size of these square blocks.
@@ -715,6 +744,7 @@ Values less than 1 generate an error.
@c @center @image{images/manipulation/pixelize,5cm}
@c @center @emph{Pixelization of 5 pixels across}
+@findex iluSharpen
@section Sharpening
Sharpening sharply defines the outlines in an image. @code{iluSharpen} performs this sharpening effect on an image. @code{iluSharpen} accepts two parameters: the sharpening factor and the number of iterations to perform the sharpening effect.
@@ -735,6 +765,7 @@ The time it takes to run this function is directly proportional to the number of
@c @node Resizing Images
@chapter Resizing Images
+@findex iluScale
@section Basic Scaling
To resize images, use the @code{iluScale} function:
@example
@@ -754,6 +785,7 @@ Alternately, if you specify a dimension smaller than the original dimension, the
@c @item @emph{Original image} @tab @tab @emph{Enlarged image} @tab @tab @emph{Shrunk image}
@c @end multitable
+@findex iluImageParameter
@section Advanced Scaling
ILU also allows you to specify which method you want to use to resize images.
As you can see in the middle figure above, the enlarged image is very pixelized.
@@ -822,6 +854,7 @@ The dimensions do not have to be powers of 2 if you generate them manually, but
@c @end multitable
@center @emph{All mipmap levels down to 1x1}
+@findex iluBuildMipmaps
@subsection Mipmap Creation
You generate mipmaps for any image using @code{iluBuildMipmaps}. If the image already has mipmaps, the previous mipmaps are erased, and new mipmaps are generated.
Otherwise, @code{iluBuildMipmaps} generates mipmaps for the image.
@@ -829,6 +862,7 @@ Otherwise, @code{iluBuildMipmaps} generates mipmaps for the image.
The mipmaps built are always powers of 2.
If the original image does not have power-of-2 dimensions, @code{iluBuildMipmaps} resizes the original image via @code{iluScale} to have power-of-2 dimensions.
+@findex iluActiveMipmap
@subsection Mipmap Access
Access mipmaps through the @code{iluActiveMipmap} function:
@example
@@ -842,7 +876,7 @@ The only other method for setting the current image to the base image is to call
@section Animations
Animations are similar to mipmaps, but instead of being smaller successive images, the images are the same size but have different data.
The successive animation chains in DevIL can be used to create animations in your programs.
-File formats that natively support animations are .gif and .mng.
+File formats that natively support animations are @code{.gif} and @code{.mng}.
You can also create your own sub-images as animations.
@subsection Animation Chain Creation
@@ -879,7 +913,7 @@ If they are compressed, DDS files use DirectX Texture Compression (DXTC). DXTC
@subsection Keeping DXTC Data
When loading, DevIL uncompresses the DXTC.
-If you call @code{ilEnable} with the IL_KEEP_DXTC_DATA parameter, DevIL will keep an uncompressed copy of the DXTC data along with the image.
+If you call @code{ilEnable} with the @code{IL_KEEP_DXTC_DATA} parameter, DevIL will keep an uncompressed copy of the DXTC data along with the image.
Functions that deal with DXTC data can use this data without having to recompress the uncompressed data, making these functions operate faster.
The only drawback is the use of more memory.
@@ -893,10 +927,14 @@ To set what format to save DDS files in, use this line:
ilSetInteger(IL_DXTC_FORMAT, Format);
@end example
-@emph{Format} can be IL_DXT1, IL_DXT3 or IL_DXT5.
+@emph{Format} can be @code{IL_DXT1}, @code{IL_DXT3} or @code{IL_DXT5}.
@subsection Compression Method
-DevIL can use the nVidia Texture Tools (NVTT) library, the libsquish library and its own internal compressor to generate DXTC data. By default, DevIL uses its internal compressor. This compressor is fast but is not very high quality. NVTT is usually CUDA-enabled, meaning that it can run quickly on computers with GeForce 8-series and higher cards. libsquish generates images with the highest quality possible, but it can be very slow.
+DevIL can use the nVidia Texture Tools (NVTT) library, the libsquish library and its own internal compressor to generate DXTC data.
+By default, DevIL uses its internal compressor.
+This compressor is fast but is not very high quality.
+NVTT is usually CUDA-enabled, meaning that it can run quickly on computers with GeForce 8-series and higher cards.
+libsquish generates images with the highest quality possible, but it can be very slow.
To enable compression by NVTT or libsquish, use one of the following lines of code:
@@ -905,10 +943,13 @@ ilEnable(IL_NVIDIA_COMPRESS);
ilEnable(IL_SQUISH_COMPRESS);
@end example
-You can also disable compression by these libraries by using ilDisable. If both are enabled, NVTT is used.
+You can also disable compression by these libraries by using @code{ilDisable}.
+If both are enabled, NVTT is used.
@section Retrieving DXTC Data
-To retrieve a copy of the DXTC data, use @code{ilGetDXTCData}. To determine how large Buffer should be, first call @code{ilGetDXTCData} with the Buffer parameter as @code{NULL}. This function will then return the number of bytes that are required to completely store the DXTC data.
+To retrieve a copy of the DXTC data, use @code{ilGetDXTCData}.
+To determine how large Buffer should be, first call @code{ilGetDXTCData} with the Buffer parameter as @code{NULL}.
+This function will then return the number of bytes that are required to completely store the DXTC data.
Call it a second time to actually retrieve the data.
@example
@@ -963,7 +1004,7 @@ This can adversely affect your performance while loading textures, though, so us
ILUT's Direct3D (D3D) support works exactly like the OpenGL support, except you use the @code{ILUT_D3D_USE_DXTC} and @code{ILUT_D3D_GEN_DXTC} defines instead of @code{ILUT_GL_USE_S3TC} and @code{ILUT_GL_GEN_S3TC}, respectively.
-@node Common #defines
+@anchor{Common #defines}
@appendix Common DevIL @code{#defines}
Here goes lists of DevIL @code{#defines} used in functions that manipulate image data.
As you can see, they are self-explanatory.
@@ -1090,7 +1131,7 @@ Table lists the formats DevIL supports sorted according to @code{#define}.
@strong{Exception:} @code{IL_JPG} (IJL) type is not supported by @code{ilLoadF} nor by @code{ilSaveF}. @code{IL_JPG} (libjpeg) is supported by both.
-@node Sample program
+@anchor{Sample program}
@appendix Sample DevIL program
If you are not used to this approach, you may be grateful for a short program demonstrating how to actually use DevIL:
@@ -1098,53 +1139,49 @@ If you are not used to this approach, you may be grateful for a short program de
@c Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
@example
@b{#include}@t{<IL/il.h>}
-@b{#include}@t{<stdlib.h>} @i{// because of malloc() etc.}
+@b{#include}@t{<stdlib.h>} @i{/* because of malloc() etc. */}
-int @b{main}()
+int @b{main}(int argc, const char * argv[])
@{
ILuint handle, w, h;
- @i{// First we initialize the library.
-Never forget that...}
+ @i{/* First we initialize the library. */}
+ @i{/*Do not forget that... */}
@b{ilInit}();
- @i{// We want all images to be loaded in a consistent manner}
+ @i{/* We want all images to be loaded in a consistent manner */}
@b{ilEnable}(IL_ORIGIN_SET);
- @i{// In the next section, we load one image}
+ @i{/* In the next section, we load one image */}
@b{ilGenImages}(1, & handle);
- @b{ilBindImage}(handle);
- @b{ilLoadImage}(@t{"our_image_file.jpg"});
- @i{// Let's spy on it a little bit}
+ @b{ilBindImage}(handle);
+ ILboolean loaded = @b{ilLoadImage}(@t{"original_file.jpg"});
+ if (loaded == IL_FALSE)
+ return -1; @i{/* error encountered during loading */}
+ @i{/* Let's spy on it a little bit */}
w = @b{ilGetInteger}(IL_IMAGE_WIDTH); @i{// getting image width}
h = @b{ilGetInteger}(IL_IMAGE_HEIGHT); @i{// and height}
@b{printf}(@t{"Our image resolution: %dx%d}@t{\n}@t{"}, w, h);
- @i{// how much memory will we need?}
+ @i{/* how much memory will we need? */}
int memory_needed = w * h * 3 * @b{sizeof}(unsigned char);
- @i{// We multiply by 3 here because we want 3 components per pixel}
- void * data = @b{malloc}(memory_needed);
- @i{// finally get the image data}
+ @i{/* We multiply by 3 here because we want 3 components per pixel */}
+ ILubyte * data = (ILubyte *)@b{malloc}(memory_needed);
+ @i{/* finally get the image data */}
@b{ilCopyPixels}(0, 0, 0, w, h, 1, IL_RGB, IL_UNSIGNED_BYTE, data);
- @i{// now we don't need the loaded image - the data is already ours}
- @b{ilDeleteImages}(1, & handle);
-
- @i{// We want to process the image, right?}
- @b{process_image}(data, w, h);
-
- @i{// And maybe we want to save that all...}
- @i{// So we have to define a new image..}
- @b{ilGenImages}(1, & handle);
- @b{ilBindImage}(handle);
- @i{// and stuff it with our precious data!}
- @b{ilTexImage}(w, h, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, data);
- @i{// and dump them to the disc...}
+ @i{/* We want to do something with the image, right? */}
+ int i;
+ for(i = 0; i < memory_needed; i++)
+ if(i % 31 == 0) @i{/* vandalise the image */}
+ data[i] = i % 255;
+ @i{/* And maybe we want to save that all... */}
+ @b{ilSetPixels}(0, 0, 0, w, h, 1, IL_RGB, IL_UNSIGNED_BYTE, data);
+ @i{/* and dump them to the disc... */}
@b{ilSaveImage}(@t{"our_result.png"});
- @i{// Finally, clean the mess!}
+ @i{/* Finally, clean the mess! */}
@b{ilDeleteImages}(1, & handle);
- @b{free}(data);
+ @b{free}(data); data = NULL;
@b{return} 0;
@}
@end example
-@node Index
-@unnumbered Index
-@printindex cp
+@unnumbered Functions index
+@printindex fn
@bye
diff --git a/DevIL/examples/Makefile.am b/DevIL/examples/Makefile.am
deleted file mode 100644
index b085d5b5..00000000
--- a/DevIL/examples/Makefile.am
+++ /dev/null
@@ -1,88 +0,0 @@
-all_include = $(srcdir)/../include
-devildir = @datadir@/devil
-examplesdir = $(devildir)/examples
-
-AM_CPPFLAGS = -I $(all_include)
-
-il_library = ../lib/libIL.la
-ilu_library = ../lib/libILU.la
-ilut_library = ../lib/libILUT.la
-
-EXTRA_DIST =
-examples_PROGRAMS = IL_override IL_read IL_simple
-
-if BUILD_ILUT
-
-examples_PROGRAMS += ILUT_cpp_wrapper
-
-if USE_ALLEGRO
-examples_PROGRAMS += ILUT_allegro
-endif #USE_ALLEGRO
-
-if USE_DIRECTX
-examples_PROGRAMS += ILUT_d3d ILUT_windows
-endif #USE_DIRECTX
-
-if USE_SDL
-examples_PROGRAMS += ILUT_sdl
-endif #USE_SDL
-
-if USE_W32
-examples_PROGRAMS += ILUT_animation
-endif #USE_W32
-
-if HAVE_GLUT
-if USE_X11
-examples_PROGRAMS += ILUT_gl ILUT_volume
-endif #USE_X11
-endif #HAVE_GLUT
-
-endif #BUILD_ILUT
-
-ILUT_allegro_SOURCES = allegro_example/allegtest.c
-ILUT_allegro_CFLAGS = $(alleg_CFLAGS)
-ILUT_allegro_LDFLAGS = $(ilut_library)
-
-ILUT_sdl_SOURCES = sdl_example/sdl_test.c
-ILUT_sdl_CFLAGS = $(SDL_CFLAGS)
-ILUT_sdl_LDFLAGS = $(ilut_library)
-
-ILUT_animation_SOURCES = animation_example/AnimTest.cpp animation_example/resource.h animation_example/AnimTest.rc
-#ILUT_animation_CFLAGS =
-ILUT_animation_LDFLAGS = $(ilut_library)
-EXTRA_DIST += animation_example/OpenIL.ico
-
-ILUT_d3d_SOURCES = direct3d_example/d3dtest.cpp
-ILUT_d3d_LDFLAGS = $(ilut_library)
-
-ILUT_cpp_wrapper_SOURCES = cpp_wrapper_example/il_wrap.cpp
-ILUT_cpp_wrapper_LDFLAGS = $(ilut_library)
-
-IL_override_SOURCES = override_example/iotest.c
-
-ILUT_gl_SOURCES = opengl_example/gltest.c opengl_example/gltest.h
-ILUT_gl_LDFLAGS = $(ilut_library)
-
-IL_read_SOURCES = register_read_example/readtest.c
-
-IL_simple_SOURCES = simple_example/simple.c
-
-if BUILD_ILU
-IL_override_LDFLAGS = $(ilu_library)
-IL_read_LDFLAGS = $(ilu_library)
-IL_simple_LDFLAGS = $(ilu_library)
-else #not BUILD_ILU
-IL_override_LDFLAGS = $(il_library)
-IL_read_LDFLAGS = $(il_library)
-IL_simple_LDFLAGS = $(il_library)
-endif #not BUILD_ILU
-
-ILUT_volume_SOURCES = volume_example/3dtest.h volume_example/3dtest.c
-ILUT_volume_LDFLAGS = $(ilut_library)
-
-ILUT_windows_SOURCES = windows_example/BatchConv.cpp windows_example/WindowsTest.cpp windows_example/WindowsTest.h windows_example/resource.h windows_example/WindowsTest.rc
-ILUT_windows_LDFLAGS = $(ilut_library)
-EXTRA_DIST += windows_example/resources/OpenIL.ico
-
-.rc.o:
- $(RC) $(RCFLAGS) $< -o $@
diff --git a/DevIL/src-IL/Makefile.am b/DevIL/src-IL/Makefile.am
deleted file mode 100644
index fb718787..00000000
--- a/DevIL/src-IL/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-SUBDIRS = src include
-DIST_SUBDIRS = src include
-
-dist-hook:
- cp -Rf "msvc9" $(distdir)
- find $(distdir) -name CVS -type d | xargs rm -rf
diff --git a/DevIL/src-ILU/Makefile.am b/DevIL/src-ILU/Makefile.am
deleted file mode 100644
index fb718787..00000000
--- a/DevIL/src-ILU/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-SUBDIRS = src include
-DIST_SUBDIRS = src include
-
-dist-hook:
- cp -Rf "msvc9" $(distdir)
- find $(distdir) -name CVS -type d | xargs rm -rf
diff --git a/DevIL/src-ILU/ilur/ilur.c b/DevIL/src-ILU/ilur/ilur.c
new file mode 100644
index 00000000..c39c5f3f
--- /dev/null
+++ b/DevIL/src-ILU/ilur/ilur.c
@@ -0,0 +1,508 @@
+#include <regex.h>
+#include <string.h>
+#include <stdio.h>
+#include <malloc.h>
+
+#include <IL/il.h>
+#include <IL/ilu.h>
+
+/** What are the classes of types of parameters of ILU functions?
+ */
+enum Parameter_types {PARAM_VOID, PARAM_ILUINT, PARAM_ILFLOAT, PARAM_OTHERS};
+
+/** The structure wrapped around functions
+ */
+struct ilu_function
+{
+ char Name[32]; /**< Name of the function used by user nad help */
+ int Parameter_type; /**< Lots of functions take the same kind of parameters */
+ void * Callback; /**< Terribly type-unsafe... callback :-) */
+};
+typedef struct ilu_function Ilu_function;
+
+/** What will we be to able to find out during arguments parsing
+ */
+enum {FLAG_NONE = 0x0, FLAG_HELP = 0x1, FLAG_VERBOSE = 0x2, FLAG_LOAD = 0x4, FLAG_SAVE = 0x8};
+enum {ILU_ALIENIFY, ILU_BLURAVG, ILU_BLURGAUSSIAN, ILU_BUILDMIPMAPS, ILU_COMPAREIMAGE, ILU_CONTRAST, ILU_CROP, ILU_EDGEDETECTE, ILU_EDGEDETECTP, ILU_EDGEDETECTS, ILU_EMBOSS, ILU_ENLARGECANVAS, ILU_ENLARGEIMAGE, ILU_EQUALIZE, ILU_CONVOLUTION, ILU_FLIPIMAGE, ILU_GAMMACORRECT, ILU_INVERTALPHA, ILU_MIRROR, ILU_NEGATIVE, ILU_NOISIFY, ILU_PIXELIZE, ILU_REPLACECOLOUR, ILU_ROTATE, ILU_ROTATE3D, ILU_SATURATE1F, ILU_SATURATE4F, ILU_SCALE, ILU_SCALEALPHA, ILU_SCALECOLOURS, ILU_SETLANGUAGE, ILU_SHARPEN, ILU_SWAPCOLOURS, ILU_WAVE, ILU_FUN_COUNT};
+
+/* security comes first */
+#define short_strlen 32
+#define long_strlen 128
+
+char program_name[short_strlen]; /**< How is our executable called? */
+Ilu_function ilu_functions[ILU_FUN_COUNT]; /**< What functions are we dealing with? */
+
+/** Just dump infos about functions to the structures so we can somehow automate the processing of user input later...
+ */
+void init_strings()
+{
+ ilu_functions[ILU_ALIENIFY] = (Ilu_function){ "iluAlienify", PARAM_VOID, & iluAlienify };
+ ilu_functions[ILU_BLURAVG] = (Ilu_function){ "iluBlurAvg", PARAM_ILUINT, & iluBlurAvg };
+ ilu_functions[ILU_BLURGAUSSIAN] = (Ilu_function){ "iluBlurGaussian", PARAM_ILUINT, & iluBlurGaussian };
+ ilu_functions[ILU_BUILDMIPMAPS] = (Ilu_function){ "iluBuildMipmaps", PARAM_VOID, & iluBuildMipmaps };
+ ilu_functions[ILU_COMPAREIMAGE] = (Ilu_function){ "iluCompareImage", PARAM_ILUINT, & iluCompareImage };
+ ilu_functions[ILU_CONTRAST] = (Ilu_function){ "iluContrast", PARAM_ILFLOAT, & iluContrast };
+ ilu_functions[ILU_CROP] = (Ilu_function){ "iluCrop", PARAM_OTHERS, & iluCrop };
+ ilu_functions[ILU_EDGEDETECTE] = (Ilu_function){ "iluEdgeDetectE", PARAM_VOID, & iluEdgeDetectE };
+ ilu_functions[ILU_EDGEDETECTP] = (Ilu_function){ "iluEdgeDetectP", PARAM_VOID, & iluEdgeDetectP };
+ ilu_functions[ILU_EDGEDETECTS] = (Ilu_function){ "iluEdgeDetectS", PARAM_VOID, & iluEdgeDetectS };
+ ilu_functions[ILU_EMBOSS] = (Ilu_function){ "iluEmboss", PARAM_VOID, & iluEmboss };
+ ilu_functions[ILU_ENLARGECANVAS] = (Ilu_function){ "iluEnlargeCanvas", PARAM_OTHERS, & iluEnlargeCanvas };
+ ilu_functions[ILU_ENLARGEIMAGE] = (Ilu_function){ "iluEnlargeImage", PARAM_OTHERS, & iluEnlargeImage };
+ ilu_functions[ILU_EQUALIZE] = (Ilu_function){ "iluEqualize", PARAM_VOID, & iluEqualize };
+ ilu_functions[ILU_CONVOLUTION] = (Ilu_function){ "iluConvolution", PARAM_OTHERS, & iluConvolution };
+ ilu_functions[ILU_FLIPIMAGE] = (Ilu_function){ "iluFlipImage", PARAM_VOID, & iluFlipImage };
+ ilu_functions[ILU_GAMMACORRECT] = (Ilu_function){ "iluGammaCorrect", PARAM_ILFLOAT, & iluGammaCorrect };
+ ilu_functions[ILU_INVERTALPHA] = (Ilu_function){ "iluInvertAlpha", PARAM_VOID, & iluInvertAlpha };
+ ilu_functions[ILU_MIRROR] = (Ilu_function){ "iluMirror", PARAM_VOID, & iluMirror };
+ ilu_functions[ILU_NEGATIVE] = (Ilu_function){ "iluNegative", PARAM_VOID, & iluNegative };
+ ilu_functions[ILU_NOISIFY] = (Ilu_function){ "iluNoisify", PARAM_OTHERS, & iluNoisify };
+ ilu_functions[ILU_PIXELIZE] = (Ilu_function){ "iluPixelize", PARAM_ILUINT, & iluPixelize };
+ ilu_functions[ILU_REPLACECOLOUR] = (Ilu_function){ "iluReplaceColour", PARAM_OTHERS, & iluReplaceColour };
+ ilu_functions[ILU_ROTATE] = (Ilu_function){ "iluRotate", PARAM_ILFLOAT, & iluRotate };
+ ilu_functions[ILU_ROTATE3D] = (Ilu_function){ "iluRotate3D", PARAM_OTHERS, & iluRotate3D };
+ ilu_functions[ILU_SATURATE1F] = (Ilu_function){ "iluSaturate1f", PARAM_ILFLOAT, & iluSaturate1f };
+ ilu_functions[ILU_SATURATE4F] = (Ilu_function){ "iluSaturate4f", PARAM_OTHERS, & iluSaturate4f };
+ ilu_functions[ILU_SCALE] = (Ilu_function){ "iluScale", PARAM_OTHERS, & iluScale };
+ ilu_functions[ILU_SCALEALPHA] = (Ilu_function){ "iluScaleAlpha", PARAM_ILFLOAT, & iluScaleAlpha };
+ ilu_functions[ILU_SCALECOLOURS] = (Ilu_function){ "iluScaleColours", PARAM_OTHERS, & iluScaleColours };
+ ilu_functions[ILU_SETLANGUAGE] = (Ilu_function){ "iluSetLanguage", PARAM_OTHERS, & iluSetLanguage };
+ ilu_functions[ILU_SHARPEN] = (Ilu_function){ "iluSharpen", PARAM_OTHERS, & iluSharpen };
+ ilu_functions[ILU_SWAPCOLOURS] = (Ilu_function){ "iluSwapColours", PARAM_VOID, & iluSwapColours };
+ ilu_functions[ILU_WAVE] = (Ilu_function){ "iluWave", PARAM_ILFLOAT, & iluWave };
+}
+
+/** What is worthy to remember from what the user can tell us...
+ */
+struct params
+{
+ char Load_filename[long_strlen]; ///< Where to get the image
+ char Save_filename[long_strlen]; ///< And where to dump it in the end
+
+ int Flags; ///< verbose, help, etc.
+ int Calls_count; ///< How many ILU functions are we going to apply to the image?
+ char ** Calls_strings; ///< How did the user specified the function calls?
+};
+typedef struct params Params;
+
+/** Create a new Params structure in the space and return a pointer to it
+ */
+Params * create_params()
+{
+ Params * ret_val = (Params *)malloc(sizeof(Params));
+ ret_val->Load_filename[0] = '\0';
+ ret_val->Save_filename[0] = '\0';
+ ret_val->Flags = 0;
+ ret_val->Calls_count = 0;
+ ret_val->Calls_strings = NULL;
+ return ret_val;
+}
+
+/** What was created, must be destroyed!
+ */
+void destroy_params(Params * to_destroy)
+{
+ int i;
+ for(i = 0; i < to_destroy->Calls_count; i++)
+ {/* The main thing to free here are the call strings */
+ free(to_destroy->Calls_strings[i]);
+ to_destroy->Calls_strings[i] = NULL;
+ }
+ /* Then free the call strings container */
+ free(to_destroy->Calls_strings);
+ to_destroy->Calls_strings = NULL;
+ /* And let's remember that the parameter itself has to be freed */
+ free(to_destroy);
+ to_destroy = NULL;
+}
+
+/** This function receives the raw string passed from the command line
+ * \param string The passed string
+ * \param name The extracted name of the function
+ * \param params The extracted string between brackets
+ */
+int parse_function(const char * string, char * name, char * params)
+{
+ regex_t rex;
+ const int match_num = 3;
+ regmatch_t matchptr[3];
+ /* First we have to compile the regex */
+ regcomp (& rex, "\\([[:alnum:]]*\\)[[:space:]]*(\\(.*\\))", 0);
+ /* Then we match it */
+ regexec (& rex, string, match_num, matchptr, 0);
+ /* Match No.0: Not interesting (it is the whole expression in this case) */
+ /* Match No.1: The name of the function. How long is it? */
+ int funlength = matchptr[1].rm_eo - matchptr[1].rm_so;
+ /* Match No.2: What was between the first brackets? */
+ int paramlength = matchptr[2].rm_eo - matchptr[2].rm_so;
+ /* Was actually anything there? No attempts to make an exploit? */
+ if (funlength > long_strlen - 2 || paramlength > long_strlen - 2)
+ return -1;
+ /* Let's get it all! */
+ if (funlength > 0)
+ strncpy(name, string + matchptr[1].rm_so, funlength);
+ /* And terminate it with the zero... */
+ name[funlength] = '\0';
+ /* and do the same for the parameter string... */
+ if (paramlength > 0)
+ strncpy(params, string + matchptr[2].rm_so, paramlength);
+ params[paramlength] = '\0';
+ return 0;
+}
+
+/** Takes a string and removes whitespaces within
+ * \param string The input string
+ * \param nonwhitespaced The 'cleaned' string
+ */
+int remove_whitespaces(const char * string, char * nonwhitespaced)
+{
+ strncpy(nonwhitespaced, string, strlen(string) + 1);
+ int i;
+ /* How many whitespace chars were skipped? */
+ int num_whitespaced = 0;
+ /* Go from the beginning and don't stop until the either end */
+ for (i = 0; string[i] != '\0' && i < long_strlen; i++)
+ /* Ho, a whitespace that shouldn't be missed! */
+ if( string[i] == ' ' || string[i] == '\t' )
+ {
+ num_whitespaced++;
+ continue;
+ }
+ else /* No whitespace, moreover we are already inside the string... */
+ {
+ /* Here we copy the stuff to the output parameter */
+ nonwhitespaced[i - num_whitespaced] = string[i];
+ }
+}
+
+/** How to fill our Params structure?
+ */
+int parse_arguments(int argc, const char * argv[], Params * parameters)
+{
+ /* How many ILU functions are we going to apply to the image? */
+ int calls_count = 0;
+ /* Let's store their corresponding indexes in argv... */
+ int * fun_to_call = (int *)malloc(argc / 2 * sizeof(int));
+
+ int i;
+ for (i = 1; i < argc; i++)
+ {
+ /* Find out what to do and what to expect */
+ if (argv[i][0] == '-')
+ {/* Ho, an option was passed... */
+ if (argv[i][1] == '-')
+ {/* Deal with long options */
+ if(strncmp(argv[i], "--apply", long_strlen))
+ goto apply; /* Yeah, there are GOTO's here :-) */
+ else if(strncmp(argv[i], "--load-from", long_strlen))
+ goto load_from;
+ else if(strncmp(argv[i], "--save-to", long_strlen))
+ goto save_to;
+ else if(strncmp(argv[i], "--verbose", long_strlen))
+ goto verbose;
+ }
+ else switch(argv[i][1]) /* Well, maybe it wasn't a long option :-) */
+ {/* Deal with long options */
+ case 'h':
+ case '?':
+ help:
+ parameters->Flags |= FLAG_HELP;
+ break;
+ case 'a':
+ apply:
+ if (argc > i + 1) /* that there is maybe something like the parameter out there... */
+ fun_to_call[calls_count++] = i + 1;
+ break;
+ case 'l':
+ load_from:
+ if (argc > i + 1)
+ {/* that there is maybe something like the parameter out there... */
+ strncpy(parameters->Load_filename, argv[i + 1], long_strlen);
+ parameters->Flags |= FLAG_LOAD;
+ }
+ break;
+ case 's':
+ save_to:
+ if (argc > i + 1)
+ {/* that there is maybe something like the parameter out there... */
+ strncpy(parameters->Save_filename, argv[i + 1], long_strlen);
+ parameters->Flags |= FLAG_SAVE;
+ }
+ break;
+ case 'v':
+ verbose:
+ parameters->Flags |= FLAG_VERBOSE;
+ break;
+ }
+ /* We don't use complicated parameters here, so no worries */
+ }/* endif (argv[i][0] == '-') */
+ }/* endif (argv[i][0] == '-') */
+ /* let's save the valuable info to the output structure... */
+ parameters->Calls_count = calls_count;
+ /* and let's also store the calls as passed by the user */
+ parameters->Calls_strings = (char **)malloc(parameters->Calls_count * sizeof (char *));
+ for (i = 0; i < calls_count; i++)
+ {
+ /* Yeah, there is probably more memory allocated than needed... */
+ parameters->Calls_strings[i] = (char *)malloc(sizeof(char) * long_strlen);
+ strncpy(parameters->Calls_strings[i], argv[ fun_to_call[i] ], long_strlen);
+ }
+
+ /* clean the mess... */
+ free(fun_to_call);
+ fun_to_call = 0;
+}
+
+void print_help()
+{
+ printf(" *** Beware, manually generated help (=> may not be 100%% up-to-date :-) ***\n");
+ printf("\tTip: If you miss something, examine the source code\n\tNext tip: You can't stack the short options. Sorry.\n");
+ printf("Run %s with this arguments:\n", program_name);
+ printf("\t-h, -? | --help: This help message\n");
+ printf("\t-v | --verbose: Verbose run\n");
+ printf("\t-l | --load_from <filename, like subject.png>: The filename of an image that will be loaded and played with\n");
+ printf("\t-s | --save-to <filename, like result.jpg>: The filename of the result\n");
+ printf("\t-a | --apply <C-styled function call, like iluBlurAvg(6)>: The operation to run. Beware of the braces, they annoy most shells, so you need to either enclose the parameter in quotation marks (recommended), or escape them (not recommended since it is clumsy)\n");
+ printf("\tFunctions will be applied in order you have specified them, that is from left to right.\n");
+ printf(" Functions we know of: ");
+ int i;
+ for (i = 0; i < ILU_FUN_COUNT - 1; i++)
+ printf("%s, ", ilu_functions[i].Name);
+ printf("%s.\n", ilu_functions[ILU_FUN_COUNT - 1].Name);
+ printf("\nExample call:\n\t%s -l source_image.png -s result_image.jpg -a 'iluAlienify()' -a 'iluContrast(0.8)'\n", program_name);
+}
+
+/**
+ * Assumed that the right image is bound to IL
+ */
+int perform_operation(const char * operation, int verbose)
+{
+ /* Where to store the first parsing results? */
+ char function[long_strlen], params[long_strlen], solid_params[long_strlen];
+ /* Get the function name string and parameters string */
+ parse_function(operation, function, params);
+ /* Get rid of any whitespaces from the parameters string */
+ remove_whitespaces(params, solid_params);
+ if (verbose)
+ printf("Calling %s(%s)\n", function, solid_params);
+ /* What function was wanted? -1 means that we don't know */
+ int function_index = -1;
+ int i;
+ for (i = 0; i < ILU_FUN_COUNT; i++)
+ if (strncmp(function, ilu_functions[i].Name, short_strlen) == 0)
+ {/* Yeah, this function was wanted. Let's have its index from the ilu_functions array */
+ function_index = i;
+ break; /* nothing to do here any more */
+ }
+ if (function_index == -1)
+ {/* Seems we haven't found anything... */
+ fprintf(stderr, "Error: You have specified an invalid function name '%s' (have you called %s).\nRun '%s --help' command to get some help\n", function, operation, program_name);
+ return 1;
+ }
+ /* We are going to try something and we want to know how it ended */
+ ILboolean return_value;
+ switch (ilu_functions[function_index].Parameter_type)
+ {/* First semi-automatic processing according to type of parameters */
+ case PARAM_VOID:
+ {
+ ILboolean (* function)() = ilu_functions[function_index].Callback;
+ return_value = function();
+ break;
+ }/* endcase PARAM_VOID */
+ case PARAM_ILUINT:
+ {
+ /* first assign and determine the type of the Callback */
+ ILboolean (* function)(ILuint) = ilu_functions[function_index].Callback;
+ /* then declare the parameter variables */
+ ILuint param_value;
+ /* fill them */
+ int success = sscanf(solid_params, "%u", & param_value);
+ if (success != 1)
+ {/* see how it ended */
+ fprintf(stderr, "Error interpreting '%s' as unsigned integer (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ /* execute the command and store the result */
+ return_value = function(param_value);
+ break;
+ }/* endcase PARAM_ILUINT */
+ case PARAM_ILFLOAT:
+ {
+ ILboolean (* function)(ILfloat) = ilu_functions[function_index].Callback;
+ double param_value;
+ int success = sscanf(solid_params, "%lf", & param_value);
+ if (success != 1)
+ {
+ fprintf(stderr, "Error interpreting '%s' as float (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function((ILfloat)param_value);
+ break;
+ }/* endcase PARAM_ILFLOAT */
+ case PARAM_OTHERS:
+ switch (function_index)
+ {/* next, the manual processing according to names */
+ case ILU_SHARPEN:
+ {
+ ILboolean (* function)(ILfloat, ILuint) = ilu_functions[function_index].Callback;
+ double factor;
+ ILuint iter;
+ int success = sscanf(solid_params, "%lf,%u", & factor, & iter);
+ if (success != 2)
+ {
+ fprintf(stderr, "Error interpreting '%s' as floating-point number and unsigned integer separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function((ILfloat)factor, iter);
+ break;
+ }/* endcase ILU_SHARPEN */
+ case ILU_CROP:
+ {
+ ILboolean (* function)(ILuint, ILuint, ILuint, ILuint, ILuint, ILuint ) = ilu_functions[function_index].Callback;
+ ILuint xoff, yoff, zoff, width, height, depth;
+ int success = sscanf(solid_params, "%u,%u,%u,%u,%u,%u", & xoff, & yoff, & zoff, & width, & height, & depth);
+ if (success != 6)
+ {
+ fprintf(stderr, "Error interpreting '%s' as 6 unsigned integers separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function(xoff, yoff, zoff, width, height, depth);
+ break;
+ }/* endcase ILU_CROP */
+ case ILU_ENLARGECANVAS:
+ case ILU_SCALE:
+ {
+ ILboolean (* function)(ILuint, ILuint, ILuint) = ilu_functions[function_index].Callback;
+ ILuint width, height, depth;
+ int success = sscanf(solid_params, "%u,%u,%u", & width, & height, & depth);
+ if (success != 3)
+ {
+ fprintf(stderr, "Error interpreting '%s' as 3 unsigned integers separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function(width, height, depth);
+ break;
+ }/* endcase ILU_ENLARGECANVAS + ILU_SCALE */
+ case ILU_ENLARGEIMAGE:
+ case ILU_SCALECOLOURS:
+ {
+ ILboolean (* function)(ILfloat, ILfloat, ILfloat) = ilu_functions[function_index].Callback;
+ double first, second, third;
+ int success = sscanf(solid_params, "%lf,%lf,%lf", & first, & second, & third);
+ if (success != 3)
+ {
+ fprintf(stderr, "Error interpreting '%s' as 3 floating-point numbers separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function((ILfloat)first, (ILfloat)second, (ILfloat)third);
+ break;
+ }/* endcase ILU_ENLARGEIMAGE + ILU_SCALECOLOURS */
+ case ILU_ROTATE3D:
+ case ILU_SATURATE4F:
+ {
+ ILboolean (* function)(ILfloat, ILfloat, ILfloat, ILfloat) = ilu_functions[function_index].Callback;
+ double first, second, third, fourth;
+ int success = sscanf(solid_params, "%lf,%lf,%lf,%lf", & first, & second, & third, & fourth);
+ if (success != 4)
+ {
+ fprintf(stderr, "Error interpreting '%s' as 4 floating-point numbers separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function((ILfloat)first, (ILfloat)second, (ILfloat)third, (ILfloat)fourth);
+ break;
+ }/* endcase ILU_ROTATE3D + ILU_SATURATE4F */
+ case ILU_REPLACECOLOUR:
+ {
+ ILboolean (* function)(ILubyte, ILubyte, ILubyte, ILfloat ) = ilu_functions[function_index].Callback;
+ ILuint red, green, blue;
+ double tolerance;
+ int success = sscanf(solid_params, "%u,%u,%u,%lf", & red, & green, & blue, & tolerance);
+ if (success != 4)
+ {
+ fprintf(stderr, "Error interpreting '%s' as 3 8-bit unsigned integers and one floating-point number separated by comma (when calling %s)\n", solid_params, operation);
+ break;
+ }
+ return_value = function((ILubyte)red, (ILubyte)green, (ILubyte)blue, (ILfloat)tolerance);
+ break;
+ }/* endcase ILU_ROTATE3D + ILU_SATURATE4F * */
+ /* iluConvolution(ILint *matrix, ILint scale, ILint bias); Any idea about this? */
+ }/* endswitch(function_index) */
+ break;
+
+ }/* endswitch (ilu_functions[function_index].Parameter_type) */
+ /* It didn't end good for some reason... */
+ if (return_value == IL_FALSE)
+ {
+ int error= ilGetError();
+ fprintf(stderr, "Something got wrong when calling %s(%s): %s\n", function, solid_params, iluErrorString(error) );
+ return error;
+ }
+ return 0;
+}
+
+int do_stuff(const Params * parameters)
+{
+ if (parameters->Flags & FLAG_HELP || ((parameters->Flags | FLAG_LOAD | FLAG_SAVE) != parameters->Flags) )
+ {/* We wanted HELP or we did not get SAVE or LOAD */
+ print_help(); /* tell the loser what to do, then :-) */
+ return 0;
+ }
+ int verbose = parameters->Flags & FLAG_VERBOSE;
+
+ int image_handle;
+ int w, h;
+ ILboolean result;
+
+ /* Quite obvious stuff, just load an image */
+ ilGenImages(1, & image_handle);
+ ilBindImage(image_handle);
+ result = ilLoadImage(parameters->Load_filename);
+ if (result == IL_FALSE)
+ {
+ int error = ilGetError();
+ fprintf(stderr, "Error: Something went wrong when loading file '%s' (%s)\n", parameters->Load_filename, iluErrorString(error));
+ return error;
+ }
+ /* If we get image's dimensions, people will believe that we have actually loaded something :-) */
+ w = ilGetInteger(IL_IMAGE_WIDTH);
+ h = ilGetInteger(IL_IMAGE_HEIGHT);
+ if (verbose)
+ printf("Loaded '%s', size %dx%d\n", parameters->Load_filename, w, h);
+ /* Now let's do our stuff!!! */
+ int i;
+ for (i = 0; i < parameters->Calls_count; i++)
+ perform_operation(parameters->Calls_strings[i], verbose);
+ /* our stuff has been done... */
+
+ result = ilSaveImage(parameters->Save_filename);
+ if (result == IL_FALSE)
+ {
+ int error = ilGetError();
+ fprintf(stderr, "Error: Something went wrong when saving file '%s' (%s)\n", parameters->Save_filename, iluErrorString(error));
+ ilDeleteImages(1, & image_handle);
+ return error;
+ }
+ ilDeleteImages(1, & image_handle);
+ return 0;
+}
+
+int main(int argc, const char * argv[])
+{
+ /* Name our little program */
+ strncpy(program_name, argv[0], short_strlen);
+ /* Prepare ilu functions "database" */
+ init_strings();
+ /* initialize DevIL in order to get defined behavior of the app */
+ ilInit();
+ iluInit();
+ /* Prepare command line parsing */
+ Params * parameters = create_params();
+ /* Do the parsing */
+ parse_arguments(argc, argv, parameters);
+ /* Finally do what we wanted */
+ do_stuff(parameters);
+ /* Clean after the party */
+ destroy_params(parameters);
+ return 0;
+}
+
diff --git a/DevIL/src-ILUT/Makefile.am b/DevIL/src-ILUT/Makefile.am
deleted file mode 100644
index 7c536ca1..00000000
--- a/DevIL/src-ILUT/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-SUBDIRS = include src
-DIST_SUBDIRS = include src
-
-dist-hook:
- cp -Rf "msvc9" $(distdir)
- find $(distdir) -name CVS -type d | xargs rm -rf