├── .gitignore ├── Makefile.common ├── TODO ├── configure ├── deps └── OSX │ ├── SDLMain.h │ └── SDLMain.m ├── design.txt ├── docs ├── header.inc ├── index.html ├── make-docs.sh └── make-wiki.sh ├── examples ├── life.sh ├── mandelbrot.sh └── plugin.cpp ├── license.txt ├── makefiles ├── Makefile.cygwin ├── Makefile.linux └── Makefile.macports ├── msvc ├── Example │ ├── Example.cpp │ ├── Example.vcxproj │ ├── Example.vcxproj.filters │ └── Example.vcxproj.user ├── ImageStack.lib │ ├── ImageStack.lib.vcxproj │ ├── ImageStack.lib.vcxproj.filters │ └── ImageStack.lib.vcxproj.user ├── ImageStack.sln ├── ImageStack.suo ├── ImageStack.vcproj ├── ImageStack.vcxproj ├── ImageStack.vcxproj.filters ├── ImageStack.vcxproj.user ├── include │ ├── SDL │ │ ├── SDL.h │ │ ├── SDL_active.h │ │ ├── SDL_audio.h │ │ ├── SDL_byteorder.h │ │ ├── SDL_cdrom.h │ │ ├── SDL_config.h │ │ ├── SDL_config.h.default │ │ ├── SDL_config.h.in │ │ ├── SDL_config_dreamcast.h │ │ ├── SDL_config_macos.h │ │ ├── SDL_config_macosx.h │ │ ├── SDL_config_minimal.h │ │ ├── SDL_config_nds.h │ │ ├── SDL_config_os2.h │ │ ├── SDL_config_symbian.h │ │ ├── SDL_config_win32.h │ │ ├── SDL_copying.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_endian.h │ │ ├── SDL_error.h │ │ ├── SDL_events.h │ │ ├── SDL_getenv.h │ │ ├── SDL_joystick.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_keysym.h │ │ ├── SDL_loadso.h │ │ ├── SDL_main.h │ │ ├── SDL_mouse.h │ │ ├── SDL_mutex.h │ │ ├── SDL_name.h │ │ ├── SDL_opengl.h │ │ ├── SDL_platform.h │ │ ├── SDL_quit.h │ │ ├── SDL_rwops.h │ │ ├── SDL_stdinc.h │ │ ├── SDL_syswm.h │ │ ├── SDL_thread.h │ │ ├── SDL_timer.h │ │ ├── SDL_types.h │ │ ├── SDL_version.h │ │ ├── SDL_video.h │ │ ├── begin_code.h │ │ ├── close_code.h │ │ └── doxyfile │ ├── api.h │ ├── cderror.h │ ├── cdjpeg.h │ ├── crc32.h │ ├── deflate.h │ ├── f77funcs.h │ ├── fftw3.h │ ├── guru.h │ ├── guru64.h │ ├── gzguts.h │ ├── inffast.h │ ├── inffixed.h │ ├── inflate.h │ ├── inftrees.h │ ├── jconfig.h │ ├── jdct.h │ ├── jerror.h │ ├── jinclude.h │ ├── jmemsys.h │ ├── jmorecfg.h │ ├── jpegint.h │ ├── jpeglib.h │ ├── jversion.h │ ├── mktensor-iodims.h │ ├── plan-guru-dft-c2r.h │ ├── plan-guru-dft-r2c.h │ ├── plan-guru-dft.h │ ├── plan-guru-r2r.h │ ├── plan-guru-split-dft-c2r.h │ ├── plan-guru-split-dft-r2c.h │ ├── plan-guru-split-dft.h │ ├── png.h │ ├── pngconf.h │ ├── t4.h │ ├── tif_dir.h │ ├── tif_fax3.h │ ├── tif_predict.h │ ├── tiff.h │ ├── tiffconf.h │ ├── tiffio.h │ ├── tiffiop.h │ ├── tiffvers.h │ ├── transupp.h │ ├── trees.h │ ├── uvcode.h │ ├── zconf.h │ ├── zlib.h │ └── zutil.h └── lib │ ├── SDL-x64-static-mt.lib │ ├── SDL-x86-static-mt.lib │ ├── dxguid-x64.lib │ ├── dxguid-x86.lib │ ├── libfftw-x64-static-mt.lib │ ├── libfftw-x86-static-mt.lib │ ├── libjpeg-x64-static-mt.lib │ ├── libjpeg-x86-static-mt.lib │ ├── libpng-x64-static-mt.lib │ ├── libpng-x86-static-mt.lib │ ├── libtiff-x64-static-mt.lib │ ├── libtiff-x86-static-mt.lib │ ├── zlib-x64-static-mt.lib │ └── zlib-x86-static-mt.lib ├── pics ├── belgium.hdr └── dog1.jpg ├── src ├── Alignment.cpp ├── Alignment.h ├── Arithmetic.cpp ├── Arithmetic.h ├── Calculus.cpp ├── Calculus.h ├── Color.cpp ├── Color.h ├── Complex.cpp ├── Complex.h ├── Control.cpp ├── Control.h ├── Convolve.cpp ├── Convolve.h ├── DFT.cpp ├── DFT.h ├── Deconvolution.cpp ├── Deconvolution.h ├── DenseGrid.h ├── Display.cpp ├── Display.h ├── DisplayWindow.cpp ├── DisplayWindow.h ├── Exception.cpp ├── Exception.h ├── Expr.h ├── Expr_avx.h ├── Expr_scalar.h ├── Expr_scalar_fallback.h ├── Expr_sse.h ├── File.cpp ├── File.h ├── FileCSV.cpp ├── FileEXR.cpp ├── FileFLO.cpp ├── FileHDR.cpp ├── FileJPG.cpp ├── FileMAT.cpp ├── FileNotImplemented.h ├── FilePBA.cpp ├── FilePNG.cpp ├── FilePPM.cpp ├── FileTGA.cpp ├── FileTIFF.cpp ├── FileTMP.cpp ├── FileWAV.cpp ├── Filter.cpp ├── Filter.h ├── Func.h ├── Func_test.cpp ├── GKDTree.h ├── GaussTransform.cpp ├── GaussTransform.h ├── Geometry.cpp ├── Geometry.h ├── HDR.cpp ├── HDR.h ├── Image.h ├── ImageStack.h ├── KernelEstimation.cpp ├── KernelEstimation.h ├── LAHBPCG.cpp ├── LAHBPCG.h ├── LightField.cpp ├── LightField.h ├── LinearAlgebra.h ├── LocalLaplacian.cpp ├── LocalLaplacian.h ├── Network.cpp ├── Network.h ├── NetworkOps.cpp ├── NetworkOps.h ├── Operation.cpp ├── Operation.h ├── Paint.cpp ├── Paint.h ├── Parser.cpp ├── Parser.h ├── PatchMatch.cpp ├── PatchMatch.h ├── Permutohedral.h ├── Plugin.cpp ├── Plugin.h ├── Prediction.cpp ├── Prediction.h ├── Reduction.h ├── Stack.cpp ├── Stack.h ├── Statistics.cpp ├── Statistics.h ├── WLS.cpp ├── WLS.h ├── Wavelet.cpp ├── Wavelet.h ├── eigenvectors.h ├── imagestack ├── macros.h ├── main.cpp ├── main.h ├── precomputations.py └── tables.h └── util ├── MATLAB ├── loadTMP.m ├── saveTMP.m └── testTMP.m └── numpy ├── loadTMP.py ├── saveTMP.py └── testTMP.py /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | # the components of imagestack 2 | IMAGESTACK_OBJECTS = \ 3 | Calculus.o \ 4 | Color.o \ 5 | Complex.o \ 6 | Control.o \ 7 | Convolve.o \ 8 | Deconvolution.o \ 9 | DFT.o \ 10 | Display.o \ 11 | DisplayWindow.o \ 12 | Exception.o \ 13 | File.o \ 14 | FileEXR.o \ 15 | FileCSV.o \ 16 | FileHDR.o \ 17 | FileJPG.o \ 18 | FilePNG.o \ 19 | FileTMP.o \ 20 | FileMAT.o \ 21 | FilePPM.o \ 22 | FilePBA.o \ 23 | FileTGA.o \ 24 | FileTIFF.o \ 25 | FileFLO.o \ 26 | FileWAV.o \ 27 | Filter.o \ 28 | GaussTransform.o \ 29 | Geometry.o \ 30 | HDR.o \ 31 | KernelEstimation.o \ 32 | LAHBPCG.o \ 33 | LightField.o \ 34 | LocalLaplacian.o \ 35 | Arithmetic.o \ 36 | Alignment.o \ 37 | NetworkOps.o \ 38 | Network.o \ 39 | Operation.o \ 40 | Paint.o \ 41 | PatchMatch.o \ 42 | Parser.o \ 43 | Plugin.o \ 44 | Prediction.o \ 45 | Stack.o \ 46 | Statistics.o \ 47 | Wavelet.o \ 48 | WLS.o \ 49 | main.o \ 50 | 51 | 52 | # This adds the appropriate defines for dependencies not included 53 | SDL_CCFLAGS ?= -DNO_SDL 54 | JPEG_CCFLAGS ?= -DNO_JPEG 55 | TIFF_CCFLAGS ?= -DNO_TIFF 56 | PNG_CCFLAGS ?= -DNO_PNG 57 | FFTW_CCFLAGS ?= -DNO_FFTW 58 | OPENEXR_CCFLAGS ?= -DNO_OPENEXR 59 | 60 | ########################## 61 | # Top-level targets # 62 | ########################## 63 | 64 | all: $(BIN_TARGET) library 65 | 66 | clean: 67 | -rm -f $(BIN_TARGET) lib/*.* bin/build/*.* lib/build/*.* include/*.* 68 | 69 | ########################## 70 | # ImageStack the program # 71 | ########################## 72 | 73 | $(BIN_TARGET): IMAGESTACK_CCFLAGS = $(BIN_CCFLAGS) $(SDL_CCFLAGS) $(JPEG_CCFLAGS) $(TIFF_CCFLAGS) $(PNG_CCFLAGS) $(FFTW_CCFLAGS) $(OPENEXR_CCFLAGS) 74 | $(BIN_TARGET): IMAGESTACK_LIBS = $(SDL_LIBS) $(JPEG_LIBS) $(TIFF_LIBS) $(PNG_LIBS) $(FFTW_LIBS) $(OPENEXR_LIBS) -ldl 75 | BIN_OBJECTS = $(foreach f,$(IMAGESTACK_OBJECTS),bin/build/$f) 76 | 77 | # Everything includes main.h. By precompiling that header we can speed up compilation about 30% 78 | bin/build/main.h.gch: src/main.h 79 | mkdir -p bin/build 80 | $(CXX) $(IMAGESTACK_CCFLAGS) -x c++-header -O3 -o bin/build/main.h.gch src/main.h 81 | 82 | $(BIN_TARGET): $(BIN_OBJECTS) 83 | $(CXX) $(IMAGESTACK_CCFLAGS) $(BIN_OBJECTS) $(IMAGESTACK_LIBS) -o $(BIN_TARGET) 84 | 85 | -include $(addprefix bin/build/, $(IMAGESTACK_OBJECTS:.o=.d)) 86 | 87 | bin/build/%.o: src/%.cpp bin/build/main.h.gch 88 | $(CXX) -include bin/build/main.h $(IMAGESTACK_CCFLAGS) -MMD -MP -MF bin/build/$*.d -MT $@ -c $< -o $@ 89 | 90 | ########################## 91 | # ImageStack the library # 92 | ########################## 93 | 94 | $(LIB_TARGET): IMAGESTACK_CCFLAGS = $(LIB_CCFLAGS) -DNO_MAIN $(SDL_CCFLAGS) $(JPEG_CCFLAGS) $(TIFF_CCFLAGS) $(PNG_CCFLAGS) $(FFTW_CCFLAGS) $(OPENEXR_CCFLAGS) 95 | $(LIB_TARGET): IMAGESTACK_LIBS = $(JPEG_LIBS) $(TIFF_LIBS) $(PNG_LIBS) $(FFTW_LIBS) $(OPENEXR_LIBS) -ldl 96 | LIB_OBJECTS = $(foreach f,$(IMAGESTACK_OBJECTS),lib/build/$f) 97 | 98 | library: $(LIB_TARGET) include/ImageStack.h 99 | 100 | lib/build/main.h.gch: src/main.h 101 | mkdir -p lib/build 102 | $(CXX) $(IMAGESTACK_CCFLAGS) -x c++-header -O3 -o lib/build/main.h.gch src/main.h 103 | 104 | $(LIB_TARGET): $(LIB_OBJECTS) 105 | $(CXX) $(LIB_FLAGS) $(LIB_OBJECTS) -o $(LIB_TARGET) $(IMAGESTACK_LIBS) 106 | 107 | include/ImageStack.h: src/ImageStack.h 108 | mkdir include 109 | cp src/*.h include 110 | 111 | lib/build/%.o: src/%.cpp lib/build/main.h.gch 112 | $(CXX) -include lib/build/main.h $(IMAGESTACK_CCFLAGS) -c $< -o $@ 113 | 114 | ########################## 115 | # Source Style Fixing # 116 | ########################## 117 | 118 | STYLE_OPTS = --indent=spaces=4 --brackets=attach --indent-labels --indent-preprocessor --indent-col1-comments --max-instatement-indent=60 --min-conditional-indent=0 --pad-header --unpad-paren --keep-one-line-blocks --keep-one-line-statements --convert-tabs --align-pointer=name --suffix=none --options=none 119 | 120 | style: 121 | astyle $(STYLE_OPTS) `find . -name '[A-Za-z]*.h'` `find . -name '[A-Za-z]*.cpp'` 122 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | more resample operators (e.g. fast bilinear, bicubic) 2 | 3 | add consts 4 | add unit tests 5 | look over Ce Lui's dissertation again for a cleaner optical flow 6 | 7 | it's not clear which operators consume their arguments and which don't 8 | 9 | change all help operators to use pprintf 10 | 11 | write some better examples 12 | 13 | write a README for developers 14 | 15 | write a README for users 16 | 17 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Copy and modify one of the makefiles in the makefiles directory to ./Makefile," 4 | echo "then run make." 5 | echo 6 | echo "Alternatively, you can just run 'make -f makefiles/Makefile.whatever'" 7 | echo "to directly use one of the supplied example makefiles." -------------------------------------------------------------------------------- /deps/OSX/SDLMain.h: -------------------------------------------------------------------------------- 1 | /* SDLMain.m - main entry point for our Cocoa-ized SDL app 2 | Initial Version: Darrell Walisser 3 | Non-NIB-Code & other changes: Max Horn 4 | 5 | Feel free to customize this file to suit your needs 6 | */ 7 | 8 | #import 9 | 10 | @interface SDLMain : NSObject 11 | @end 12 | -------------------------------------------------------------------------------- /design.txt: -------------------------------------------------------------------------------- 1 | 2 | Usage Scenario: 3 | 4 | ImageStack is intended to be used as a command line image manipulation program from within a shell such as bash. 5 | 6 | ImageStack can also be compiled and used as a library. It's preferable to do this for experimental code (as opposed to modifying 7 | imagestack itself). 8 | 9 | 10 | Current Design Goals: 11 | 12 | - Provide an extensive set of tools for manipulating arbitrarily sized 2D images in arbitrary color spaces with float precision. 13 | 14 | - Be able to manipulate 3D volumes of data without obfuscating or compromising support for the above. 15 | 16 | - Be able to manipulate 4D light fields without obfuscating or compromising support for either of the above. 17 | 18 | - Be able to manipulate 1D sounds without obfuscating or compomising support for any of the above. 19 | 20 | - Be as modular as possible with respect to operations. All code concerning an operation should be in the one place. It should be easy to add and remove operations. 21 | 22 | - Provide documentation for every operation. 23 | 24 | - Can be developed and used on any system that supports gcc/makefiles. 25 | 26 | - Be as simple as possible. 27 | 28 | - Use only dependencies that are: 29 | - Cross platform 30 | - Easy to compile 31 | - Widely available 32 | 33 | 34 | 35 | Future Design Goals: 36 | 37 | - Provide a clean API to the library from Python. 38 | 39 | - Be compilable in IDEs such as msvc or xcode. 40 | 41 | -------------------------------------------------------------------------------- /docs/header.inc: -------------------------------------------------------------------------------- 1 | 2 | 3 | ImageStack 4 | 5 | 35 | 36 | 37 | 38 |
39 | 40 |

41 | 42 | " >> index.html 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /docs/make-wiki.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # Make the operation listing page 4 | echo "#labels Featured" > OperationIndex.wiki 5 | echo "==!ImageStack Operation Listing==" >> OperationIndex.wiki 6 | echo "_This page was auto-generated from the !ImageStack -help operator. Direct edits to it will be lost._" >> OperationIndex.wiki 7 | 8 | # Make each wiki page 9 | OPS=`ImageStack -help | grep "^-" | tail -n1` 10 | for OPERATION in $OPS; do 11 | OPERATION=${OPERATION/-/} 12 | echo $OPERATION 13 | echo " * [${OPERATION}]" >> OperationIndex.wiki 14 | echo "----" > ${OPERATION}.wiki; 15 | echo "_This page was auto-generated from the !ImageStack -help operator. Direct edits to it will be lost. Use the comments below to discuss this operation._" >> ${OPERATION}.wiki 16 | echo "----" >> ${OPERATION}.wiki 17 | echo "{{{" >> ${OPERATION}.wiki 18 | echo "ImageStack -help ${OPERATION}" >> ${OPERATION}.wiki 19 | ImageStack -help ${OPERATION} | grep -v "Performing operation -help" >> ${OPERATION}.wiki 20 | echo "}}}" >> ${OPERATION}.wiki; 21 | done 22 | -------------------------------------------------------------------------------- /examples/life.sh: -------------------------------------------------------------------------------- 1 | ImageStack -push 1920 1200 1 1 -noise 0 1 -threshold 0.75 -loop 1000 --convolve 3 3 1 1 1 1 1 0.5 1 1 1 1 zero --eval "(val < 3.75) * (val > 2.25)" --display full 2 | -------------------------------------------------------------------------------- /examples/mandelbrot.sh: -------------------------------------------------------------------------------- 1 | MAXX=1 2 | MINX=-2.5 3 | MAXY=1.3125 4 | MINY=-1.3125 5 | ITERATIONS=30 6 | 7 | ../bin/ImageStack -push 800 600 1 3 -evalchannels "(x/width)*($MAXX - $MINX) + $MINX" "(y/height)*($MAXY - $MINY) + $MINY" 0 -loop $ITERATIONS --evalchannels "[0]*[0] - [1]*[1] + (x/width)*($MAXX - $MINX) + $MINX" "2*[0]*[1] + (y/height)*($MAXY - $MINY) + $MINY" "(([0]*[0] + [1]*[1]) > 2) / $ITERATIONS + [2]" --clamp -50 50 -evalchannels "[2]" 1 "[2]" -normalize -colorconvert hsv rgb -display 8 | -------------------------------------------------------------------------------- /examples/plugin.cpp: -------------------------------------------------------------------------------- 1 | // An example plugin to be used with the -plugin operator. 2 | // 3 | // On OS X you compile it like this: 4 | // g++ -c plugin.cpp -I ../src 5 | // ld -dylib plugin.o -o plugin.so -undefined dynamic_lookup 6 | // 7 | // On linux you compile it like this: 8 | // g++ -std=gnu++0x -shared plugin.cpp -o plugin.so -I ../src -fPIC 9 | // 10 | // And use it like this: 11 | // ImageStack -load ../pics/dog1.jpg -plugin ./plugin.so -help foo -test foo -foo -display 12 | 13 | #include 14 | 15 | using namespace ImageStack; 16 | 17 | // here's our new operation to add 18 | class Foo : public Operation { 19 | public: 20 | void parse(vector args) { 21 | printf("Called foo with %zu args\n", args.size()); 22 | Image im = apply(stack(0)); 23 | pop(); 24 | push(im); 25 | } 26 | 27 | // Foo doubles an image then squares it, then flips it 28 | static Image apply(Image im) { 29 | Image out(im); 30 | 31 | // Use an image expression 32 | out += out; 33 | 34 | // Do some custom stuff 35 | for (int t = 0; t < out.frames; t++) { 36 | for (int y = 0; y < out.height; y++) { 37 | for (int x = 0; x < out.width; x++) { 38 | for (int c = 0; c < out.channels; c++) { 39 | out(x, y, t, c) *= out(x, y, t, c); 40 | } 41 | } 42 | } 43 | } 44 | 45 | // Use an imagestack operator 46 | Flip::apply(out, 'x'); 47 | 48 | return out; 49 | } 50 | 51 | void help() { 52 | pprintf("-foo doubles an image, squares it, and flips it.\n"); 53 | } 54 | 55 | bool test() { 56 | // Apply foo to a linear ramp 57 | Image ramp(128, 128, 1, 1); 58 | Lazy::X x; Lazy::Y y; 59 | ramp.set(x + 3*y); 60 | Image out = Foo::apply(ramp); 61 | 62 | // For a ramp the output should be... 63 | Image correct(128, 128, 1, 1); 64 | correct.set((ramp.width-1-x) + 3*y); 65 | correct *= 2; 66 | correct *= correct; 67 | 68 | return nearlyEqual(out, correct); 69 | } 70 | }; 71 | 72 | 73 | extern "C" void init_imagestack_plugin(map &operationMap) { 74 | printf("Initializing ImageStack plugin\n"); 75 | operationMap["-foo"] = new Foo(); 76 | printf("Added foo to the operation map\n"); 77 | } 78 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | * Copyright (c) 1995-2010, Stanford University 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above copyright 9 | * notice, this list of conditions and the following disclaimer in the 10 | * documentation and/or other materials provided with the distribution. 11 | * * Neither the name of Stanford University nor the 12 | * names of its contributors may be used to endorse or promote products 13 | * derived from this software without specific prior written permission. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ''AS IS'' AND ANY 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | * DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE FOR ANY 19 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /makefiles/Makefile.cygwin: -------------------------------------------------------------------------------- 1 | CXX=g++-4 2 | BIN_CCFLAGS = -O3 -std=gnu++0x -Winvalid-pch -Wall -Wshadow -Werror -pipe -ffast-math -march=native -fopenmp -Wno-uninitialized 3 | 4 | LIB_CCFLAGS = $(BIN_CCFLAGS) 5 | 6 | ################ 7 | # Dependencies # 8 | ################ 9 | 10 | # Comment out any dependencies you do not wish to include, or do not have 11 | SDL_CCFLAGS = -I/usr/local/include/SDL 12 | SDL_LIBS = -L /usr/local/lib -lSDL 13 | 14 | JPEG_CCFLAGS = 15 | JPEG_LIBS = -ljpeg 16 | 17 | TIFF_CCFLAGS = 18 | TIFF_LIBS = -ltiff 19 | 20 | PNG_CCFLAGS = 21 | PNG_LIBS = -lpng 22 | 23 | FFTW_CCFLAGS = 24 | FFTW_LIBS = -lfftw3f 25 | 26 | # By default we don't include OpenEXR, because most people won't have it installed 27 | #OPENEXR_CCFLAGS = -I /usr/local/include/OpenEXR 28 | #OPENEXR_LIBS = -L/usr/local/lib -lImath -lHalf -lIex -lIlmImf 29 | 30 | ################################# 31 | # Target names and installation # 32 | ################################# 33 | 34 | BIN_TARGET = bin/ImageStack.exe 35 | default: $(BIN_TARGET) 36 | LIB_TARGET = lib/cygImageStack.dll 37 | 38 | LIB_FLAGS = -shared -Wl,--out-implib=lib/libImageStack.dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive -Wl,--no-whole-archive 39 | 40 | install: $(BIN_TARGET) 41 | cp $(BIN_TARGET) /usr/local/bin 42 | 43 | libinstall: library 44 | cp lib/lib*.dll.a /usr/local/lib 45 | cp lib/cyg*.dll /usr/local/bin 46 | mkdir -p /usr/local/include/ImageStack 47 | cp include/*.h /usr/local/include/ImageStack/ 48 | 49 | include Makefile.common 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /makefiles/Makefile.linux: -------------------------------------------------------------------------------- 1 | BIN_CCFLAGS = -std=gnu++0x -O3 -Winvalid-pch -Wshadow -Wall -Werror -Wno-uninitialized -pipe -march=native -ffast-math -fopenmp -rdynamic 2 | 3 | 4 | LIB_CCFLAGS = $(BIN_CCFLAGS) -fPIC 5 | 6 | ########################## 7 | # Dependencies # 8 | ########################## 9 | 10 | # Comment out any dependencies you do not wish to include, or do not have 11 | SDL_CCFLAGS = -I /usr/include/SDL 12 | SDL_LIBS = `sdl-config --libs` 13 | 14 | JPEG_CCFLAGS = 15 | JPEG_LIBS = -ljpeg 16 | 17 | TIFF_CCFLAGS = 18 | TIFF_LIBS = -ltiff 19 | 20 | PNG_CCFLAGS = 21 | PNG_LIBS = -lpng 22 | 23 | FFTW_CCFLAGS = 24 | FFTW_LIBS = -lfftw3f 25 | 26 | #OPENEXR_CCFLAGS = -I /usr/local/include/OpenEXR 27 | #OPENEXR_LIBS = -L/usr/local/lib -lImath -lHalf -lIex -lIlmImf 28 | 29 | ################################# 30 | # Target names and installation # 31 | ################################# 32 | 33 | BIN_TARGET = bin/ImageStack 34 | default: $(BIN_TARGET) 35 | LIB_TARGET = lib/libImageStack.so 36 | LIB_FLAGS = -shared -fPIC 37 | 38 | install: $(BIN_TARGET) 39 | cp $(BIN_TARGET) /usr/local/bin 40 | cp src/imagestack /etc/bash_completion.d/ 41 | bash -e ./src/imagestack 42 | 43 | libinstall: library 44 | cp $(LIB_TARGET) /usr/local/lib 45 | mkdir -p /usr/local/include/ImageStack 46 | cp include/*.h /usr/local/include/ImageStack/ 47 | 48 | include Makefile.common 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /makefiles/Makefile.macports: -------------------------------------------------------------------------------- 1 | BIN_CCFLAGS = -O3 -std=c++0x -Winvalid-pch -Wall -Werror -march=native -ffast-math -Wno-uninitialized -I /opt/local/include 2 | 3 | LIB_CCFLAGS = $(BIN_CCFLAGS) -fPIC 4 | 5 | ################ 6 | # Dependencies # 7 | ################ 8 | 9 | # Needs the macports packages: fftw-3-single, openexr, libsdl, jpeg, tiff, libpng 10 | 11 | # Comment out any dependencies you do not wish to include, or do not have 12 | SDL_CCFLAGS = `sdl-config --cflags` 13 | SDL_LIBS = `sdl-config --libs` 14 | 15 | JPEG_CCFLAGS = 16 | JPEG_LIBS = -L /opt/local/lib -ljpeg 17 | 18 | TIFF_CCFLAGS = 19 | TIFF_LIBS = -L /opt/local/lib -ltiff 20 | 21 | PNG_CCFLAGS = 22 | PNG_LIBS = -L /opt/local/lib -lpng 23 | 24 | FFTW_CCFLAGS = 25 | FFTW_LIBS = -L /opt/local/lib -lfftw3f 26 | 27 | #OPENEXR_CCFLAGS = -I /opt/local/include/OpenEXR 28 | #OPENEXR_LIBS = -L/opt/local/lib -lImath -lHalf -lIex -lIlmImf 29 | 30 | ################################# 31 | # Target names and installation # 32 | ################################# 33 | 34 | BIN_TARGET = bin/ImageStack 35 | default: $(BIN_TARGET) 36 | LIB_TARGET = lib/libImageStack.dylib 37 | LIB_FLAGS = -dynamiclib -install_name /opt/local/lib/libImageStack.dylib 38 | 39 | install: $(BIN_TARGET) 40 | cp $(BIN_TARGET) /opt/local/bin 41 | 42 | libinstall: library 43 | cp $(LIB_TARGET) /opt/local/lib 44 | mkdir -p /opt/local/include/ImageStack 45 | cp include/*.h /opt/local/include/ImageStack/ 46 | 47 | include Makefile.common 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /msvc/Example/Example.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace ImageStack; 4 | 5 | // An example program that uses the ImageStack library to load a file, do some image processing, display it, and save it 6 | 7 | int main(int argc, const char **argv) { 8 | if (argc != 3) { 9 | printf("Usage: example input.jpg output.jpg\n"); 10 | return -1; 11 | } 12 | 13 | // Load an image 14 | Image im = Load::apply(argv[1]); 15 | 16 | // Do some image processing to it manually (inverting it) 17 | for (int c = 0; c < im.channels; c++) { 18 | for (int t = 0; t < im.frames; t++) { 19 | for (int y = 0; y < im.height; y++) { 20 | for (int x = 0; x < im.width; x++) { 21 | im(x, y, t, c) = 1.0f - im(x, y, t, c); 22 | } 23 | } 24 | } 25 | } 26 | 27 | // Call one of ImageStack's operators to smooth it 28 | im = WLS::apply(im, 1.2f, 0.5f, 0.1f); 29 | 30 | // Use image expressions to mess with it more 31 | im.set(im*2 - 0.5); 32 | 33 | // Save it out 34 | Save::apply(im, argv[2]); 35 | 36 | // Display it 37 | Display::apply(im); 38 | 39 | // Wait for input 40 | getchar(); 41 | 42 | return 0; 43 | } -------------------------------------------------------------------------------- /msvc/Example/Example.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /msvc/Example/Example.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /msvc/ImageStack.lib/ImageStack.lib.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /msvc/ImageStack.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageStack", "ImageStack.vcxproj", "{D7E8DB69-02AB-426F-B07E-8A2A61BA0002}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ImageStack.lib", "ImageStack.lib\ImageStack.lib.vcxproj", "{24973419-CB88-4CE2-BBF3-784748473206}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Example", "Example\Example.vcxproj", "{BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AB9A1EDA-62CB-4DB2-B207-6A7D309B8791}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Debug|x64 = Debug|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Debug|Win32.Build.0 = Debug|Win32 22 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Debug|x64.ActiveCfg = Debug|x64 23 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Debug|x64.Build.0 = Debug|x64 24 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Release|Win32.ActiveCfg = Release|Win32 25 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Release|Win32.Build.0 = Release|Win32 26 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Release|x64.ActiveCfg = Release|x64 27 | {D7E8DB69-02AB-426F-B07E-8A2A61BA0002}.Release|x64.Build.0 = Release|x64 28 | {24973419-CB88-4CE2-BBF3-784748473206}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {24973419-CB88-4CE2-BBF3-784748473206}.Debug|Win32.Build.0 = Debug|Win32 30 | {24973419-CB88-4CE2-BBF3-784748473206}.Debug|x64.ActiveCfg = Debug|x64 31 | {24973419-CB88-4CE2-BBF3-784748473206}.Debug|x64.Build.0 = Debug|x64 32 | {24973419-CB88-4CE2-BBF3-784748473206}.Release|Win32.ActiveCfg = Release|Win32 33 | {24973419-CB88-4CE2-BBF3-784748473206}.Release|Win32.Build.0 = Release|Win32 34 | {24973419-CB88-4CE2-BBF3-784748473206}.Release|x64.ActiveCfg = Release|x64 35 | {24973419-CB88-4CE2-BBF3-784748473206}.Release|x64.Build.0 = Release|x64 36 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Debug|Win32.Build.0 = Debug|Win32 38 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Debug|x64.ActiveCfg = Debug|x64 39 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Debug|x64.Build.0 = Debug|x64 40 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Release|Win32.ActiveCfg = Release|Win32 41 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Release|Win32.Build.0 = Release|Win32 42 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Release|x64.ActiveCfg = Release|x64 43 | {BBCE071D-D00D-4F47-95C4-A76B0B2ADED1}.Release|x64.Build.0 = Release|x64 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /msvc/ImageStack.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/ImageStack.suo -------------------------------------------------------------------------------- /msvc/ImageStack.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL.h 24 | * Main include header for the SDL library 25 | */ 26 | 27 | #ifndef _SDL_H 28 | #define _SDL_H 29 | 30 | #include "SDL_main.h" 31 | #include "SDL_stdinc.h" 32 | #include "SDL_audio.h" 33 | #include "SDL_cdrom.h" 34 | #include "SDL_cpuinfo.h" 35 | #include "SDL_endian.h" 36 | #include "SDL_error.h" 37 | #include "SDL_events.h" 38 | #include "SDL_loadso.h" 39 | #include "SDL_mutex.h" 40 | #include "SDL_rwops.h" 41 | #include "SDL_thread.h" 42 | #include "SDL_timer.h" 43 | #include "SDL_video.h" 44 | #include "SDL_version.h" 45 | 46 | #include "begin_code.h" 47 | /* Set up for C function definitions, even when using C++ */ 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /** @file SDL.h 53 | * @note As of version 0.5, SDL is loaded dynamically into the application 54 | */ 55 | 56 | /** @name SDL_INIT Flags 57 | * These are the flags which may be passed to SDL_Init() -- you should 58 | * specify the subsystems which you will be using in your application. 59 | */ 60 | /*@{*/ 61 | #define SDL_INIT_TIMER 0x00000001 62 | #define SDL_INIT_AUDIO 0x00000010 63 | #define SDL_INIT_VIDEO 0x00000020 64 | #define SDL_INIT_CDROM 0x00000100 65 | #define SDL_INIT_JOYSTICK 0x00000200 66 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ 67 | #define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ 68 | #define SDL_INIT_EVERYTHING 0x0000FFFF 69 | /*@}*/ 70 | 71 | /** This function loads the SDL dynamically linked library and initializes 72 | * the subsystems specified by 'flags' (and those satisfying dependencies) 73 | * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup 74 | * signal handlers for some commonly ignored fatal signals (like SIGSEGV) 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 77 | 78 | /** This function initializes specific SDL subsystems */ 79 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 80 | 81 | /** This function cleans up specific SDL subsystems */ 82 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 83 | 84 | /** This function returns mask of the specified subsystems which have 85 | * been initialized. 86 | * If 'flags' is 0, it returns a mask of all initialized subsystems. 87 | */ 88 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 89 | 90 | /** This function cleans up all initialized subsystems and unloads the 91 | * dynamically linked library. You should call it upon all exit conditions. 92 | */ 93 | extern DECLSPEC void SDLCALL SDL_Quit(void); 94 | 95 | /* Ends C function definitions when using C++ */ 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #include "close_code.h" 100 | 101 | #endif /* _SDL_H */ 102 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_active.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_active.h 25 | * Include file for SDL application focus event handling 26 | */ 27 | 28 | #ifndef _SDL_active_h 29 | #define _SDL_active_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @name The available application states */ 41 | /*@{*/ 42 | #define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ 43 | #define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ 44 | #define SDL_APPACTIVE 0x04 /**< The application is active */ 45 | /*@}*/ 46 | 47 | /* Function prototypes */ 48 | /** 49 | * This function returns the current state of the application, which is a 50 | * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and 51 | * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to 52 | * see your application, otherwise it has been iconified or disabled. 53 | */ 54 | extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); 55 | 56 | 57 | /* Ends C function definitions when using C++ */ 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #include "close_code.h" 62 | 63 | #endif /* _SDL_active_h */ 64 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_byteorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_byteorder.h 25 | * @deprecated Use SDL_endian.h instead 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_endian.h" 30 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_h 24 | #define _SDL_config_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* Add any platform that doesn't build using the configure system */ 29 | #if defined(__DREAMCAST__) 30 | #include "SDL_config_dreamcast.h" 31 | #elif defined(__MACOS__) 32 | #include "SDL_config_macos.h" 33 | #elif defined(__MACOSX__) 34 | #include "SDL_config_macosx.h" 35 | #elif defined(__SYMBIAN32__) 36 | #include "SDL_config_symbian.h" /* must be before win32! */ 37 | #elif defined(__WIN32__) 38 | #include "SDL_config_win32.h" 39 | #elif defined(__OS2__) 40 | #include "SDL_config_os2.h" 41 | #else 42 | #include "SDL_config_minimal.h" 43 | #endif /* platform config */ 44 | 45 | #endif /* _SDL_config_h */ 46 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config.h.default: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_h 24 | #define _SDL_config_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* Add any platform that doesn't build using the configure system */ 29 | #if defined(__DREAMCAST__) 30 | #include "SDL_config_dreamcast.h" 31 | #elif defined(__MACOS__) 32 | #include "SDL_config_macos.h" 33 | #elif defined(__MACOSX__) 34 | #include "SDL_config_macosx.h" 35 | #elif defined(__SYMBIAN32__) 36 | #include "SDL_config_symbian.h" /* must be before win32! */ 37 | #elif defined(__WIN32__) 38 | #include "SDL_config_win32.h" 39 | #elif defined(__OS2__) 40 | #include "SDL_config_os2.h" 41 | #else 42 | #include "SDL_config_minimal.h" 43 | #endif /* platform config */ 44 | 45 | #endif /* _SDL_config_h */ 46 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_dreamcast.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_dreamcast_h 24 | #define _SDL_config_dreamcast_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | typedef signed char int8_t; 31 | typedef unsigned char uint8_t; 32 | typedef signed short int16_t; 33 | typedef unsigned short uint16_t; 34 | typedef signed int int32_t; 35 | typedef unsigned int uint32_t; 36 | typedef signed long long int64_t; 37 | typedef unsigned long long uint64_t; 38 | typedef unsigned long uintptr_t; 39 | #define SDL_HAS_64BIT_TYPE 1 40 | 41 | /* Useful headers */ 42 | #define HAVE_SYS_TYPES_H 1 43 | #define HAVE_STDIO_H 1 44 | #define STDC_HEADERS 1 45 | #define HAVE_STRING_H 1 46 | #define HAVE_CTYPE_H 1 47 | 48 | /* C library functions */ 49 | #define HAVE_MALLOC 1 50 | #define HAVE_CALLOC 1 51 | #define HAVE_REALLOC 1 52 | #define HAVE_FREE 1 53 | #define HAVE_ALLOCA 1 54 | #define HAVE_GETENV 1 55 | #define HAVE_PUTENV 1 56 | #define HAVE_QSORT 1 57 | #define HAVE_ABS 1 58 | #define HAVE_BCOPY 1 59 | #define HAVE_MEMSET 1 60 | #define HAVE_MEMCPY 1 61 | #define HAVE_MEMMOVE 1 62 | #define HAVE_MEMCMP 1 63 | #define HAVE_STRLEN 1 64 | #define HAVE_STRDUP 1 65 | #define HAVE_INDEX 1 66 | #define HAVE_RINDEX 1 67 | #define HAVE_STRCHR 1 68 | #define HAVE_STRRCHR 1 69 | #define HAVE_STRSTR 1 70 | #define HAVE_STRTOL 1 71 | #define HAVE_STRTOD 1 72 | #define HAVE_ATOI 1 73 | #define HAVE_ATOF 1 74 | #define HAVE_STRCMP 1 75 | #define HAVE_STRNCMP 1 76 | #define HAVE_STRICMP 1 77 | #define HAVE_STRCASECMP 1 78 | #define HAVE_SSCANF 1 79 | #define HAVE_SNPRINTF 1 80 | #define HAVE_VSNPRINTF 1 81 | 82 | /* Enable various audio drivers */ 83 | #define SDL_AUDIO_DRIVER_DC 1 84 | #define SDL_AUDIO_DRIVER_DISK 1 85 | #define SDL_AUDIO_DRIVER_DUMMY 1 86 | 87 | /* Enable various cdrom drivers */ 88 | #define SDL_CDROM_DC 1 89 | 90 | /* Enable various input drivers */ 91 | #define SDL_JOYSTICK_DC 1 92 | 93 | /* Enable various shared object loading systems */ 94 | #define SDL_LOADSO_DUMMY 1 95 | 96 | /* Enable various threading systems */ 97 | #define SDL_THREAD_DC 1 98 | 99 | /* Enable various timer systems */ 100 | #define SDL_TIMER_DC 1 101 | 102 | /* Enable various video drivers */ 103 | #define SDL_VIDEO_DRIVER_DC 1 104 | #define SDL_VIDEO_DRIVER_DUMMY 1 105 | 106 | #endif /* _SDL_config_dreamcast_h */ 107 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_macos.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_macos_h 24 | #define _SDL_config_macos_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | #include 31 | 32 | typedef SInt8 int8_t; 33 | typedef UInt8 uint8_t; 34 | typedef SInt16 int16_t; 35 | typedef UInt16 uint16_t; 36 | typedef SInt32 int32_t; 37 | typedef UInt32 uint32_t; 38 | typedef SInt64 int64_t; 39 | typedef UInt64 uint64_t; 40 | typedef unsigned long uintptr_t; 41 | 42 | #define SDL_HAS_64BIT_TYPE 1 43 | 44 | /* Useful headers */ 45 | #define HAVE_STDIO_H 1 46 | #define STDC_HEADERS 1 47 | #define HAVE_STRING_H 1 48 | #define HAVE_CTYPE_H 1 49 | #define HAVE_MATH_H 1 50 | #define HAVE_SIGNAL_H 1 51 | 52 | /* C library functions */ 53 | #define HAVE_MALLOC 1 54 | #define HAVE_CALLOC 1 55 | #define HAVE_REALLOC 1 56 | #define HAVE_FREE 1 57 | #define HAVE_ALLOCA 1 58 | #define HAVE_ABS 1 59 | #define HAVE_MEMSET 1 60 | #define HAVE_MEMCPY 1 61 | #define HAVE_MEMMOVE 1 62 | #define HAVE_MEMCMP 1 63 | #define HAVE_STRLEN 1 64 | #define HAVE_STRCHR 1 65 | #define HAVE_STRRCHR 1 66 | #define HAVE_STRSTR 1 67 | #define HAVE_ITOA 1 68 | #define HAVE_STRTOL 1 69 | #define HAVE_STRTOD 1 70 | #define HAVE_ATOI 1 71 | #define HAVE_ATOF 1 72 | #define HAVE_STRCMP 1 73 | #define HAVE_STRNCMP 1 74 | #define HAVE_SSCANF 1 75 | 76 | /* Enable various audio drivers */ 77 | #define SDL_AUDIO_DRIVER_SNDMGR 1 78 | #define SDL_AUDIO_DRIVER_DISK 1 79 | #define SDL_AUDIO_DRIVER_DUMMY 1 80 | 81 | /* Enable various cdrom drivers */ 82 | #if TARGET_API_MAC_CARBON 83 | #define SDL_CDROM_DUMMY 1 84 | #else 85 | #define SDL_CDROM_MACOS 1 86 | #endif 87 | 88 | /* Enable various input drivers */ 89 | #if TARGET_API_MAC_CARBON 90 | #define SDL_JOYSTICK_DUMMY 1 91 | #else 92 | #define SDL_JOYSTICK_MACOS 1 93 | #endif 94 | 95 | /* Enable various shared object loading systems */ 96 | #define SDL_LOADSO_MACOS 1 97 | 98 | /* Enable various threading systems */ 99 | #define SDL_THREADS_DISABLED 1 100 | 101 | /* Enable various timer systems */ 102 | #define SDL_TIMER_MACOS 1 103 | 104 | /* Enable various video drivers */ 105 | #define SDL_VIDEO_DRIVER_DUMMY 1 106 | #define SDL_VIDEO_DRIVER_DRAWSPROCKET 1 107 | #define SDL_VIDEO_DRIVER_TOOLBOX 1 108 | 109 | /* Enable OpenGL support */ 110 | #define SDL_VIDEO_OPENGL 1 111 | 112 | #endif /* _SDL_config_macos_h */ 113 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_minimal.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_minimal_h 24 | #define _SDL_config_minimal_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is the minimal configuration that can be used to build SDL */ 29 | 30 | #include 31 | 32 | typedef signed char int8_t; 33 | typedef unsigned char uint8_t; 34 | typedef signed short int16_t; 35 | typedef unsigned short uint16_t; 36 | typedef signed int int32_t; 37 | typedef unsigned int uint32_t; 38 | typedef unsigned int size_t; 39 | typedef unsigned long uintptr_t; 40 | 41 | /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ 42 | #define SDL_AUDIO_DRIVER_DUMMY 1 43 | 44 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 45 | #define SDL_CDROM_DISABLED 1 46 | 47 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 48 | #define SDL_JOYSTICK_DISABLED 1 49 | 50 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 51 | #define SDL_LOADSO_DISABLED 1 52 | 53 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 54 | #define SDL_THREADS_DISABLED 1 55 | 56 | /* Enable the stub timer support (src/timer/dummy/\*.c) */ 57 | #define SDL_TIMERS_DISABLED 1 58 | 59 | /* Enable the dummy video driver (src/video/dummy/\*.c) */ 60 | #define SDL_VIDEO_DRIVER_DUMMY 1 61 | 62 | #endif /* _SDL_config_minimal_h */ 63 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_nds.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_nds_h 24 | #define _SDL_config_nds_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | /* General platform specific identifiers */ 31 | #include "SDL_platform.h" 32 | 33 | /* C datatypes */ 34 | #define SDL_HAS_64BIT_TYPE 1 35 | 36 | /* Endianness */ 37 | #define SDL_BYTEORDER 1234 38 | 39 | /* Useful headers */ 40 | #define HAVE_ALLOCA_H 1 41 | #define HAVE_SYS_TYPES_H 1 42 | #define HAVE_STDIO_H 1 43 | #define STDC_HEADERS 1 44 | #define HAVE_STDLIB_H 1 45 | #define HAVE_STDARG_H 1 46 | #define HAVE_MALLOC_H 1 47 | #define HAVE_STRING_H 1 48 | #define HAVE_INTTYPES_H 1 49 | #define HAVE_STDINT_H 1 50 | #define HAVE_CTYPE_H 1 51 | #define HAVE_MATH_H 1 52 | #define HAVE_ICONV_H 1 53 | #define HAVE_SIGNAL_H 1 54 | 55 | /* C library functions */ 56 | #define HAVE_MALLOC 1 57 | #define HAVE_CALLOC 1 58 | #define HAVE_REALLOC 1 59 | #define HAVE_FREE 1 60 | #define HAVE_ALLOCA 1 61 | #define HAVE_GETENV 1 62 | #define HAVE_PUTENV 1 63 | #define HAVE_UNSETENV 1 64 | #define HAVE_QSORT 1 65 | #define HAVE_ABS 1 66 | #define HAVE_BCOPY 1 67 | #define HAVE_MEMSET 1 68 | #define HAVE_MEMCPY 1 69 | #define HAVE_MEMMOVE 1 70 | #define HAVE_STRLEN 1 71 | #define HAVE_STRLCPY 1 72 | #define HAVE_STRLCAT 1 73 | #define HAVE_STRDUP 1 74 | #define HAVE_STRCHR 1 75 | #define HAVE_STRRCHR 1 76 | #define HAVE_STRSTR 1 77 | #define HAVE_STRTOL 1 78 | #define HAVE_STRTOUL 1 79 | #define HAVE_STRTOLL 1 80 | #define HAVE_STRTOULL 1 81 | #define HAVE_ATOI 1 82 | #define HAVE_ATOF 1 83 | #define HAVE_STRCMP 1 84 | #define HAVE_STRNCMP 1 85 | #define HAVE_STRCASECMP 1 86 | #define HAVE_STRNCASECMP 1 87 | #define HAVE_SSCANF 1 88 | #define HAVE_SNPRINTF 1 89 | #define HAVE_VSNPRINTF 1 90 | #define HAVE_SETJMP 1 91 | 92 | /* Enable various audio drivers */ 93 | #define SDL_AUDIO_DRIVER_NDS 1 94 | #define SDL_AUDIO_DRIVER_DUMMY 1 95 | 96 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 97 | #define SDL_CDROM_DISABLED 1 98 | 99 | /* Enable various input drivers */ 100 | #define SDL_JOYSTICK_NDS 1 101 | 102 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 103 | #define SDL_LOADSO_DISABLED 1 104 | 105 | /* Enable the stub thread support (src/thread/generic/\*.c) */ 106 | #define SDL_THREADS_DISABLED 1 107 | 108 | /* Enable various timer systems */ 109 | #define SDL_TIMER_NDS 1 110 | 111 | /* Enable various video drivers */ 112 | #define SDL_VIDEO_DRIVER_NDS 1 113 | #define SDL_VIDEO_DRIVER_DUMMY 1 114 | 115 | #endif /* _SDL_config_nds_h */ 116 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_os2.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_config_os2_h 24 | #define _SDL_config_os2_h 25 | 26 | #include "SDL_platform.h" 27 | 28 | /* This is a set of defines to configure the SDL features */ 29 | 30 | typedef signed char int8_t; 31 | typedef unsigned char uint8_t; 32 | typedef signed short int16_t; 33 | typedef unsigned short uint16_t; 34 | typedef signed int int32_t; 35 | typedef unsigned int uint32_t; 36 | typedef unsigned int size_t; 37 | typedef unsigned long uintptr_t; 38 | typedef signed long long int64_t; 39 | typedef unsigned long long uint64_t; 40 | 41 | #define SDL_HAS_64BIT_TYPE 1 42 | 43 | /* Use Watcom's LIBC */ 44 | #define HAVE_LIBC 1 45 | 46 | /* Useful headers */ 47 | #define HAVE_SYS_TYPES_H 1 48 | #define HAVE_STDIO_H 1 49 | #define STDC_HEADERS 1 50 | #define HAVE_STDLIB_H 1 51 | #define HAVE_STDARG_H 1 52 | #define HAVE_MALLOC_H 1 53 | #define HAVE_MEMORY_H 1 54 | #define HAVE_STRING_H 1 55 | #define HAVE_STRINGS_H 1 56 | #define HAVE_INTTYPES_H 1 57 | #define HAVE_STDINT_H 1 58 | #define HAVE_CTYPE_H 1 59 | #define HAVE_MATH_H 1 60 | #define HAVE_SIGNAL_H 1 61 | 62 | /* C library functions */ 63 | #define HAVE_MALLOC 1 64 | #define HAVE_CALLOC 1 65 | #define HAVE_REALLOC 1 66 | #define HAVE_FREE 1 67 | #define HAVE_ALLOCA 1 68 | #define HAVE_GETENV 1 69 | #define HAVE_PUTENV 1 70 | #define HAVE_UNSETENV 1 71 | #define HAVE_QSORT 1 72 | #define HAVE_ABS 1 73 | #define HAVE_BCOPY 1 74 | #define HAVE_MEMSET 1 75 | #define HAVE_MEMCPY 1 76 | #define HAVE_MEMMOVE 1 77 | #define HAVE_MEMCMP 1 78 | #define HAVE_STRLEN 1 79 | #define HAVE_STRLCPY 1 80 | #define HAVE_STRLCAT 1 81 | #define HAVE_STRDUP 1 82 | #define HAVE__STRREV 1 83 | #define HAVE__STRUPR 1 84 | #define HAVE__STRLWR 1 85 | #define HAVE_INDEX 1 86 | #define HAVE_RINDEX 1 87 | #define HAVE_STRCHR 1 88 | #define HAVE_STRRCHR 1 89 | #define HAVE_STRSTR 1 90 | #define HAVE_ITOA 1 91 | #define HAVE__LTOA 1 92 | #define HAVE__UITOA 1 93 | #define HAVE__ULTOA 1 94 | #define HAVE_STRTOL 1 95 | #define HAVE__I64TOA 1 96 | #define HAVE__UI64TOA 1 97 | #define HAVE_STRTOLL 1 98 | #define HAVE_STRTOD 1 99 | #define HAVE_ATOI 1 100 | #define HAVE_ATOF 1 101 | #define HAVE_STRCMP 1 102 | #define HAVE_STRNCMP 1 103 | #define HAVE_STRICMP 1 104 | #define HAVE_STRCASECMP 1 105 | #define HAVE_SSCANF 1 106 | #define HAVE_SNPRINTF 1 107 | #define HAVE_VSNPRINTF 1 108 | #define HAVE_SETJMP 1 109 | #define HAVE_CLOCK_GETTIME 1 110 | 111 | /* Enable various audio drivers */ 112 | #define SDL_AUDIO_DRIVER_DART 1 113 | #define SDL_AUDIO_DRIVER_DISK 1 114 | #define SDL_AUDIO_DRIVER_DUMMY 1 115 | 116 | /* Enable various cdrom drivers */ 117 | #define SDL_CDROM_OS2 1 118 | 119 | /* Enable various input drivers */ 120 | #define SDL_JOYSTICK_OS2 1 121 | 122 | /* Enable various shared object loading systems */ 123 | #define SDL_LOADSO_OS2 1 124 | 125 | /* Enable various threading systems */ 126 | #define SDL_THREAD_OS2 1 127 | 128 | /* Enable various timer systems */ 129 | #define SDL_TIMER_OS2 1 130 | 131 | /* Enable various video drivers */ 132 | #define SDL_VIDEO_DRIVER_DUMMY 1 133 | #define SDL_VIDEO_DRIVER_OS2FS 1 134 | 135 | /* Enable OpenGL support */ 136 | /* Nothing here yet for OS/2... :( */ 137 | 138 | /* Enable assembly routines where available */ 139 | #define SDL_ASSEMBLY_ROUTINES 1 140 | 141 | #endif /* _SDL_config_os2_h */ 142 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_config_symbian.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /* 24 | 25 | Symbian version Markus Mertama 26 | 27 | */ 28 | 29 | 30 | #ifndef _SDL_CONFIG_SYMBIAN_H 31 | #define _SDL_CONFIG_SYMBIAN_H 32 | 33 | #include "SDL_platform.h" 34 | 35 | /* This is the minimal configuration that can be used to build SDL */ 36 | 37 | 38 | #include 39 | #include 40 | 41 | 42 | #ifdef __GCCE__ 43 | #define SYMBIAN32_GCCE 44 | #endif 45 | 46 | #ifndef _SIZE_T_DEFINED 47 | typedef unsigned int size_t; 48 | #endif 49 | 50 | #ifndef _INTPTR_T_DECLARED 51 | typedef unsigned int uintptr_t; 52 | #endif 53 | 54 | #ifndef _INT8_T_DECLARED 55 | typedef signed char int8_t; 56 | #endif 57 | 58 | #ifndef _UINT8_T_DECLARED 59 | typedef unsigned char uint8_t; 60 | #endif 61 | 62 | #ifndef _INT16_T_DECLARED 63 | typedef signed short int16_t; 64 | #endif 65 | 66 | #ifndef _UINT16_T_DECLARED 67 | typedef unsigned short uint16_t; 68 | #endif 69 | 70 | #ifndef _INT32_T_DECLARED 71 | typedef signed int int32_t; 72 | #endif 73 | 74 | #ifndef _UINT32_T_DECLARED 75 | typedef unsigned int uint32_t; 76 | #endif 77 | 78 | #ifndef _INT64_T_DECLARED 79 | typedef signed long long int64_t; 80 | #endif 81 | 82 | #ifndef _UINT64_T_DECLARED 83 | typedef unsigned long long uint64_t; 84 | #endif 85 | 86 | #define SDL_AUDIO_DRIVER_EPOCAUDIO 1 87 | 88 | 89 | /* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ 90 | #define SDL_CDROM_DISABLED 1 91 | 92 | /* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ 93 | #define SDL_JOYSTICK_DISABLED 1 94 | 95 | /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ 96 | #define SDL_LOADSO_DISABLED 1 97 | 98 | #define SDL_THREAD_SYMBIAN 1 99 | 100 | #define SDL_VIDEO_DRIVER_EPOC 1 101 | 102 | #define SDL_VIDEO_OPENGL 0 103 | 104 | #define SDL_HAS_64BIT_TYPE 1 105 | 106 | #define HAVE_LIBC 1 107 | #define HAVE_STDIO_H 1 108 | #define STDC_HEADERS 1 109 | #define HAVE_STRING_H 1 110 | #define HAVE_CTYPE_H 1 111 | #define HAVE_MATH_H 1 112 | 113 | #define HAVE_MALLOC 1 114 | #define HAVE_CALLOC 1 115 | #define HAVE_REALLOC 1 116 | #define HAVE_FREE 1 117 | /*#define HAVE_ALLOCA 1*/ 118 | #define HAVE_QSORT 1 119 | #define HAVE_ABS 1 120 | #define HAVE_MEMSET 1 121 | #define HAVE_MEMCPY 1 122 | #define HAVE_MEMMOVE 1 123 | #define HAVE_MEMCMP 1 124 | #define HAVE_STRLEN 1 125 | #define HAVE__STRUPR 1 126 | #define HAVE_STRCHR 1 127 | #define HAVE_STRRCHR 1 128 | #define HAVE_STRSTR 1 129 | #define HAVE_ITOA 1 130 | #define HAVE_STRTOL 1 131 | #define HAVE_STRTOUL 1 132 | #define HAVE_STRTOLL 1 133 | #define HAVE_STRTOD 1 134 | #define HAVE_ATOI 1 135 | #define HAVE_ATOF 1 136 | #define HAVE_STRCMP 1 137 | #define HAVE_STRNCMP 1 138 | /*#define HAVE__STRICMP 1*/ 139 | #define HAVE__STRNICMP 1 140 | #define HAVE_SSCANF 1 141 | #define HAVE_STDARG_H 1 142 | #define HAVE_STDDEF_H 1 143 | 144 | 145 | 146 | #endif /* _SDL_CONFIG_SYMBIAN_H */ 147 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_copying.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_cpuinfo.h 25 | * CPU feature detection for SDL 26 | */ 27 | 28 | #ifndef _SDL_cpuinfo_h 29 | #define _SDL_cpuinfo_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** This function returns true if the CPU has the RDTSC instruction */ 40 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 41 | 42 | /** This function returns true if the CPU has MMX features */ 43 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 44 | 45 | /** This function returns true if the CPU has MMX Ext. features */ 46 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); 47 | 48 | /** This function returns true if the CPU has 3DNow features */ 49 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 50 | 51 | /** This function returns true if the CPU has 3DNow! Ext. features */ 52 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); 53 | 54 | /** This function returns true if the CPU has SSE features */ 55 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 56 | 57 | /** This function returns true if the CPU has SSE2 features */ 58 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 59 | 60 | /** This function returns true if the CPU has AltiVec features */ 61 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_cpuinfo_h */ 70 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_error.h 25 | * Simple error message routines for SDL 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * @name Public functions 41 | */ 42 | /*@{*/ 43 | extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); 44 | extern DECLSPEC char *SDLCALL SDL_GetError(void); 45 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 46 | /*@}*/ 47 | 48 | /** 49 | * @name Private functions 50 | * @internal Private error message function - used internally 51 | */ 52 | /*@{*/ 53 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 54 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 55 | typedef enum { 56 | SDL_ENOMEM, 57 | SDL_EFREAD, 58 | SDL_EFWRITE, 59 | SDL_EFSEEK, 60 | SDL_UNSUPPORTED, 61 | SDL_LASTERROR 62 | } SDL_errorcode; 63 | extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); 64 | /*@}*/ 65 | 66 | /* Ends C function definitions when using C++ */ 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #include "close_code.h" 71 | 72 | #endif /* _SDL_error_h */ 73 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_getenv.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_getenv.h 24 | * @deprecated Use SDL_stdinc.h instead 25 | */ 26 | 27 | /* DEPRECATED */ 28 | #include "SDL_stdinc.h" 29 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_loadso.h 24 | * System dependent library loading routines 25 | */ 26 | 27 | /** @file SDL_loadso.h 28 | * Some things to keep in mind: 29 | * - These functions only work on C function names. Other languages may 30 | * have name mangling and intrinsic language support that varies from 31 | * compiler to compiler. 32 | * - Make sure you declare your function pointers with the same calling 33 | * convention as the actual library function. Your code will crash 34 | * mysteriously if you do not do this. 35 | * - Avoid namespace collisions. If you load a symbol from the library, 36 | * it is not defined whether or not it goes into the global symbol 37 | * namespace for the application. If it does and it conflicts with 38 | * symbols in your code or other shared libraries, you will not get 39 | * the results you expect. :) 40 | */ 41 | 42 | 43 | #ifndef _SDL_loadso_h 44 | #define _SDL_loadso_h 45 | 46 | #include "SDL_stdinc.h" 47 | #include "SDL_error.h" 48 | 49 | #include "begin_code.h" 50 | /* Set up for C function definitions, even when using C++ */ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * This function dynamically loads a shared object and returns a pointer 57 | * to the object handle (or NULL if there was an error). 58 | * The 'sofile' parameter is a system dependent name of the object file. 59 | */ 60 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 61 | 62 | /** 63 | * Given an object handle, this function looks up the address of the 64 | * named function in the shared object and returns it. This address 65 | * is no longer valid after calling SDL_UnloadObject(). 66 | */ 67 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, const char *name); 68 | 69 | /** Unload a shared object from memory */ 70 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 71 | 72 | /* Ends C function definitions when using C++ */ 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #include "close_code.h" 77 | 78 | #endif /* _SDL_loadso_h */ 79 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_main_h 24 | #define _SDL_main_h 25 | 26 | #include "SDL_stdinc.h" 27 | 28 | /** @file SDL_main.h 29 | * Redefine main() on Win32 and MacOS so that it is called by winmain.c 30 | */ 31 | 32 | #if defined(__WIN32__) || \ 33 | (defined(__MWERKS__) && !defined(__BEOS__)) || \ 34 | defined(__MACOS__) || defined(__MACOSX__) || \ 35 | defined(__SYMBIAN32__) || defined(QWS) 36 | 37 | #ifdef __cplusplus 38 | #define C_LINKAGE "C" 39 | #else 40 | #define C_LINKAGE 41 | #endif /* __cplusplus */ 42 | 43 | /** The application's main() function must be called with C linkage, 44 | * and should be declared like this: 45 | * @code 46 | * #ifdef __cplusplus 47 | * extern "C" 48 | * #endif 49 | * int main(int argc, char *argv[]) 50 | * { 51 | * } 52 | * @endcode 53 | */ 54 | #define main SDL_main 55 | 56 | /** The prototype for the application's main() function */ 57 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); 58 | 59 | 60 | /** @name From the SDL library code -- needed for registering the app on Win32 */ 61 | /*@{*/ 62 | #ifdef __WIN32__ 63 | 64 | #include "begin_code.h" 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /** This should be called from your WinMain() function, if any */ 70 | extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); 71 | /** This can also be called, but is no longer necessary */ 72 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); 73 | /** This can also be called, but is no longer necessary (SDL_Quit calls it) */ 74 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | #include "close_code.h" 79 | #endif 80 | /*@}*/ 81 | 82 | /** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ 83 | /*@{*/ 84 | #if defined(__MACOS__) 85 | 86 | #include "begin_code.h" 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | /** Forward declaration so we don't need to include QuickDraw.h */ 92 | struct QDGlobals; 93 | 94 | /** This should be called from your main() function, if any */ 95 | extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | #include "close_code.h" 101 | #endif 102 | /*@}*/ 103 | 104 | #endif /* Need to redefine main()? */ 105 | 106 | #endif /* _SDL_main_h */ 107 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_name.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SDLname_h_ 3 | #define _SDLname_h_ 4 | 5 | #if defined(__STDC__) || defined(__cplusplus) 6 | #define NeedFunctionPrototypes 1 7 | #endif 8 | 9 | #define SDL_NAME(X) SDL_##X 10 | 11 | #endif /* _SDLname_h_ */ 12 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_platform.h 24 | * Try to get a standard set of platform defines 25 | */ 26 | 27 | #ifndef _SDL_platform_h 28 | #define _SDL_platform_h 29 | 30 | #if defined(_AIX) 31 | #undef __AIX__ 32 | #define __AIX__ 1 33 | #endif 34 | #if defined(__BEOS__) 35 | #undef __BEOS__ 36 | #define __BEOS__ 1 37 | #endif 38 | #if defined(__HAIKU__) 39 | #undef __HAIKU__ 40 | #define __HAIKU__ 1 41 | #endif 42 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 43 | #undef __BSDI__ 44 | #define __BSDI__ 1 45 | #endif 46 | #if defined(_arch_dreamcast) 47 | #undef __DREAMCAST__ 48 | #define __DREAMCAST__ 1 49 | #endif 50 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 51 | #undef __FREEBSD__ 52 | #define __FREEBSD__ 1 53 | #endif 54 | #if defined(__HAIKU__) 55 | #undef __HAIKU__ 56 | #define __HAIKU__ 1 57 | #endif 58 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 59 | #undef __HPUX__ 60 | #define __HPUX__ 1 61 | #endif 62 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 63 | #undef __IRIX__ 64 | #define __IRIX__ 1 65 | #endif 66 | #if defined(linux) || defined(__linux) || defined(__linux__) 67 | #undef __LINUX__ 68 | #define __LINUX__ 1 69 | #endif 70 | #if defined(__APPLE__) 71 | #undef __MACOSX__ 72 | #define __MACOSX__ 1 73 | #elif defined(macintosh) 74 | #undef __MACOS__ 75 | #define __MACOS__ 1 76 | #endif 77 | #if defined(__NetBSD__) 78 | #undef __NETBSD__ 79 | #define __NETBSD__ 1 80 | #endif 81 | #if defined(__OpenBSD__) 82 | #undef __OPENBSD__ 83 | #define __OPENBSD__ 1 84 | #endif 85 | #if defined(__OS2__) 86 | #undef __OS2__ 87 | #define __OS2__ 1 88 | #endif 89 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 90 | #undef __OSF__ 91 | #define __OSF__ 1 92 | #endif 93 | #if defined(__QNXNTO__) 94 | #undef __QNXNTO__ 95 | #define __QNXNTO__ 1 96 | #endif 97 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 98 | #undef __RISCOS__ 99 | #define __RISCOS__ 1 100 | #endif 101 | #if defined(__SVR4) 102 | #undef __SOLARIS__ 103 | #define __SOLARIS__ 1 104 | #endif 105 | #if defined(WIN32) || defined(_WIN32) 106 | #undef __WIN32__ 107 | #define __WIN32__ 1 108 | #endif 109 | 110 | #endif /* _SDL_platform_h */ 111 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_quit.h 24 | * Include file for SDL quit event handling 25 | */ 26 | 27 | #ifndef _SDL_quit_h 28 | #define _SDL_quit_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | 33 | /** @file SDL_quit.h 34 | * An SDL_QUITEVENT is generated when the user tries to close the application 35 | * window. If it is ignored or filtered out, the window will remain open. 36 | * If it is not ignored or filtered, it is queued normally and the window 37 | * is allowed to close. When the window is closed, screen updates will 38 | * complete, but have no effect. 39 | * 40 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 41 | * and SIGTERM (system termination request), if handlers do not already 42 | * exist, that generate SDL_QUITEVENT events as well. There is no way 43 | * to determine the cause of an SDL_QUITEVENT, but setting a signal 44 | * handler in your application will override the default generation of 45 | * quit events for that signal. 46 | */ 47 | 48 | /** @file SDL_quit.h 49 | * There are no functions directly affecting the quit event 50 | */ 51 | 52 | #define SDL_QuitRequested() \ 53 | (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) 54 | 55 | #endif /* _SDL_quit_h */ 56 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_types.h 24 | * @deprecated Use SDL_stdinc.h instead. 25 | */ 26 | 27 | /* DEPRECATED */ 28 | #include "SDL_stdinc.h" 29 | -------------------------------------------------------------------------------- /msvc/include/SDL/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_version.h 24 | * This header defines the current SDL version 25 | */ 26 | 27 | #ifndef _SDL_version_h 28 | #define _SDL_version_h 29 | 30 | #include "SDL_stdinc.h" 31 | 32 | #include "begin_code.h" 33 | /* Set up for C function definitions, even when using C++ */ 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @name Version Number 39 | * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 40 | */ 41 | /*@{*/ 42 | #define SDL_MAJOR_VERSION 1 43 | #define SDL_MINOR_VERSION 2 44 | #define SDL_PATCHLEVEL 14 45 | /*@}*/ 46 | 47 | typedef struct SDL_version { 48 | Uint8 major; 49 | Uint8 minor; 50 | Uint8 patch; 51 | } SDL_version; 52 | 53 | /** 54 | * This macro can be used to fill a version structure with the compile-time 55 | * version of the SDL library. 56 | */ 57 | #define SDL_VERSION(X) \ 58 | { \ 59 | (X)->major = SDL_MAJOR_VERSION; \ 60 | (X)->minor = SDL_MINOR_VERSION; \ 61 | (X)->patch = SDL_PATCHLEVEL; \ 62 | } 63 | 64 | /** This macro turns the version numbers into a numeric value: 65 | * (1,2,3) -> (1203) 66 | * This assumes that there will never be more than 100 patchlevels 67 | */ 68 | #define SDL_VERSIONNUM(X, Y, Z) \ 69 | ((X)*1000 + (Y)*100 + (Z)) 70 | 71 | /** This is the version number macro for the current SDL version */ 72 | #define SDL_COMPILEDVERSION \ 73 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 74 | 75 | /** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ 76 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 77 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 78 | 79 | /** This function gets the version of the dynamically linked SDL library. 80 | * it should NOT be used to fill a version structure, instead you should 81 | * use the SDL_Version() macro. 82 | */ 83 | extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void); 84 | 85 | /* Ends C function definitions when using C++ */ 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #include "close_code.h" 90 | 91 | #endif /* _SDL_version_h */ 92 | -------------------------------------------------------------------------------- /msvc/include/SDL/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2009 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file close_code.h 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /** 32 | * @file close_code.h 33 | * Reset structure packing at previous byte alignment 34 | */ 35 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 36 | #ifdef __BORLANDC__ 37 | #pragma nopackwarning 38 | #endif 39 | #if (defined(__MWERKS__) && defined(__MACOS__)) 40 | #pragma options align=reset 41 | #pragma enumsalwaysint reset 42 | #else 43 | #pragma pack(pop) 44 | #endif 45 | #endif /* Compiler needs structure packing set */ 46 | 47 | -------------------------------------------------------------------------------- /msvc/include/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | /* internal API definitions */ 22 | #ifndef __API_H__ 23 | #define __API_H__ 24 | 25 | #ifndef CALLING_FFTW /* defined in hook.c, when calling internal functions */ 26 | # define COMPILING_FFTW /* used for DLL symbol exporting in fftw3.h */ 27 | #endif 28 | 29 | /* When compiling with GNU libtool on Windows, DLL_EXPORT is #defined 30 | for compiling the shared-library code. In this case, we'll #define 31 | FFTW_DLL to add dllexport attributes to the specified functions in 32 | fftw3.h. 33 | 34 | If we don't specify dllexport explicitly, then libtool 35 | automatically exports all symbols. However, if we specify 36 | dllexport explicitly for any functions, then libtool apparently 37 | doesn't do any automatic exporting. (Not documented, grrr, but 38 | this is the observed behavior with libtool 1.5.8.) Thus, using 39 | this forces us to correctly dllexport every exported symbol, or 40 | linking bench.exe will fail. This has the advantage of forcing 41 | us to mark things correctly, which is necessary for other compilers 42 | (such as MS VC++). */ 43 | #ifdef DLL_EXPORT 44 | # define FFTW_DLL 45 | #endif 46 | 47 | /* just in case: force not to use C99 complex numbers 48 | (we need this for IBM xlc because _Complex_I is treated specially 49 | and is defined even if is not included) */ 50 | #define FFTW_NO_Complex 51 | 52 | #include "fftw3.h" 53 | #include "ifftw.h" 54 | 55 | /* the API ``plan'' contains both the kernel plan and problem */ 56 | struct X(plan_s) { 57 | plan *pln; 58 | problem *prb; 59 | int sign; 60 | }; 61 | 62 | /* shorthand */ 63 | typedef struct X(plan_s) apiplan; 64 | 65 | /* complex type for internal use */ 66 | typedef R C[2]; 67 | 68 | #define EXTRACT_REIM(sign, c, r, i) X(extract_reim)(sign, (c)[0], r, i) 69 | 70 | #define TAINT_UNALIGNED(p, flg) TAINT(p, ((flg) & FFTW_UNALIGNED) != 0) 71 | 72 | tensor *X(mktensor_rowmajor)(int rnk, const int *n, 73 | const int *niphys, const int *nophys, 74 | int is, int os); 75 | 76 | tensor *X(mktensor_iodims)(int rank, const X(iodim) *dims, int is, int os); 77 | tensor *X(mktensor_iodims64)(int rank, const X(iodim64) *dims, int is, int os); 78 | const int *X(rdft2_pad)(int rnk, const int *n, const int *nembed, 79 | int inplace, int cmplx, int **nfree); 80 | 81 | int X(many_kosherp)(int rnk, const int *n, int howmany); 82 | int X(guru_kosherp)(int rank, const X(iodim) *dims, 83 | int howmany_rank, const X(iodim) *howmany_dims); 84 | int X(guru64_kosherp)(int rank, const X(iodim64) *dims, 85 | int howmany_rank, const X(iodim64) *howmany_dims); 86 | 87 | /* Note: FFTW_EXTERN is used for "internal" functions used in tests/hook.c */ 88 | 89 | FFTW_EXTERN printer *X(mkprinter_file)(FILE *f); 90 | 91 | FFTW_EXTERN planner *X(the_planner)(void); 92 | void X(configure_planner)(planner *plnr); 93 | 94 | void X(mapflags)(planner *, unsigned); 95 | 96 | apiplan *X(mkapiplan)(int sign, unsigned flags, problem *prb); 97 | 98 | #endif /* __API_H__ */ 99 | -------------------------------------------------------------------------------- /msvc/include/guru.h: -------------------------------------------------------------------------------- 1 | #define XGURU(name) X(plan_guru_ ## name) 2 | #define IODIM X(iodim) 3 | #define MKTENSOR_IODIMS X(mktensor_iodims) 4 | #define GURU_KOSHERP X(guru_kosherp) 5 | -------------------------------------------------------------------------------- /msvc/include/guru64.h: -------------------------------------------------------------------------------- 1 | #define XGURU(name) X(plan_guru64_ ## name) 2 | #define IODIM X(iodim64) 3 | #define MKTENSOR_IODIMS X(mktensor_iodims64) 4 | #define GURU_KOSHERP X(guru64_kosherp) 5 | -------------------------------------------------------------------------------- /msvc/include/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /msvc/include/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR *FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /msvc/include/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ 2 | /* see jconfig.txt for explanations */ 3 | 4 | #define HAVE_PROTOTYPES 5 | #define HAVE_UNSIGNED_CHAR 6 | #define HAVE_UNSIGNED_SHORT 7 | /* #define void char */ 8 | /* #define const */ 9 | #undef CHAR_IS_UNSIGNED 10 | #define HAVE_STDDEF_H 11 | #define HAVE_STDLIB_H 12 | #undef NEED_BSD_STRINGS 13 | #undef NEED_SYS_TYPES_H 14 | #undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */ 15 | #undef NEED_SHORT_EXTERNAL_NAMES 16 | #undef INCOMPLETE_TYPES_BROKEN 17 | 18 | /* Define "boolean" as unsigned char, not int, per Windows custom */ 19 | #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ 20 | typedef unsigned char boolean; 21 | #endif 22 | #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ 23 | 24 | 25 | #ifdef JPEG_INTERNALS 26 | 27 | #undef RIGHT_SHIFT_IS_UNSIGNED 28 | 29 | #endif /* JPEG_INTERNALS */ 30 | 31 | #ifdef JPEG_CJPEG_DJPEG 32 | 33 | #define BMP_SUPPORTED /* BMP image file format */ 34 | #define GIF_SUPPORTED /* GIF image file format */ 35 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 36 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 37 | #define TARGA_SUPPORTED /* Targa image file format */ 38 | 39 | #define TWO_FILE_COMMANDLINE /* optional */ 40 | #define USE_SETMODE /* Microsoft has setmode() */ 41 | #undef NEED_SIGNAL_CATCHER 42 | #undef DONT_USE_B_MODE 43 | #undef PROGRESS_REPORT /* optional */ 44 | 45 | #endif /* JPEG_CJPEG_DJPEG */ 46 | -------------------------------------------------------------------------------- /msvc/include/jinclude.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jinclude.h 3 | * 4 | * Copyright (C) 1991-1994, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file exists to provide a single place to fix any problems with 9 | * including the wrong system include files. (Common problems are taken 10 | * care of by the standard jconfig symbols, but on really weird systems 11 | * you may have to edit this file.) 12 | * 13 | * NOTE: this file is NOT intended to be included by applications using the 14 | * JPEG library. Most applications need only include jpeglib.h. 15 | */ 16 | 17 | 18 | /* Include auto-config file to find out which system include files we need. */ 19 | 20 | #include "jconfig.h" /* auto configuration options */ 21 | #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 22 | 23 | /* 24 | * We need the NULL macro and size_t typedef. 25 | * On an ANSI-conforming system it is sufficient to include . 26 | * Otherwise, we get them from or ; we may have to 27 | * pull in as well. 28 | * Note that the core JPEG library does not require ; 29 | * only the default error handler and data source/destination modules do. 30 | * But we must pull it in because of the references to FILE in jpeglib.h. 31 | * You can remove those references if you want to compile without . 32 | */ 33 | 34 | #ifdef HAVE_STDDEF_H 35 | #include 36 | #endif 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | #ifdef NEED_SYS_TYPES_H 43 | #include 44 | #endif 45 | 46 | #include 47 | 48 | /* 49 | * We need memory copying and zeroing functions, plus strncpy(). 50 | * ANSI and System V implementations declare these in . 51 | * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 52 | * Some systems may declare memset and memcpy in . 53 | * 54 | * NOTE: we assume the size parameters to these functions are of type size_t. 55 | * Change the casts in these macros if not! 56 | */ 57 | 58 | #ifdef NEED_BSD_STRINGS 59 | 60 | #include 61 | #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 62 | #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 63 | 64 | #else /* not BSD, assume ANSI/SysV string lib */ 65 | 66 | #include 67 | #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 68 | #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 69 | 70 | #endif 71 | 72 | /* 73 | * In ANSI C, and indeed any rational implementation, size_t is also the 74 | * type returned by sizeof(). However, it seems there are some irrational 75 | * implementations out there, in which sizeof() returns an int even though 76 | * size_t is defined as long or unsigned long. To ensure consistent results 77 | * we always use this SIZEOF() macro in place of using sizeof() directly. 78 | */ 79 | 80 | #define SIZEOF(object) ((size_t) sizeof(object)) 81 | 82 | /* 83 | * The modules that use fread() and fwrite() always invoke them through 84 | * these macros. On some systems you may need to twiddle the argument casts. 85 | * CAUTION: argument order is different from underlying functions! 86 | */ 87 | 88 | #define JFREAD(file,buf,sizeofbuf) \ 89 | ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 90 | #define JFWRITE(file,buf,sizeofbuf) \ 91 | ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 92 | -------------------------------------------------------------------------------- /msvc/include/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "8a 28-Feb-2010" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding" 15 | -------------------------------------------------------------------------------- /msvc/include/mktensor-iodims.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | 23 | tensor *MKTENSOR_IODIMS(int rank, const IODIM *dims, int is, int os) { 24 | int i; 25 | tensor *x = X(mktensor)(rank); 26 | 27 | if (FINITE_RNK(rank)) { 28 | for (i = 0; i < rank; ++i) { 29 | x->dims[i].n = dims[i].n; 30 | x->dims[i].is = dims[i].is * is; 31 | x->dims[i].os = dims[i].os * os; 32 | } 33 | } 34 | return x; 35 | } 36 | 37 | static int iodims_kosherp(int rank, const IODIM *dims, int allow_minfty) { 38 | int i; 39 | 40 | if (rank < 0) { return 0; } 41 | 42 | if (allow_minfty) { 43 | if (!FINITE_RNK(rank)) { return 1; } 44 | for (i = 0; i < rank; ++i) 45 | if (dims[i].n < 0) { return 0; } 46 | } else { 47 | if (!FINITE_RNK(rank)) { return 0; } 48 | for (i = 0; i < rank; ++i) 49 | if (dims[i].n <= 0) { return 0; } 50 | } 51 | 52 | return 1; 53 | } 54 | 55 | int GURU_KOSHERP(int rank, const IODIM *dims, 56 | int howmany_rank, const IODIM *howmany_dims) { 57 | return (iodims_kosherp(rank, dims, 0) && 58 | iodims_kosherp(howmany_rank, howmany_dims, 1)); 59 | } 60 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-dft-c2r.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "rdft.h" 23 | 24 | X(plan) XGURU(dft_c2r)(int rank, const IODIM *dims, 25 | int howmany_rank, const IODIM *howmany_dims, 26 | C *in, R *out, unsigned flags) { 27 | R *ri, *ii; 28 | 29 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 30 | 31 | EXTRACT_REIM(FFT_SIGN, in, &ri, &ii); 32 | 33 | if (out != ri) { 34 | flags |= FFTW_DESTROY_INPUT; 35 | } 36 | return X(mkapiplan)( 37 | 0, flags, 38 | X(mkproblem_rdft2_d_3pointers)( 39 | MKTENSOR_IODIMS(rank, dims, 2, 1), 40 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 2, 1), 41 | TAINT_UNALIGNED(out, flags), 42 | TAINT_UNALIGNED(ri, flags), 43 | TAINT_UNALIGNED(ii, flags), HC2R)); 44 | } 45 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-dft-r2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "rdft.h" 23 | 24 | X(plan) XGURU(dft_r2c)(int rank, const IODIM *dims, 25 | int howmany_rank, 26 | const IODIM *howmany_dims, 27 | R *in, C *out, unsigned flags) { 28 | R *ro, *io; 29 | 30 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 31 | 32 | EXTRACT_REIM(FFT_SIGN, out, &ro, &io); 33 | 34 | return X(mkapiplan)( 35 | 0, flags, 36 | X(mkproblem_rdft2_d_3pointers)( 37 | MKTENSOR_IODIMS(rank, dims, 1, 2), 38 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 1, 2), 39 | TAINT_UNALIGNED(in, flags), 40 | TAINT_UNALIGNED(ro, flags), 41 | TAINT_UNALIGNED(io, flags), R2HC)); 42 | } 43 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-dft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "dft.h" 23 | 24 | X(plan) XGURU(dft)(int rank, const IODIM *dims, 25 | int howmany_rank, const IODIM *howmany_dims, 26 | C *in, C *out, int sign, unsigned flags) { 27 | R *ri, *ii, *ro, *io; 28 | 29 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 30 | 31 | EXTRACT_REIM(sign, in, &ri, &ii); 32 | EXTRACT_REIM(sign, out, &ro, &io); 33 | 34 | return X(mkapiplan)( 35 | sign, flags, 36 | X(mkproblem_dft_d)(MKTENSOR_IODIMS(rank, dims, 2, 2), 37 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 38 | 2, 2), 39 | TAINT_UNALIGNED(ri, flags), 40 | TAINT_UNALIGNED(ii, flags), 41 | TAINT_UNALIGNED(ro, flags), 42 | TAINT_UNALIGNED(io, flags))); 43 | } 44 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-r2r.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "rdft.h" 23 | 24 | rdft_kind *X(map_r2r_kind)(int rank, const X(r2r_kind) * kind); 25 | 26 | X(plan) XGURU(r2r)(int rank, const IODIM *dims, 27 | int howmany_rank, 28 | const IODIM *howmany_dims, 29 | R *in, R *out, 30 | const X(r2r_kind) * kind, unsigned flags) { 31 | X(plan) p; 32 | rdft_kind *k; 33 | 34 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 35 | 36 | k = X(map_r2r_kind)(rank, kind); 37 | p = X(mkapiplan)( 38 | 0, flags, 39 | X(mkproblem_rdft_d)(MKTENSOR_IODIMS(rank, dims, 1, 1), 40 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 41 | 1, 1), 42 | TAINT_UNALIGNED(in, flags), 43 | TAINT_UNALIGNED(out, flags), k)); 44 | X(ifree0)(k); 45 | return p; 46 | } 47 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-split-dft-c2r.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "rdft.h" 23 | 24 | X(plan) XGURU(split_dft_c2r)(int rank, const IODIM *dims, 25 | int howmany_rank, const IODIM *howmany_dims, 26 | R *ri, R *ii, R *out, unsigned flags) { 27 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 28 | 29 | if (out != ri) { 30 | flags |= FFTW_DESTROY_INPUT; 31 | } 32 | return X(mkapiplan)( 33 | 0, flags, 34 | X(mkproblem_rdft2_d_3pointers)( 35 | MKTENSOR_IODIMS(rank, dims, 1, 1), 36 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 1, 1), 37 | TAINT_UNALIGNED(out, flags), 38 | TAINT_UNALIGNED(ri, flags), 39 | TAINT_UNALIGNED(ii, flags), HC2R)); 40 | } 41 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-split-dft-r2c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "rdft.h" 23 | 24 | X(plan) XGURU(split_dft_r2c)(int rank, const IODIM *dims, 25 | int howmany_rank, 26 | const IODIM *howmany_dims, 27 | R *in, R *ro, R *io, unsigned flags) { 28 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 29 | 30 | return X(mkapiplan)( 31 | 0, flags, 32 | X(mkproblem_rdft2_d_3pointers)( 33 | MKTENSOR_IODIMS(rank, dims, 1, 1), 34 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 1, 1), 35 | TAINT_UNALIGNED(in, flags), 36 | TAINT_UNALIGNED(ro, flags), 37 | TAINT_UNALIGNED(io, flags), R2HC)); 38 | } 39 | -------------------------------------------------------------------------------- /msvc/include/plan-guru-split-dft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2003, 2007-8 Matteo Frigo 3 | * Copyright (c) 2003, 2007-8 Massachusetts Institute of Technology 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | * 19 | */ 20 | 21 | #include "api.h" 22 | #include "dft.h" 23 | 24 | X(plan) XGURU(split_dft)(int rank, const IODIM *dims, 25 | int howmany_rank, const IODIM *howmany_dims, 26 | R *ri, R *ii, R *ro, R *io, unsigned flags) { 27 | if (!GURU_KOSHERP(rank, dims, howmany_rank, howmany_dims)) { return 0; } 28 | 29 | return X(mkapiplan)( 30 | ii - ri == 1 && io - ro == 1 ? FFT_SIGN : -FFT_SIGN, flags, 31 | X(mkproblem_dft_d)(MKTENSOR_IODIMS(rank, dims, 1, 1), 32 | MKTENSOR_IODIMS(howmany_rank, howmany_dims, 33 | 1, 1), 34 | TAINT_UNALIGNED(ri, flags), 35 | TAINT_UNALIGNED(ii, flags), 36 | TAINT_UNALIGNED(ro, flags), 37 | TAINT_UNALIGNED(io, flags))); 38 | } 39 | -------------------------------------------------------------------------------- /msvc/include/tif_predict.h: -------------------------------------------------------------------------------- 1 | /* $Id: tif_predict.h,v 1.3.2.1 2007/11/22 21:24:51 fwarmerdam Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1995-1997 Sam Leffler 5 | * Copyright (c) 1995-1997 Silicon Graphics, Inc. 6 | * 7 | * Permission to use, copy, modify, distribute, and sell this software and 8 | * its documentation for any purpose is hereby granted without fee, provided 9 | * that (i) the above copyright notices and this permission notice appear in 10 | * all copies of the software and related documentation, and (ii) the names of 11 | * Sam Leffler and Silicon Graphics may not be used in any advertising or 12 | * publicity relating to the software without the specific, prior written 13 | * permission of Sam Leffler and Silicon Graphics. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18 | * 19 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24 | * OF THIS SOFTWARE. 25 | */ 26 | 27 | #ifndef _TIFFPREDICT_ 28 | #define _TIFFPREDICT_ 29 | /* 30 | * ``Library-private'' Support for the Predictor Tag 31 | */ 32 | 33 | /* 34 | * Codecs that want to support the Predictor tag must place 35 | * this structure first in their private state block so that 36 | * the predictor code can cast tif_data to find its state. 37 | */ 38 | typedef struct { 39 | int predictor; /* predictor tag value */ 40 | int stride; /* sample stride over data */ 41 | tsize_t rowsize; /* tile/strip row size */ 42 | 43 | TIFFCodeMethod encoderow; /* parent codec encode/decode row */ 44 | TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */ 45 | TIFFCodeMethod encodetile; /* parent codec encode/decode tile */ 46 | TIFFPostMethod encodepfunc; /* horizontal differencer */ 47 | 48 | TIFFCodeMethod decoderow; /* parent codec encode/decode row */ 49 | TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */ 50 | TIFFCodeMethod decodetile; /* parent codec encode/decode tile */ 51 | TIFFPostMethod decodepfunc; /* horizontal accumulator */ 52 | 53 | TIFFVGetMethod vgetparent; /* super-class method */ 54 | TIFFVSetMethod vsetparent; /* super-class method */ 55 | TIFFPrintMethod printdir; /* super-class method */ 56 | TIFFBoolMethod setupdecode; /* super-class method */ 57 | TIFFBoolMethod setupencode; /* super-class method */ 58 | } TIFFPredictorState; 59 | 60 | #if defined(__cplusplus) 61 | extern "C" { 62 | #endif 63 | extern int TIFFPredictorInit(TIFF *); 64 | extern int TIFFPredictorCleanup(TIFF *); 65 | #if defined(__cplusplus) 66 | } 67 | #endif 68 | #endif /* _TIFFPREDICT_ */ 69 | 70 | /* vim: set ts=8 sts=8 sw=8 noet: */ 71 | -------------------------------------------------------------------------------- /msvc/include/tiffconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | Configuration defines for installed libtiff. 3 | This file maintained for backward compatibility. Do not use definitions 4 | from this file in your programs. 5 | */ 6 | 7 | #ifndef _TIFFCONF_ 8 | #define _TIFFCONF_ 9 | 10 | /* Define to 1 if the system has the type `int16'. */ 11 | /* #undef HAVE_INT16 */ 12 | 13 | /* Define to 1 if the system has the type `int32'. */ 14 | /* #undef HAVE_INT32 */ 15 | 16 | /* Define to 1 if the system has the type `int8'. */ 17 | /* #undef HAVE_INT8 */ 18 | 19 | /* The size of a `int', as computed by sizeof. */ 20 | #define SIZEOF_INT 4 21 | 22 | /* The size of a `long', as computed by sizeof. */ 23 | #define SIZEOF_LONG 4 24 | 25 | /* Signed 64-bit type formatter */ 26 | #define TIFF_INT64_FORMAT "%I64d" 27 | 28 | /* Signed 64-bit type */ 29 | #define TIFF_INT64_T signed __int64 30 | 31 | /* Unsigned 64-bit type formatter */ 32 | #define TIFF_UINT64_FORMAT "%I64u" 33 | 34 | /* Unsigned 64-bit type */ 35 | #define TIFF_UINT64_T unsigned __int64 36 | 37 | /* Compatibility stuff. */ 38 | 39 | /* Define as 0 or 1 according to the floating point format suported by the 40 | machine */ 41 | #define HAVE_IEEEFP 1 42 | 43 | /* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ 44 | #define HOST_FILLORDER FILLORDER_LSB2MSB 45 | 46 | /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian 47 | (Intel) */ 48 | #define HOST_BIGENDIAN 0 49 | 50 | /* Support CCITT Group 3 & 4 algorithms */ 51 | #define CCITT_SUPPORT 1 52 | 53 | /* Support JPEG compression (requires IJG JPEG library) */ 54 | /* #undef JPEG_SUPPORT */ 55 | 56 | /* Support LogLuv high dynamic range encoding */ 57 | #define LOGLUV_SUPPORT 1 58 | 59 | /* Support LZW algorithm */ 60 | #define LZW_SUPPORT 1 61 | 62 | /* Support NeXT 2-bit RLE algorithm */ 63 | #define NEXT_SUPPORT 1 64 | 65 | /* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation 66 | fails with unpatched IJG JPEG library) */ 67 | /* #undef OJPEG_SUPPORT */ 68 | 69 | /* Support Macintosh PackBits algorithm */ 70 | #define PACKBITS_SUPPORT 1 71 | 72 | /* Support Pixar log-format algorithm (requires Zlib) */ 73 | /* #undef PIXARLOG_SUPPORT */ 74 | 75 | /* Support ThunderScan 4-bit RLE algorithm */ 76 | #define THUNDER_SUPPORT 1 77 | 78 | /* Support Deflate compression */ 79 | /* #undef ZIP_SUPPORT */ 80 | 81 | /* Support strip chopping (whether or not to convert single-strip uncompressed 82 | images to mutiple strips of ~8Kb to reduce memory usage) */ 83 | #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP 84 | 85 | /* Enable SubIFD tag (330) support */ 86 | #define SUBIFD_SUPPORT 1 87 | 88 | /* Treat extra sample as alpha (default enabled). The RGBA interface will 89 | treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many 90 | packages produce RGBA files but don't mark the alpha properly. */ 91 | #define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 92 | 93 | /* Pick up YCbCr subsampling info from the JPEG data stream to support files 94 | lacking the tag (default enabled). */ 95 | #define CHECK_JPEG_YCBCR_SUBSAMPLING 1 96 | 97 | /* 98 | * Feature support definitions. 99 | * XXX: These macros are obsoleted. Don't use them in your apps! 100 | * Macros stays here for backward compatibility and should be always defined. 101 | */ 102 | #define COLORIMETRY_SUPPORT 103 | #define YCBCR_SUPPORT 104 | #define CMYK_SUPPORT 105 | #define ICC_SUPPORT 106 | #define PHOTOSHOP_SUPPORT 107 | #define IPTC_SUPPORT 108 | 109 | #endif /* _TIFFCONF_ */ 110 | -------------------------------------------------------------------------------- /msvc/include/tiffvers.h: -------------------------------------------------------------------------------- 1 | #define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." 2 | /* 3 | * This define can be used in code that requires 4 | * compilation-related definitions specific to a 5 | * version or versions of the library. Runtime 6 | * version checking should be done based on the 7 | * string returned by TIFFGetVersion. 8 | */ 9 | #define TIFFLIB_VERSION 20091104 10 | -------------------------------------------------------------------------------- /msvc/lib/SDL-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/SDL-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/SDL-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/SDL-x86-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/dxguid-x64.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/dxguid-x64.lib -------------------------------------------------------------------------------- /msvc/lib/dxguid-x86.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/dxguid-x86.lib -------------------------------------------------------------------------------- /msvc/lib/libfftw-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libfftw-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libfftw-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libfftw-x86-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libjpeg-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libjpeg-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libjpeg-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libjpeg-x86-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libpng-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libpng-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libpng-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libpng-x86-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libtiff-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libtiff-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/libtiff-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/libtiff-x86-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/zlib-x64-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/zlib-x64-static-mt.lib -------------------------------------------------------------------------------- /msvc/lib/zlib-x86-static-mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/msvc/lib/zlib-x86-static-mt.lib -------------------------------------------------------------------------------- /pics/belgium.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/pics/belgium.hdr -------------------------------------------------------------------------------- /pics/dog1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abadams/ImageStack/24cd9843c83c27a566a71a1c933992c89159957c/pics/dog1.jpg -------------------------------------------------------------------------------- /src/Alignment.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_ALIGNMENT_H 2 | #define IMAGESTACK_ALIGNMENT_H 3 | 4 | namespace ImageStack { 5 | 6 | class Align : public Operation { 7 | public: 8 | void help(); 9 | bool test(); 10 | void parse(vector args); 11 | 12 | typedef enum {Translate = 0, Similarity, Affine, Perspective, Rigid} Mode; 13 | 14 | static Image apply(Image a, Image b, Mode m); 15 | 16 | }; 17 | 18 | class AlignFrames : public Operation { 19 | public: 20 | void help(); 21 | bool test(); 22 | void parse(vector args); 23 | static void apply(Image im, Align::Mode m); 24 | }; 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/Arithmetic.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_MATH_H 2 | #define IMAGESTACK_MATH_H 3 | namespace ImageStack { 4 | 5 | class Add : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | }; 11 | 12 | class Multiply : public Operation { 13 | public: 14 | void help(); 15 | bool test(); 16 | void parse(vector args); 17 | enum Mode {Elementwise = 0, Inner, Outer}; 18 | static Image apply(Image a, Image b, Mode m); 19 | }; 20 | 21 | class Subtract : public Operation { 22 | public: 23 | void help(); 24 | void parse(vector args); 25 | bool test(); 26 | }; 27 | 28 | class Divide : public Operation { 29 | public: 30 | void help(); 31 | bool test(); 32 | void parse(vector args); 33 | }; 34 | 35 | class Maximum : public Operation { 36 | public: 37 | void help(); 38 | bool test(); 39 | void parse(vector args); 40 | static void apply(Image a, Image b); 41 | }; 42 | 43 | class Minimum : public Operation { 44 | public: 45 | void help(); 46 | bool test(); 47 | void parse(vector args); 48 | static void apply(Image a, Image b); 49 | }; 50 | 51 | class Log : public Operation { 52 | public: 53 | void help(); 54 | bool test(); 55 | void parse(vector args); 56 | static void apply(Image a); 57 | }; 58 | 59 | class Exp : public Operation { 60 | public: 61 | void help(); 62 | bool test(); 63 | void parse(vector args); 64 | static void apply(Image a, float base = E); 65 | }; 66 | 67 | class Abs : public Operation { 68 | public: 69 | void help(); 70 | bool test(); 71 | void parse(vector args); 72 | static void apply(Image a); 73 | }; 74 | 75 | class Offset : public Operation { 76 | public: 77 | void help(); 78 | bool test(); 79 | void parse(vector args); 80 | }; 81 | 82 | class Scale : public Operation { 83 | public: 84 | void help(); 85 | bool test(); 86 | void parse(vector args); 87 | }; 88 | 89 | class Gamma : public Operation { 90 | public: 91 | void help(); 92 | bool test(); 93 | void parse(vector args); 94 | static void apply(Image a, float); 95 | }; 96 | 97 | class Mod : public Operation { 98 | public: 99 | void help(); 100 | bool test(); 101 | void parse(vector args); 102 | static void apply(Image a, float); 103 | }; 104 | 105 | class Clamp : public Operation { 106 | public: 107 | void help(); 108 | bool test(); 109 | void parse(vector args); 110 | static void apply(Image a, float lower = 0, float upper = 1); 111 | }; 112 | 113 | class DeNaN : public Operation { 114 | public: 115 | void help(); 116 | bool test(); 117 | void parse(vector args); 118 | static void apply(Image a, float replacement = 0); 119 | }; 120 | 121 | class Threshold : public Operation { 122 | public: 123 | void help(); 124 | bool test(); 125 | void parse(vector args); 126 | static void apply(Image a, float val); 127 | }; 128 | 129 | class Normalize : public Operation { 130 | public: 131 | void help(); 132 | bool test(); 133 | void parse(vector args); 134 | static void apply(Image a); 135 | }; 136 | 137 | class Quantize : public Operation { 138 | public: 139 | void help(); 140 | bool test(); 141 | void parse(vector args); 142 | static void apply(Image a, float increment); 143 | }; 144 | 145 | } 146 | #endif 147 | -------------------------------------------------------------------------------- /src/Calculus.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_CALCULUS_H 2 | #define IMAGESTACK_CALCULUS_H 3 | namespace ImageStack { 4 | 5 | class Gradient : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static void apply(Image im, string dimensions); 11 | static void apply(Image im, char dimension); 12 | }; 13 | 14 | class Integrate : public Operation { 15 | public: 16 | void help(); 17 | bool test(); 18 | void parse(vector args); 19 | static void apply(Image im, string dimensions); 20 | static void apply(Image im, char dimension); 21 | }; 22 | 23 | class GradMag : public Operation { 24 | public: 25 | void help(); 26 | bool test(); 27 | void parse(vector args); 28 | static void apply(Image im); 29 | }; 30 | 31 | class Poisson : public Operation { 32 | public: 33 | void help(); 34 | bool test(); 35 | void parse(vector args); 36 | static Image apply(Image dx, Image dy, float termination = 0.01); 37 | }; 38 | 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /src/Color.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_COLOR_H 2 | #define IMAGESTACK_COLOR_H 3 | namespace ImageStack { 4 | 5 | class ColorMatrix : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image im, const vector &matrix); 11 | static Image apply(Image im, const float *matrix, int outChannels); 12 | }; 13 | 14 | class ColorConvert : public Operation { 15 | public: 16 | void help(); 17 | bool test(); 18 | void parse(vector args); 19 | static Image apply(Image im, string from, string to); 20 | static Image rgb2hsv(Image im); 21 | static Image hsv2rgb(Image im); 22 | static Image rgb2y(Image im); 23 | static Image y2rgb(Image im); 24 | static Image rgb2yuv(Image im); 25 | static Image yuv2rgb(Image im); 26 | static Image lrgb2xyz(Image im); 27 | static Image xyz2lrgb(Image im); 28 | static Image lab2xyz(Image im); 29 | static Image xyz2lab(Image im); 30 | static Image rgb2lrgb(Image im); 31 | static Image lrgb2rgb(Image im); 32 | static Image uyvy2yuv(Image im); 33 | static Image yuyv2yuv(Image im); 34 | static Image argb2xyz(Image im); 35 | static Image xyz2argb(Image im); 36 | 37 | 38 | 39 | }; 40 | 41 | class Demosaic : public Operation { 42 | public: 43 | void help(); 44 | bool test(); 45 | void parse(vector args); 46 | static Image apply(Image win, int xoff, int yoff, bool awb); 47 | }; 48 | 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /src/Complex.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_COMPLEX_H 2 | #define IMAGESTACK_COMPLEX_H 3 | namespace ImageStack { 4 | 5 | class ComplexMultiply : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static void apply(Image a, Image b, bool conj = false); 11 | }; 12 | 13 | class ComplexDivide : public Operation { 14 | public: 15 | void help(); 16 | bool test(); 17 | void parse(vector args); 18 | static void apply(Image a, Image b, bool conj = false); 19 | }; 20 | 21 | class ComplexReal : public Operation { 22 | public: 23 | void help(); 24 | bool test(); 25 | void parse(vector args); 26 | static Image apply(Image im); 27 | }; 28 | 29 | class RealComplex : public Operation { 30 | public: 31 | void help(); 32 | bool test(); 33 | void parse(vector args); 34 | static Image apply(Image im); 35 | }; 36 | 37 | class ComplexImag : public Operation { 38 | public: 39 | void help(); 40 | bool test(); 41 | void parse(vector args); 42 | static Image apply(Image im); 43 | }; 44 | 45 | class ComplexMagnitude : public Operation { 46 | public: 47 | void help(); 48 | bool test(); 49 | void parse(vector args); 50 | static Image apply(Image im); 51 | }; 52 | 53 | class ComplexPhase : public Operation { 54 | public: 55 | void help(); 56 | bool test(); 57 | void parse(vector args); 58 | static Image apply(Image im); 59 | }; 60 | 61 | class ComplexConjugate : public Operation { 62 | public: 63 | void help(); 64 | bool test(); 65 | void parse(vector args); 66 | static void apply(Image im); 67 | }; 68 | 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /src/Control.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "Control.h" 3 | namespace ImageStack { 4 | 5 | void Loop::help() { 6 | printf("\n-loop takes an integer and a sequence of commands, and loops that sequence\n" 7 | "the specified number of times. The commands that form the argument must be\n" 8 | "prefixed with an extra dash. It is possible to nest this operation using more\n" 9 | "dashes. If given no integer argument, loop will loop forever.\n\n" 10 | "Usage: ImageStack -load a.tga -loop 36 --rotate 10 --loop 10 ---downsample\n" 11 | " ---upsample -save b.tga\n\n"); 12 | } 13 | 14 | void Loop::parse(vector args) { 15 | assert(args.size() > 0, "-loop requires arguments\n"); 16 | 17 | if (args[0].size() > 2 && args[0][0] == '-' && args[0][1] == '-') { // infinite loop mode 18 | vector newArgs(args.size()); 19 | 20 | for (size_t i = 0; i < args.size(); i++) { 21 | if (args[i].size() > 1 && args[i][0] == '-' && args[i][1] == '-') { 22 | newArgs[i] = args[i].substr(1, args[i].size() - 1); 23 | } else { 24 | newArgs[i] = args[i]; 25 | } 26 | } 27 | 28 | for (;;) { parseCommands(newArgs); } 29 | 30 | } else { // finite loop mode 31 | 32 | vector newArgs(args.size() - 1); 33 | 34 | for (size_t i = 0; i < newArgs.size(); i++) { 35 | if (args[i+1].size() > 1 && args[i+1][0] == '-' && args[i+1][1] == '-') { 36 | newArgs[i] = args[i+1].substr(1, args[i+1].size() - 1); 37 | } else { 38 | newArgs[i] = args[i+1]; 39 | } 40 | } 41 | 42 | for (int i = 0; i < readInt(args[0]); i++) { 43 | parseCommands(newArgs); 44 | } 45 | } 46 | } 47 | 48 | 49 | 50 | void Pause::help() { 51 | printf("\n-pause waits for the user to press hit enter.\n\n" 52 | "Usage: ImageStack -load a.tga -display -pause -load b.tga -display\n\n"); 53 | } 54 | 55 | void Pause::parse(vector args) { 56 | assert(args.size() == 0, "-pause takes no arguments\n"); 57 | fprintf(stdout, "Press enter to continue\n"); 58 | char c = ' '; 59 | while (c != '\n' && c != EOF) { c = getchar(); } 60 | } 61 | 62 | void Time::help() { 63 | printf("\n-time takes a sequence of commands, performs that sequence, and reports how\n" 64 | "long it took. The commands that form the argument must be prefixed with an extra\n" 65 | "dash. If given to arguments, it simply reports the time since the program was\n" 66 | "launched. It is a useful operation for profiling.\n\n" 67 | "Usage: ImageStack -load a.jpg -time --resample 10 10 --scale 2\n\n"); 68 | } 69 | 70 | void Time::parse(vector args) { 71 | if (args.size() == 0) { 72 | printf("%3.3f s\n", currentTime()); 73 | return; 74 | } 75 | 76 | vector newArgs(args.size()); 77 | 78 | for (size_t i = 0; i < args.size(); i++) { 79 | if (args[i].size() > 1 && args[i][0] == '-' && args[i][1] == '-') { 80 | newArgs[i] = args[i].substr(1, args[i].size() - 1); 81 | } else { 82 | newArgs[i] = args[i]; 83 | } 84 | } 85 | 86 | float t1 = currentTime(); 87 | parseCommands(newArgs); 88 | float t2 = currentTime(); 89 | printf("%3.3f s\n", t2 - t1); 90 | } 91 | 92 | } 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/Control.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_CONTROL_H 2 | #define IMAGESTACK_CONTROL_H 3 | namespace ImageStack { 4 | 5 | class Loop : public Operation { 6 | public: 7 | void help(); 8 | bool test() {return true;} 9 | void parse(vector args); 10 | }; 11 | 12 | class Pause : public Operation { 13 | public: 14 | void help(); 15 | bool test() {return true;} 16 | void parse(vector args); 17 | }; 18 | 19 | class Time : public Operation { 20 | public: 21 | void help(); 22 | bool test() {return true;} 23 | void parse(vector args); 24 | }; 25 | 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/Convolve.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_CONVOLVE_H 2 | #define IMAGESTACK_CONVOLVE_H 3 | 4 | #include "Arithmetic.h" 5 | 6 | namespace ImageStack { 7 | 8 | class Convolve : public Operation { 9 | public: 10 | void help(); 11 | bool test(); 12 | void parse(vector args); 13 | 14 | enum BoundaryCondition {Zero = 0, Homogeneous, Clamp, Wrap}; 15 | 16 | static Image apply(Image im, Image filter, BoundaryCondition b = Zero, 17 | Multiply::Mode m = Multiply::Outer); 18 | private: 19 | static void convolveSingle(Image im, Image filter, Image out, BoundaryCondition b); 20 | }; 21 | 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /src/DFT.h: -------------------------------------------------------------------------------- 1 | #ifndef NO_FFTW 2 | #ifndef DFT_H 3 | #define DFT_H 4 | 5 | #include "Convolve.h" 6 | 7 | namespace ImageStack { 8 | 9 | class DCT : public Operation { 10 | public: 11 | void help(); 12 | bool test(); 13 | void parse(vector args); 14 | static void apply(Image win, bool x = true, bool y = true, bool t = true); 15 | }; 16 | 17 | class FFT : public Operation { 18 | public: 19 | void help(); 20 | bool test(); 21 | void parse(vector args); 22 | static void apply(Image im, bool x = true, bool y = true, bool t = true, bool inverse = false); 23 | }; 24 | 25 | class IFFT : public Operation { 26 | public: 27 | void help(); 28 | bool test(); 29 | void parse(vector args); 30 | static void apply(Image im, bool x = true, bool y = true, bool t = true); 31 | }; 32 | 33 | class FFTConvolve : public Operation { 34 | public: 35 | void help(); 36 | bool test(); 37 | void parse(vector args); 38 | static Image apply(Image im, Image filter, Convolve::BoundaryCondition b, Multiply::Mode m); 39 | private: 40 | static void convolveSingle(Image im, Image filter, Image out, Convolve::BoundaryCondition b); 41 | }; 42 | 43 | class FFTPoisson : public Operation { 44 | public: 45 | void help(); 46 | bool test(); 47 | void parse(vector args); 48 | 49 | // Return an image which has gradients dx and dy, and is somewhat similar to the target 50 | static Image apply(Image dx, Image dy, Image target, float targetStrength = 0); 51 | }; 52 | 53 | } 54 | #endif 55 | #endif 56 | -------------------------------------------------------------------------------- /src/Deconvolution.h: -------------------------------------------------------------------------------- 1 | #ifndef NO_FFTW 2 | #ifndef DECONVOLUTION_H 3 | #define DECONVOLUTION_H 4 | namespace ImageStack { 5 | 6 | class Deconvolve : public Operation { 7 | public: 8 | void help(); 9 | bool test(); 10 | void parse(vector args); 11 | static Image applyCho2009(Image im, Image kernel); 12 | static Image applyShan2008(Image im, Image kernel); 13 | static Image applyLevin2007(Image im, Image kernel, float weight); 14 | private: 15 | static Image applyPadding(Image im); 16 | }; 17 | 18 | } 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /src/Display.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "Display.h" 3 | #include "DisplayWindow.h" 4 | namespace ImageStack { 5 | 6 | #ifndef NO_SDL 7 | Display::~Display() { 8 | DisplayWindow::instance().wait(); 9 | } 10 | 11 | void Display::help() { 12 | printf("\n-display opens a window and displays the current image. Subsequent displays\n" 13 | "will use the same window. The presence of an optional second argument indicates\n" 14 | "that the window should be fullscreen.\n\n" 15 | "Usage: ImageStack -load a.tga -loop 100 --display --gaussianblur 2\n\n"); 16 | 17 | } 18 | 19 | bool Display::test() { 20 | // Not testable without popping up a window, which seems kinda annoying. 21 | return true; 22 | } 23 | 24 | void Display::parse(vector args) { 25 | assert(args.size() < 2, "-display takes zero or one arguments\n"); 26 | apply(stack(0), args.size() == 1); 27 | } 28 | 29 | void Display::apply(Image im, bool fullscreen) { 30 | DisplayWindow::instance().setMode(im.width, im.height, fullscreen); 31 | DisplayWindow::instance().setImage(im); 32 | 33 | #ifdef __APPLE_CC__ 34 | // OS X can't deal with launching a UI outside the main thread, so 35 | // we show it, wait until the user closes it, then continue 36 | DisplayWindow::instance().show(); 37 | #else 38 | // In the linux/windows case we show it in the background and 39 | // continue processing 40 | DisplayWindow::instance().showAsync(); 41 | #endif 42 | } 43 | 44 | #else 45 | Display::~Display() { 46 | } 47 | 48 | void Display::help() { 49 | printf("This version of ImageStack was compiled without SDL, so cannot display.\n"); 50 | } 51 | 52 | bool Display::test() { 53 | printf("This version of ImageStack was compiled without SDL, so cannot display.\n"); 54 | return true; 55 | } 56 | 57 | void Display::parse(vector args) { 58 | panic("This version of ImageStack was compiled without SDL, so cannot display.\n"); 59 | } 60 | 61 | void Display::apply(Image im, bool fullscreen) { 62 | panic("This version of ImageStack was compiled without SDL, so cannot display.\n"); 63 | } 64 | 65 | #endif 66 | } 67 | -------------------------------------------------------------------------------- /src/Display.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_DISPLAY_H 2 | #define IMAGESTACK_DISPLAY_H 3 | namespace ImageStack { 4 | 5 | class Display : public Operation { 6 | public: 7 | ~Display(); 8 | void help(); 9 | bool test(); 10 | void parse(vector args); 11 | static void apply(Image im, bool fullscreen = false); 12 | }; 13 | 14 | 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /src/DisplayWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_DISPLAYWINDOW_H 2 | #define IMAGESTACK_DISPLAYWINDOW_H 3 | #ifndef NO_SDL 4 | 5 | #include 6 | #include 7 | #include 8 | #include "main.h" 9 | #include "Image.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace ImageStack { 16 | 17 | // a singleton SDL window 18 | class DisplayWindow { 19 | public: 20 | static DisplayWindow &instance(); 21 | void setMode(int width, int height, bool fullscreen = false, bool cursorVisible = true, 22 | float bgRed = 0, float bgGreen = 0, float bgBlue = 0); 23 | 24 | int width() {return width_;} 25 | int height() {return height_;} 26 | bool fullscreen() {return fullscreen_;} 27 | 28 | void setImage(Image im); 29 | 30 | void setOffset(int tOffset, int xOffset, int yOffset); 31 | int xOffset() {return xOffset_;} 32 | int yOffset() {return yOffset_;} 33 | int tOffset() {return tOffset_;} 34 | 35 | void show(); 36 | void showAsync(); 37 | void wait(); 38 | 39 | private: 40 | DisplayWindow(); 41 | ~DisplayWindow(); 42 | 43 | static DisplayWindow *instance_; 44 | 45 | bool update(); 46 | void redraw(); 47 | void renderSurface(); 48 | void updateCaption(); 49 | void handleModeChange(); 50 | bool terminate, modeChange, needRedraw; 51 | 52 | int width_, height_; 53 | bool fullscreen_, cursorVisible_; 54 | unsigned char bgRed_, bgGreen_, bgBlue_; 55 | int tOffset_, xOffset_, yOffset_; 56 | SDL_Surface *surface; 57 | Uint8 *displayImage; // a 3D buffer of the 8bit image 58 | SDL_Thread *thread; 59 | SDL_mutex *mutex; 60 | int mouseX_, mouseY_; 61 | int zoom_; 62 | Image image_; 63 | int stop_; 64 | }; 65 | 66 | } 67 | #endif 68 | #endif 69 | -------------------------------------------------------------------------------- /src/Exception.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "Exception.h" 3 | 4 | namespace ImageStack { 5 | 6 | Exception::Exception(const char *fmt, ...) { 7 | va_list arglist; 8 | va_start(arglist, fmt); 9 | vsnprintf(message, EXCEPTION_LENGTH, fmt, arglist); 10 | va_end(arglist); 11 | } 12 | 13 | 14 | Exception::Exception(const char *fmt, va_list arglist) { 15 | vsnprintf(message, EXCEPTION_LENGTH, fmt, arglist); 16 | } 17 | 18 | void panic(const char *fmt, ...) { 19 | va_list arglist; 20 | va_start(arglist, fmt); 21 | Exception e(fmt, arglist); 22 | va_end(arglist); 23 | throw e; 24 | } 25 | 26 | void assert(bool cond, const char *fmt, ...) { 27 | if (!cond) { 28 | va_list arglist; 29 | va_start(arglist, fmt); 30 | Exception e(fmt, arglist); 31 | va_end(arglist); 32 | throw e; 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/Exception.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_EXCEPTION_H 2 | #define IMAGESTACK_EXCEPTION_H 3 | 4 | #include 5 | 6 | namespace ImageStack { 7 | 8 | #define EXCEPTION_LENGTH 1024 9 | 10 | class Exception { 11 | public: 12 | Exception(const char *fmt, va_list arglist); 13 | Exception(const char *fmt, ...); 14 | 15 | char message[EXCEPTION_LENGTH]; 16 | }; 17 | 18 | void panic(const char *fmt, ...); 19 | #undef assert 20 | void assert(bool cond, const char *fmt, ...); 21 | 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/Expr_scalar_fallback.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_EXPR_SCALAR_FALLBACK_H 2 | #define IMAGESTACK_EXPR_SCALAR_FALLBACK_H 3 | 4 | namespace ImageStack { 5 | 6 | // This file gets included if no sse or avx is available. It provides 7 | // for a vector type that's just a float 8 | 9 | namespace Vec { 10 | typedef float type; 11 | const int width = 1; 12 | 13 | inline type broadcast(float v) { 14 | return v; 15 | } 16 | 17 | inline type zero() { 18 | return 0; 19 | } 20 | 21 | // Arithmetic binary operators 22 | struct Add : public ImageStack::Scalar::Add { 23 | static type vec(type a, type b) {return scalar_f(a, b);} 24 | }; 25 | struct Sub : public ImageStack::Scalar::Sub { 26 | static type vec(type a, type b) {return scalar_f(a, b);} 27 | }; 28 | struct Mul : public ImageStack::Scalar::Mul { 29 | static type vec(type a, type b) {return scalar_f(a, b);} 30 | }; 31 | struct Div : public ImageStack::Scalar::Div { 32 | static type vec(type a, type b) {return scalar_f(a, b);} 33 | }; 34 | struct Min : public ImageStack::Scalar::Min { 35 | static type vec(type a, type b) {return scalar_f(a, b);} 36 | }; 37 | struct Max : public ImageStack::Scalar::Max { 38 | static type vec(type a, type b) {return scalar_f(a, b);} 39 | }; 40 | 41 | // Comparisons 42 | struct GT : public ImageStack::Scalar::GT { 43 | static bool vec(type a, type b) {return scalar_f(a, b);} 44 | }; 45 | struct LT : public ImageStack::Scalar::LT { 46 | static bool vec(type a, type b) {return scalar_f(a, b);} 47 | }; 48 | struct GE : public ImageStack::Scalar::GE { 49 | static bool vec(type a, type b) {return scalar_f(a, b);} 50 | }; 51 | struct LE : public ImageStack::Scalar::LE { 52 | static bool vec(type a, type b) {return scalar_f(a, b);} 53 | }; 54 | struct EQ : public ImageStack::Scalar::EQ { 55 | static bool vec(type a, type b) {return scalar_f(a, b);} 56 | }; 57 | struct NEQ : public ImageStack::Scalar::NEQ { 58 | static bool vec(type a, type b) {return scalar_f(a, b);} 59 | }; 60 | 61 | // Logical ops 62 | inline type blend(bool mask, type a, type b) { 63 | return (mask ? b : a); 64 | } 65 | 66 | inline type interleave(type a, type b) { 67 | return a; 68 | } 69 | 70 | inline type subsample(type a, type b) { 71 | return a; 72 | } 73 | 74 | inline type reverse(type a) { 75 | return a; 76 | } 77 | 78 | // Unary ops 79 | struct Floor : public ImageStack::Scalar::Floor { 80 | static type vec(type a) {return scalar_f(a);} 81 | }; 82 | struct Ceil : public ImageStack::Scalar::Ceil { 83 | static type vec(type a) {return scalar_f(a);} 84 | }; 85 | struct Sqrt : public ImageStack::Scalar::Sqrt { 86 | static type vec(type a) {return scalar_f(a);} 87 | }; 88 | 89 | // Loads and stores 90 | inline type load(const float *f) { 91 | return *f; 92 | } 93 | 94 | inline void store(type a, float *f) { 95 | *f = a; 96 | } 97 | } 98 | 99 | 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/FileCSV.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "File.h" 3 | namespace ImageStack { 4 | 5 | namespace FileCSV { 6 | void help() { 7 | pprintf(".csv files. These contain comma-separated floating point values in" 8 | " text. Each scanline of the image corresponds to a line in the file. x" 9 | " and c are thus conflated, as are y and t. When loading csv files," 10 | " ImageStack assumes 1 channel and 1 frame.\n"); 11 | } 12 | 13 | 14 | Image load(string filename) { 15 | // calculate the number of rows and columns in the file 16 | FILE *f = fopen(filename.c_str(), "r"); 17 | 18 | // how many commas in the first line? 19 | int width = 1; 20 | int c, last; 21 | do { 22 | c = fgetc(f); 23 | if (c == ',') { width++; } 24 | } while (c != '\n' && c != EOF); 25 | 26 | // how many lines in the file? 27 | int height = 1; 28 | do { 29 | last = c; 30 | c = fgetc(f); 31 | if (c == '\n' && last != '\n') { height++; } 32 | } while (c != EOF); 33 | 34 | // go back to the start and start reading data 35 | fseek(f, 0, SEEK_SET); 36 | 37 | Image out(width, height, 1, 1); 38 | 39 | for (int y = 0; y < height; y++) { 40 | for (int x = 0; x < width-1; x++) { 41 | assert(fscanf(f, "%20f,", &out(x, y)) == 1, "Failed to parse file\n"); 42 | } 43 | assert(fscanf(f, "%20f", &out(width-1, y)) == 1, "Failed to parse file\n"); 44 | } 45 | 46 | fclose(f); 47 | 48 | return out; 49 | } 50 | 51 | void save(Image im, string filename) { 52 | FILE *f = fopen(filename.c_str(), "w"); 53 | 54 | for (int c = 0; c < im.channels; c++) { 55 | for (int t = 0; t < im.frames; t++) { 56 | for (int y = 0; y < im.height; y++) { 57 | for (int x = 0; x < im.width-1; x++) { 58 | fprintf(f, "%10.10f, ", im(x, y, t, c)); 59 | } 60 | fprintf(f, "%10.10f\n", im(im.width-1, y, t, c)); 61 | } 62 | } 63 | } 64 | 65 | fclose(f); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/FileFLO.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "File.h" 3 | 4 | // first four bytes, should be the same in little endian 5 | #define TAG_FLOAT 202021.25 // check for this when READING the file 6 | #define TAG_STRING "PIEH" // use this when WRITING the file 7 | 8 | namespace ImageStack { 9 | namespace FileFLO { 10 | void help() { 11 | pprintf(".flo files. This format is used for optical flow evaluation. It stores" 12 | " 2-band float image for horizontal and vertical flow components.\n"); 13 | } 14 | 15 | void save(Image im, string filename) { 16 | 17 | assert(im.channels == 2, "image must have 2 channels", filename.c_str()); 18 | assert(im.frames == 1, "Can only save single-frame .flo files\n"); 19 | 20 | FILE *stream = fopen(filename.c_str(), "wb"); 21 | assert(stream, "Could not open %s", filename.c_str()); 22 | 23 | // write the header 24 | fprintf(stream, TAG_STRING); 25 | if ((int)fwrite(&im.width, sizeof(int), 1, stream) != 1 || 26 | (int)fwrite(&im.height, sizeof(int), 1, stream) != 1) { 27 | panic("problem writing header: %s", filename.c_str()); 28 | } 29 | 30 | vector scanline(im.width*2); 31 | for (int y = 0; y < im.height; y++) { 32 | for (int x = 0; x < im.width; x++) { 33 | scanline[x*2] = im(x, y, 0); 34 | scanline[x*2+1] = im(x, y, 1); 35 | } 36 | fwrite(&scanline[0], sizeof(float), im.width*2, stream); 37 | } 38 | 39 | fclose(stream); 40 | } 41 | 42 | Image load(string filename) { 43 | FILE *stream = fopen(filename.c_str(), "rb"); 44 | assert(stream, "Could not open file %s\n", filename.c_str()); 45 | 46 | int width, height; 47 | float tag; 48 | 49 | if ((int)fread(&tag, sizeof(float), 1, stream) != 1 || 50 | (int)fread(&width, sizeof(int), 1, stream) != 1 || 51 | (int)fread(&height, sizeof(int), 1, stream) != 1) { 52 | panic("ReadFlowFile: problem reading file %s", filename.c_str()); 53 | } 54 | 55 | assert(tag == TAG_FLOAT, "Wrong tag (possibly due to big-endian machine?)"); 56 | 57 | // another sanity check to see that integers were read correctly (999999 should do the trick...) 58 | assert(width > 0 && width < 999999, "illegal width %d", width); 59 | assert(height > 0 && height < 999999, "illegal height %d", height); 60 | 61 | Image out(width, height, 1, 2); 62 | 63 | vector scanline(width*2); 64 | 65 | for (int y = 0; y < height; y++) { 66 | assert(fread(&scanline[0], sizeof(float), width*2, stream) == (size_t)width*2, 67 | "Unexpected end of file\n"); 68 | for (int x = 0; x < width; x++) { 69 | out(x, y, 0) = scanline[2*x]; 70 | out(x, y, 1) = scanline[2*x+1]; 71 | } 72 | } 73 | 74 | fclose(stream); 75 | 76 | return out; 77 | } 78 | } 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/FileJPG.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "File.h" 3 | 4 | #ifdef NO_JPEG 5 | 6 | namespace ImageStack { 7 | namespace FileJPG { 8 | #include "FileNotImplemented.h" 9 | } 10 | } 11 | 12 | #else 13 | 14 | extern "C" { 15 | #include 16 | } 17 | 18 | namespace ImageStack { 19 | namespace FileJPG { 20 | 21 | void help() { 22 | printf(".jpg (or .jpeg) files. When saving, an optional second arguments specifies\n" 23 | "the quality. This defaults to 90. A jpeg image always has a single frame,\n" 24 | "and may have either one or three channels.\n"); 25 | } 26 | 27 | void save(Image im, string filename, int quality) { 28 | assert(im.channels == 1 || im.channels == 3, "Can only save jpg images with 1 or 3 channels\n"); 29 | assert(im.frames == 1, "Can't save multiframe jpg images\n"); 30 | assert(quality > 0 && quality <= 100, "jpeg quality must lie between 1 and 100\n"); 31 | 32 | struct jpeg_compress_struct cinfo; 33 | struct jpeg_error_mgr jerr; 34 | 35 | FILE *f = fopen(filename.c_str(), "wb"); 36 | assert(f, "Could not open file %s\n", filename.c_str()); 37 | 38 | cinfo.err = jpeg_std_error(&jerr); 39 | jpeg_create_compress(&cinfo); 40 | jpeg_stdio_dest(&cinfo, f); 41 | 42 | cinfo.image_width = im.width; 43 | cinfo.image_height = im.height; 44 | cinfo.input_components = im.channels; 45 | if (im.channels == 3) { 46 | cinfo.in_color_space = JCS_RGB; 47 | } else { // channels must be 1 48 | cinfo.in_color_space = JCS_GRAYSCALE; 49 | } 50 | 51 | jpeg_set_defaults(&cinfo); 52 | jpeg_set_quality(&cinfo, quality, TRUE); 53 | 54 | jpeg_start_compress(&cinfo, TRUE); 55 | 56 | JSAMPLE *row = new JSAMPLE[im.width * im.channels]; 57 | 58 | while (cinfo.next_scanline < cinfo.image_height) { 59 | // convert the row 60 | JSAMPLE *dstPtr = row; 61 | for (int x = 0; x < im.width; x++) { 62 | for (int c = 0; c < im.channels; c++) { 63 | *dstPtr++ = (JSAMPLE)(HDRtoLDR(im(x, cinfo.next_scanline, c))); 64 | } 65 | } 66 | jpeg_write_scanlines(&cinfo, &row, 1); 67 | } 68 | 69 | jpeg_finish_compress(&cinfo); 70 | fclose(f); 71 | 72 | // clean up 73 | delete[] row; 74 | jpeg_destroy_compress(&cinfo); 75 | 76 | } 77 | 78 | 79 | 80 | Image load(string filename) { 81 | 82 | struct jpeg_decompress_struct cinfo; 83 | struct jpeg_error_mgr jerr; 84 | 85 | FILE *f = fopen(filename.c_str(), "rb"); 86 | assert(f, "Could not open file %s\n", filename.c_str()); 87 | 88 | cinfo.err = jpeg_std_error(&jerr); 89 | jpeg_create_decompress(&cinfo); 90 | jpeg_stdio_src(&cinfo, f); 91 | 92 | jpeg_read_header(&cinfo, TRUE); 93 | jpeg_start_decompress(&cinfo); 94 | 95 | Image im(cinfo.output_width, cinfo.output_height, 1, cinfo.output_components); 96 | JSAMPARRAY buffer = (*cinfo.mem->alloc_sarray)((j_common_ptr)&cinfo, JPOOL_IMAGE, im.width * im.channels, 1); 97 | 98 | while (cinfo.output_scanline < cinfo.output_height) { 99 | jpeg_read_scanlines(&cinfo, buffer, 1); 100 | JSAMPLE *srcPtr = buffer[0]; 101 | for (int x = 0; x < im.width; x++) { 102 | for (int c = 0; c < im.channels; c++) { 103 | im(x, cinfo.output_scanline-1, c) = LDRtoHDR(*srcPtr++); 104 | } 105 | } 106 | } 107 | 108 | jpeg_finish_decompress(&cinfo); 109 | jpeg_destroy_decompress(&cinfo); 110 | 111 | fclose(f); 112 | 113 | return im; 114 | } 115 | } 116 | } 117 | #endif 118 | -------------------------------------------------------------------------------- /src/FileNotImplemented.h: -------------------------------------------------------------------------------- 1 | void help() { 2 | } 3 | 4 | Image load(string filename) { 5 | panic("This file type not implemented in this build\n"); 6 | Image im; 7 | return im; 8 | } 9 | 10 | void save(Image im, string filename) { 11 | panic("This file type not implemented in this build\n"); 12 | } 13 | 14 | void save(Image im, string filename, int opt) { 15 | panic("This file type not implemented in this build\n"); 16 | } 17 | 18 | void save(Image im, string filename, string opt) { 19 | panic("This file type not implemented in this build\n"); 20 | } 21 | -------------------------------------------------------------------------------- /src/FilePBA.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "File.h" 3 | namespace ImageStack { 4 | 5 | namespace FilePBA { 6 | 7 | void help() { 8 | pprintf(".pba files. This format is a human-readable space-separated 2D array of" 9 | " numbers. It is used by petabricks. Width becomes columns" 10 | " of the file, and height, frames, and channels become rows.\n"); 11 | } 12 | 13 | void save(Image im, string filename) { 14 | FILE *f = fopen(filename.c_str(), "w"); 15 | assert(f, "Could not write output file %s\n", filename.c_str()); 16 | // write the dimensions 17 | fprintf(f, "SIZE"); 18 | if (im.channels != 1) { fprintf(f, " %d", im.channels); } 19 | if (im.width != 1) { fprintf(f, " %d", im.width); } 20 | if (im.height != 1) { fprintf(f, " %d", im.height); } 21 | if (im.frames != 1) { fprintf(f, " %d", im.frames); } 22 | fprintf(f, "\n"); 23 | 24 | for (int c = 0; c < im.channels; c++) { 25 | for (int t = 0; t < im.frames; t++) { 26 | for (int y = 0; y < im.height; y++) { 27 | for (int x = 0; x < im.width; x++) { 28 | fprintf(f, "%f ", im(x, y, t, c)); 29 | } 30 | fprintf(f, "\n"); 31 | } 32 | fprintf(f, "\n"); 33 | } 34 | fprintf(f, "\n"); 35 | } 36 | 37 | fclose(f); 38 | } 39 | 40 | Image load(string filename) { 41 | FILE *f = fopen(filename.c_str(), "r"); 42 | assert(f, "Could not read input file %s\n", filename.c_str()); 43 | 44 | // read the dimensions 45 | char header[256]; 46 | assert(fgets(header, 256, f) == header, 47 | "Could not read header of %s\n", filename.c_str()); 48 | 49 | int ch, wi, he, fr; 50 | int ret = sscanf(header, "SIZE %20d %20d %20d %20d", &ch, &wi, &he, &fr); 51 | if (ret == 0) { // 0D 52 | ch = wi = he = fr = 1; 53 | } else if (ret == 1) { // 1D 54 | wi = ch; 55 | ch = he = fr = 1; 56 | } else if (ret == 2) { // 2D 57 | he = wi; 58 | wi = ch; 59 | ch = fr = 1; 60 | } else if (ret == 3) { 61 | fr = 1; 62 | } else if (ret == 4) { 63 | 64 | } else { 65 | panic("Could not parse header of %s\n", filename.c_str()); 66 | } 67 | 68 | 69 | 70 | Image im(wi, he, fr, ch); 71 | 72 | // read the data 73 | for (int c = 0; c < im.channels; c++) { 74 | for (int t = 0; t < im.frames; t++) { 75 | for (int y = 0; y < im.height; y++) { 76 | for (int x = 0; x < im.width; x++) { 77 | assert(fscanf(f, "%20f", &im(x, y, t, c)) == 1, 78 | "Unexpected end of file reading %s\n", filename.c_str()); 79 | } 80 | } 81 | } 82 | } 83 | 84 | fclose(f); 85 | 86 | return im; 87 | } 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Filter.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_FILTER_H 2 | #define IMAGESTACK_FILTER_H 3 | namespace ImageStack { 4 | 5 | class GaussianBlur : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image im, float filterWidth, float filterHeight, float filterFrames); 11 | }; 12 | 13 | class FastBlur : public Operation { 14 | public: 15 | void help(); 16 | bool test(); 17 | void parse(vector args); 18 | static void apply(Image im, float filterWidth, float filterHeight, float filterFrames); 19 | private: 20 | // helper function for IIR filtering 21 | static void calculateCoefficients(float sigma, float *c0, float *c1, float *c2, float *c3); 22 | 23 | // filter a 16-wide chunk of data in place with the given iir coefficients 24 | static void blurChunk(float *data, int size, float c0, float c1, float c2, float c3); 25 | 26 | // compute the inverse of the attenuation due to the zero boundary condition 27 | static void computeAttenuation(float *data, int size, int width, float c0, float c1, float c2, float c3, int iterations); 28 | }; 29 | 30 | class RectFilter : public Operation { 31 | public: 32 | void help(); 33 | bool test(); 34 | void parse(vector args); 35 | static void apply(Image im, int filterWidth, int filterHeight, int filterFrames, int iterations = 1); 36 | 37 | private: 38 | static void blurX(Image im, int filterSize, int iterations = 1); 39 | static void blurY(Image im, int filterSize, int iterations = 1); 40 | static void blurT(Image im, int filterSize, int iterations = 1); 41 | static void blurXCompletely(Image im); 42 | }; 43 | 44 | 45 | class LanczosBlur : public Operation { 46 | public: 47 | void help(); 48 | bool test(); 49 | void parse(vector args); 50 | static Image apply(Image im, float filterWidth, float filterHeight, float filterFrames); 51 | }; 52 | 53 | class MedianFilter : public Operation { 54 | public: 55 | void help(); 56 | bool test(); 57 | void parse(vector args); 58 | static Image apply(Image im, int radius); 59 | }; 60 | 61 | class MinFilter : public Operation { 62 | public: 63 | void help(); 64 | bool test(); 65 | void parse(vector args); 66 | static void apply(Image im, int radius); 67 | }; 68 | 69 | class MaxFilter : public Operation { 70 | public: 71 | void help(); 72 | bool test(); 73 | void parse(vector args); 74 | static void apply(Image im, int radius); 75 | }; 76 | 77 | class PercentileFilter : public Operation { 78 | public: 79 | void help(); 80 | bool test(); 81 | void parse(vector args); 82 | static Image apply(Image im, int radius, float percentile); 83 | }; 84 | 85 | class CircularFilter : public Operation { 86 | public: 87 | void help(); 88 | bool test(); 89 | void parse(vector args); 90 | static Image apply(Image im, int radius); 91 | }; 92 | 93 | 94 | class Envelope : public Operation { 95 | public: 96 | void help(); 97 | bool test(); 98 | void parse(vector args); 99 | enum Mode {Lower = 0, Upper}; 100 | static void apply(Image im, Mode m, int radius); 101 | }; 102 | 103 | class HotPixelSuppression : public Operation { 104 | public: 105 | void help(); 106 | bool test(); 107 | void parse(vector args); 108 | static Image apply(Image im); 109 | }; 110 | 111 | } 112 | #endif 113 | -------------------------------------------------------------------------------- /src/GaussTransform.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_GAUSS_TRANSFORM_H 2 | #define IMAGESTACK_GAUSS_TRANSFORM_H 3 | namespace ImageStack { 4 | 5 | 6 | class GaussTransform : public Operation { 7 | public: 8 | enum Method {AUTO = 0, EXACT, GRID, PERMUTOHEDRAL, GKDTREE}; 9 | 10 | void help(); 11 | bool test(); 12 | void parse(vector args); 13 | static Image apply(Image slicePositions, Image splatPositions, Image values, 14 | vector sigmas, Method m = AUTO); 15 | }; 16 | 17 | 18 | class JointBilateral : public Operation { 19 | public: 20 | void help(); 21 | bool test(); 22 | void parse(vector args); 23 | static void apply(Image image, Image reference, 24 | float filterWidth, float filterHeight, float filterFrames, float colorSigma, 25 | GaussTransform::Method m = GaussTransform::AUTO); 26 | }; 27 | 28 | class Bilateral : public Operation { 29 | public: 30 | void help(); 31 | bool test(); 32 | void parse(vector args); 33 | static void apply(Image image, float filterWidth, float filterHeight, 34 | float filterFrames, float colorSigma, 35 | GaussTransform::Method m = GaussTransform::AUTO); 36 | }; 37 | 38 | 39 | class BilateralSharpen : public Operation { 40 | public: 41 | void help(); 42 | bool test(); 43 | void parse(vector args); 44 | static Image apply(Image im, float spatialSigma, float colorSigma, float sharpness); 45 | }; 46 | 47 | class ChromaBlur : public Operation { 48 | public: 49 | void help(); 50 | bool test(); 51 | void parse(vector args); 52 | static Image apply(Image im, float spatialSigma, float colorSigma); 53 | }; 54 | 55 | 56 | 57 | class NLMeans : public Operation { 58 | public: 59 | void help(); 60 | bool test(); 61 | void parse(vector args); 62 | static void apply(Image image, float patchSize, int dimensions, 63 | float spatialSigma, float patchSigma, 64 | GaussTransform::Method m = GaussTransform::AUTO); 65 | }; 66 | 67 | class FastNLMeans : public Operation { 68 | public: 69 | void help(); 70 | bool test(); 71 | void parse(vector args); 72 | static Image apply(Image image, float patchSize, float spatialSigma, float patchSigma); 73 | }; 74 | 75 | class NLMeans3D : public Operation { 76 | public: 77 | void help(); 78 | bool test(); 79 | void parse(vector args); 80 | static void apply(Image image, float patchSize, int dimensions, 81 | float spatialSigma, float patchSigma, 82 | GaussTransform::Method m = GaussTransform::AUTO); 83 | }; 84 | 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /src/HDR.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_HDR_H 2 | #define IMAGESTACK_HDR_H 3 | namespace ImageStack { 4 | 5 | class AssembleHDR : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image frames); 11 | static Image apply(Image frames, const vector &exposures, string gamma="1.0"); 12 | private: 13 | enum CutoffType { Regular, LongestExposure, ShortestExposure}; 14 | static float weightFunc(float maxVal, CutoffType c = Regular); 15 | 16 | }; 17 | 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /src/ImageStack.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_IMAGESTACK_H 2 | #define IMAGESTACK_IMAGESTACK_H 3 | 4 | // We never want SDL when used as a library 5 | #define NO_SDL 6 | 7 | // includes that don't survive well in the namespace 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #ifdef WIN32 19 | #include 20 | #else 21 | #include 22 | #include 23 | #include 24 | #include 25 | #endif 26 | 27 | #include 28 | 29 | #include "main.h" 30 | #include "Operation.h" 31 | #include "Calculus.h" 32 | #include "Color.h" 33 | #include "Control.h" 34 | #include "Convolve.h" 35 | #include "Complex.h" 36 | #include "Deconvolution.h" 37 | #include "DFT.h" 38 | #include "Display.h" 39 | #include "DisplayWindow.h" 40 | #include "Exception.h" 41 | #include "File.h" 42 | #include "Filter.h" 43 | #include "Geometry.h" 44 | #include "GaussTransform.h" 45 | #include "HDR.h" 46 | #include "Image.h" 47 | #include "KernelEstimation.h" 48 | #include "LAHBPCG.h" 49 | #include "LightField.h" 50 | #include "Arithmetic.h" 51 | #include "Network.h" 52 | #include "NetworkOps.h" 53 | #include "Paint.h" 54 | #include "Parser.h" 55 | #include "Prediction.h" 56 | #include "Stack.h" 57 | #include "Statistics.h" 58 | #include "Wavelet.h" 59 | #include "WLS.h" 60 | #include "macros.h" 61 | #include "tables.h" 62 | 63 | #undef NO_SDL 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /src/KernelEstimation.h: -------------------------------------------------------------------------------- 1 | #ifndef NO_FFTW 2 | #ifndef KERNELESTIMATION_H 3 | #define KERNELESTIMATION_H 4 | namespace ImageStack { 5 | 6 | class KernelEstimation : public Operation { 7 | public: 8 | void help(); 9 | bool test(); 10 | void parse(vector args); 11 | static Image apply(Image im, int kernelSize = 25); 12 | 13 | // Helpers 14 | static void normalizeSum(Image im); 15 | static Image enlargeKernel(Image im, int w, int h); 16 | static Image contractKernel(Image im, int size); 17 | static Image bilinearResample(Image im, int w, int h); 18 | 19 | private: 20 | static void shockFilterIteration(Image im, float dt = 1.0f); 21 | static void bilateralFilterIteration(Image im, float sigmaR); 22 | }; 23 | 24 | } 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /src/LAHBPCG.h: -------------------------------------------------------------------------------- 1 | #ifndef LAHBPCG_H 2 | #define LAHBPCG_H 3 | namespace ImageStack { 4 | 5 | class LAHBPCG : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | 11 | static Image apply(Image d, Image gx, Image gy, 12 | Image w, Image sx, Image sy, int max_iter, float tol); 13 | private: 14 | }; 15 | 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /src/LightField.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_LIGHTFIELD_H 2 | #define IMAGESTACK_LIGHTFIELD_H 3 | namespace ImageStack { 4 | 5 | // a LightField is an image which assumes u and v are rolled up into x 6 | // and y, like an image of the lenslets in a plenoptic camera 7 | class LightField { 8 | public: 9 | LightField(Image im, int uSize_, int vSize_) : image(im), uSize(uSize_), vSize(vSize_) { 10 | assert(im.width % uSize == 0, "width is not a multiple of lenslet width\n"); 11 | assert(im.height % vSize == 0, "height is not a multiple of lenslet height\n"); 12 | xSize = im.width / uSize; 13 | ySize = im.height / vSize; 14 | } 15 | 16 | float &operator()(int x, int y, int u, int v, int c) { 17 | return image(x*uSize + u, y*vSize + v, c); 18 | } 19 | 20 | float &operator()(int x, int y, int u, int v, int t, int c) { 21 | return image(x*uSize + u, y*vSize + v, t, c); 22 | } 23 | 24 | // quadrilinear 4D sampling (quadriLanczos3 too expensive, 6^4=1296) 25 | // x,y,u,v follow the same coordinate conventions as 26 | // operator() 27 | void sample4D(float x, float y, float u, float v, int t, float *result) { 28 | int ix[2], iy[2], iu[2], iv[2]; // integer indices 29 | float wx[2], wy[2], wu[2], wv[2]; // weighting factors 30 | 31 | if ((x < 0 || y < 0 || x > xSize-1 || y > ySize-1) 32 | || (u < 0 || v < 0 || u > uSize-1 || v > vSize-1)) { 33 | // out of bounds, so return zero 34 | for (int c = 0; c < image.channels; c++) { 35 | result[c] = 0; 36 | } 37 | return; 38 | } 39 | 40 | ix[0] = (int)(floor(x)); 41 | iy[0] = (int)(floor(y)); 42 | iu[0] = (int)(floor(u)); 43 | iv[0] = (int)(floor(v)); 44 | // clamp against bounds 45 | ix[0] = clamp(ix[0],0,xSize-1); 46 | iy[0] = clamp(iy[0],0,ySize-1); 47 | iu[0] = clamp(iu[0],0,uSize-1); 48 | iv[0] = clamp(iv[0],0,vSize-1); 49 | 50 | ix[1] = ix[0]+1; 51 | iy[1] = iy[0]+1; 52 | iu[1] = iu[0]+1; 53 | iv[1] = iv[0]+1; 54 | // clamp against bounds 55 | ix[1] = min(ix[1],xSize-1); 56 | iy[1] = min(iy[1],ySize-1); 57 | iu[1] = min(iu[1],uSize-1); 58 | iv[1] = min(iv[1],vSize-1); 59 | 60 | // calculate the weights for quadrilinear 61 | wx[1] = x-ix[0]; 62 | wy[1] = y-iy[0]; 63 | wu[1] = u-iu[0]; 64 | wv[1] = v-iv[0]; 65 | wx[0] = 1-wx[1]; 66 | wy[0] = 1-wy[1]; 67 | wu[0] = 1-wu[1]; 68 | wv[0] = 1-wv[1]; 69 | 70 | // do the computation 71 | for (int c = 0; c < image.channels; c++) { 72 | result[c] = 0; 73 | } 74 | 75 | for (int i = 0; i < 2; i++) { // go through iu 76 | for (int j = 0; j < 2; j++) { // go through ix 77 | for (int k = 0; k < 2; k++) { // go through iv 78 | for (int l = 0; l < 2; l++) { // go through iy 79 | for (int c = 0; c < image.channels; c++) { 80 | result[c] += ((*this)(ix[j],iy[l],iu[i],iv[k],t,c) * 81 | wx[j]*wy[l]*wu[i]*wv[k]); 82 | } 83 | } 84 | } 85 | } 86 | } 87 | } 88 | 89 | void sample4D(float x, float y, float u, float v, float *result) { 90 | sample4D(x,y,u,v,0,result); 91 | } 92 | 93 | Image image; 94 | int uSize, vSize; 95 | int xSize, ySize; 96 | }; 97 | 98 | class LFFocalStack : public Operation { 99 | public: 100 | void help(); 101 | bool test(); 102 | void parse(vector args); 103 | static Image apply(LightField im, float minAlpha, float maxAlpha, float deltaAlpha); 104 | }; 105 | 106 | class LFPoint : public Operation { 107 | public: 108 | void help(); 109 | bool test(); 110 | void parse(vector args); 111 | static void apply(LightField lf, float x, float y, float z); 112 | }; 113 | 114 | } 115 | #endif 116 | -------------------------------------------------------------------------------- /src/LocalLaplacian.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_LOCAL_LAPLACIAN_H 2 | #define IMAGESTACK_LOCAL_LAPLACIAN_H 3 | namespace ImageStack { 4 | 5 | class LocalLaplacian : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static void apply(Image im, float alpha, float beta); 11 | }; 12 | 13 | 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /src/Network.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_NETWORK_H 2 | #define IMAGESTACK_NETWORK_H 3 | 4 | #ifdef WIN32 5 | //#include 6 | #else 7 | #include 8 | #include 9 | #include 10 | #include 11 | #endif 12 | 13 | #include 14 | using ::std::string; 15 | 16 | #include "macros.h" 17 | #include "Image.h" 18 | namespace ImageStack { 19 | 20 | class Address { 21 | public: 22 | Address() : port(0) {} 23 | Address(string name_, unsigned short port_); 24 | Address(struct sockaddr_in addr_); 25 | 26 | struct sockaddr_in addr; 27 | string hostname; 28 | unsigned short port; 29 | }; 30 | 31 | class TCPServer; 32 | 33 | class TCPConnection { 34 | public: 35 | // connect to a remote port 36 | TCPConnection(Address address); 37 | 38 | // listen (once) on a local port 39 | TCPConnection(unsigned short port); 40 | 41 | ~TCPConnection(); 42 | bool recv(char *buffer, int len); 43 | bool send(const char *buffer, int len); 44 | 45 | Image recvImage(); 46 | void sendImage(Image im); 47 | 48 | friend class TCPServer; 49 | 50 | private: 51 | int fd; 52 | TCPConnection() {} 53 | }; 54 | 55 | namespace UDP { 56 | int recv(unsigned short port, char *buffer, int maxlen, Address *sender = NULL, int timeout = -1); 57 | void send(Address address, const char *buffer, int len); 58 | } 59 | 60 | class TCPServer { 61 | public: 62 | TCPServer(unsigned short port); 63 | ~TCPServer(); 64 | 65 | // returns a connection or NULL 66 | TCPConnection *listen(int timeout = -1); 67 | private: 68 | int sock; 69 | }; 70 | 71 | class UDPServer { 72 | public: 73 | UDPServer(unsigned short port); 74 | ~UDPServer(); 75 | int recv(char *buffer, int maxlen, Address *sender = NULL, int timeout = -1); 76 | private: 77 | int sock; 78 | }; 79 | 80 | } 81 | #endif 82 | -------------------------------------------------------------------------------- /src/NetworkOps.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "NetworkOps.h" 3 | #include "Network.h" 4 | #include 5 | #include 6 | #include "Statistics.h" 7 | 8 | #ifndef NO_SDL 9 | #include 10 | #include 11 | #include 12 | #endif 13 | 14 | namespace ImageStack { 15 | 16 | void Send::help() { 17 | printf("\n-send sends an image over a TCP connection. It has an optional first and second\n" 18 | "argument. The first argument specifies which server to contact, and the second\n" 19 | "argument specifies the port. By default, 127.0.0.1:5678 is used.\n\n" 20 | "Usage: ImageStack -load a.tga -remotedisplay localhost 5678\n"); 21 | } 22 | 23 | #ifdef NO_SDL 24 | bool Send::test() { 25 | printf("SDL required to test send\n"); 26 | return false; 27 | } 28 | #else 29 | 30 | // An anonymous namespace confines these globals to this translation unit 31 | namespace { 32 | int Send_test_port; 33 | Image Send_test_image; 34 | int Send_test_thread(void *) { 35 | Send::apply(Send_test_image, "localhost", Send_test_port); 36 | return 0; 37 | } 38 | } 39 | 40 | bool Send::test() { 41 | Send_test_image = Image(123, 234, 5, 2); 42 | Noise::apply(Send_test_image, 0, 1); 43 | 44 | Send_test_port = randomInt(10000, 15000); 45 | 46 | // Create a child thread to send myself an image 47 | SDL_Thread *thread = SDL_CreateThread(Send_test_thread, NULL); 48 | 49 | // Wait to receive it 50 | Image im = Receive::apply(Send_test_port); 51 | 52 | // Check it's identical to a 53 | im -= Send_test_image; 54 | Stats s(im); 55 | 56 | // Wait for the thread to terminate 57 | SDL_WaitThread(thread, NULL); 58 | 59 | return s.mean() == 0 && s.variance() == 0; 60 | } 61 | #endif 62 | 63 | void Send::parse(vector args) { 64 | switch (args.size()) { 65 | case 0: 66 | apply(stack(0)); 67 | return; 68 | case 1: 69 | apply(stack(0), args[0]); 70 | return; 71 | case 2: 72 | apply(stack(0), args[0], readInt(args[1])); 73 | return; 74 | default: 75 | panic("-send takes at most two arguments\n"); 76 | } 77 | } 78 | 79 | void Send::apply(Image im, string host, int port) { 80 | TCPConnection conn(Address(host, port)); 81 | conn.sendImage(im); 82 | } 83 | 84 | 85 | 86 | void Receive::help() { 87 | printf("\n-receive sets up a TCP server and listens for an image (such as that sent by\n" 88 | "-send). The sole optional argument is the port to listen on. It defaults\n" 89 | "to 5678.\n\n" 90 | "Usage: ImageStack -receive 5243 -save image.jpg\n\n" 91 | " ImageStack -loop --receive --scale 2 --send somewhereelse\n\n"); 92 | 93 | } 94 | 95 | bool Receive::test() { 96 | // tested by -send 97 | return true; 98 | } 99 | 100 | void Receive::parse(vector args) { 101 | assert(args.size() < 2, "-receive takes zero or one argument\n"); 102 | if (args.size() == 0) { push(apply()); } 103 | else { push(apply(readInt(args[0]))); } 104 | } 105 | 106 | 107 | Image Receive::apply(int port) { 108 | // create and bind the server if it hasn't already been created 109 | if (!servers[port]) { 110 | servers[port] = new TCPServer(port); 111 | } 112 | 113 | printf("Listening on port %i\n", port); 114 | TCPConnection *conn = servers[port]->listen(); 115 | printf("Got a connection, reading image...\n"); 116 | 117 | Image im = conn->recvImage(); 118 | 119 | delete conn; 120 | return im; 121 | } 122 | 123 | map Receive::servers; 124 | } 125 | -------------------------------------------------------------------------------- /src/NetworkOps.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_NETWORKOPS_H 2 | #define IMAGESTACK_NETWORKOPS_H 3 | namespace ImageStack { 4 | 5 | #include 6 | 7 | class TCPServer; 8 | 9 | class Send : public Operation { 10 | public: 11 | void help(); 12 | bool test(); 13 | void parse(vector args); 14 | static void apply(Image im, string host = "127.0.0.1", int port = 5678); 15 | }; 16 | 17 | class Receive : public Operation { 18 | public: 19 | void help(); 20 | bool test(); 21 | void parse(vector args); 22 | static Image apply(int port = 5678); 23 | static map servers; 24 | }; 25 | 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/Operation.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_OPERATION_H 2 | #define IMAGESTACK_OPERATION_H 3 | namespace ImageStack { 4 | 5 | class Operation { 6 | public: 7 | virtual ~Operation() {}; 8 | virtual void parse(vector) = 0; 9 | virtual void help() = 0; 10 | virtual bool test() = 0; 11 | }; 12 | 13 | void loadOperations(); 14 | void unloadOperations(); 15 | 16 | // Meta-operations for getting help and testing 17 | 18 | class Help : public Operation { 19 | public: 20 | void help(); 21 | bool test() {return true;} 22 | void parse(vector args); 23 | }; 24 | 25 | class Test : public Operation { 26 | public: 27 | void help(); 28 | bool test() {return true;} 29 | void parse(vector args); 30 | static bool apply(string name, Operation *op); 31 | }; 32 | 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /src/Paint.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_PAINT_H 2 | #define IMAGESTACK_PAINT_H 3 | namespace ImageStack { 4 | 5 | class Eval : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image im, string expression); 11 | }; 12 | 13 | class EvalChannels : public Operation { 14 | public: 15 | void help(); 16 | bool test(); 17 | void parse(vector args); 18 | static Image apply(Image im, vector expressions); 19 | }; 20 | 21 | class Plot : public Operation { 22 | public: 23 | void help(); 24 | bool test(); 25 | void parse(vector args); 26 | static Image apply(Image im, int width, int height, float lineThickness); 27 | }; 28 | 29 | class Composite : public Operation { 30 | public: 31 | void help(); 32 | bool test(); 33 | void parse(vector args); 34 | static void apply(Image dst, Image src); 35 | static void apply(Image dst, Image src, Image mask); 36 | }; 37 | 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /src/PatchMatch.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_PATCHMATCH_H 2 | #define IMAGESTACK_PATCHMATCH_H 3 | namespace ImageStack { 4 | 5 | class PatchMatch : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image source, Image target, int iterations, int patchSize); 11 | static Image apply(Image source, Image target, Image mask, int iterations, int patchSize); 12 | 13 | private: 14 | static float distance(Image source, Image target, Image mask, 15 | int sx, int sy, int st, 16 | int tx, int ty, int tt, 17 | int patchSize, float prevDist); 18 | 19 | }; 20 | 21 | 22 | 23 | class BidirectionalSimilarity : public Operation { 24 | public: 25 | void help(); 26 | bool test(); 27 | void parse(vector args); 28 | static void apply(Image source, Image target, 29 | Image sourceMask, Image targetMask, 30 | float alpha, int numIter, int numIterPM = 5); 31 | 32 | }; 33 | 34 | 35 | class Heal : public Operation { 36 | public: 37 | void help(); 38 | bool test(); 39 | void parse(vector args); 40 | void apply(Image image, Image mask, int numIter = 5, int numIterPM = 5); 41 | }; 42 | 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /src/Plugin.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "Plugin.h" 3 | namespace ImageStack { 4 | 5 | #ifdef __WIN32__ 6 | #else 7 | #include "dlfcn.h" 8 | #endif 9 | 10 | typedef void (*init_imagestack_plugin)(map &); 11 | 12 | #ifdef __WIN32__ 13 | 14 | void Plugin::parse(vector args) { 15 | HMODULE handle = LoadLibrary(args[0].c_str()); 16 | assert(handle, "Could not open %s as a shared library\n", args[0].c_str()); 17 | 18 | FARPROC function = GetProcAddress(handle, "init_imagestack_plugin"); 19 | assert(function, "Could not find symbol init_imagestack_plugin (with C linkage) in %s\n", args[0].c_str()); 20 | 21 | // Pass control to the shared library to inject crap into the operation map 22 | ((init_imagestack_plugin)function)(operationMap); 23 | } 24 | 25 | #else 26 | 27 | void Plugin::parse(vector args) { 28 | void *handle = dlopen(args[0].c_str(), RTLD_LAZY); 29 | assert(handle, "Could not open %s as a shared library: %s\n", args[0].c_str(), dlerror()); 30 | 31 | void *function = dlsym(handle, "init_imagestack_plugin"); 32 | assert(function, "Could not find symbol init_imagestack_plugin (with C linkage) in %s\n", args[0].c_str()); 33 | 34 | // Pass control to the shared library to inject crap into the operation map 35 | ((init_imagestack_plugin)function)(operationMap); 36 | } 37 | 38 | #endif 39 | 40 | bool Plugin::test() { 41 | // The build dependencies to test this are too much. 42 | return true; 43 | } 44 | 45 | void Plugin::help() { 46 | pprintf("-plugin loads a shared object that can add new operations to" 47 | " ImageStack. It does this by calling the function" 48 | " init_imagestack_plugin, which should exist in the shared object with" 49 | " C linkage. To this function it passes the ImageStack operation map," 50 | " into which the plugin may inject new operations.\n\n" 51 | "Usage: ImageStack -plugin foo.so -foo 1 2 3\n"); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/Plugin.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_PLUGIN_H 2 | #define IMAGESTACK_PLUGIN_H 3 | 4 | namespace ImageStack { 5 | 6 | 7 | class Plugin : public Operation { 8 | public: 9 | void parse(vector args); 10 | bool test(); 11 | void help(); 12 | }; 13 | 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/Prediction.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_PREDICTION_H 2 | #define IMAGESTACK_PREDICTION_H 3 | namespace ImageStack { 4 | 5 | class Inpaint : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image im, Image mask); 11 | }; 12 | 13 | class SeamlessClone : public Operation { 14 | public: 15 | void help(); 16 | bool test(); 17 | void parse(vector args); 18 | static void apply(Image dst, Image src, Image mask); 19 | static void apply(Image dst, Image src); 20 | }; 21 | 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /src/Reduction.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_REDUCTION_H 2 | #define IMAGESTACK_REDUCTION_H 3 | 4 | #include "Expr.h" 5 | namespace ImageStack { 6 | 7 | namespace Reduce { 8 | 9 | class RowSum { 10 | public: 11 | void accept(int, float val) { 12 | accum_scalar += val; 13 | } 14 | 15 | void accept(int, Vec::type val) { 16 | accum_vec += val; 17 | } 18 | 19 | float toScalar() { 20 | float result = accum_scalar; 21 | float vec[Vec::width]; 22 | Vec::store(accum_vec, vec); 23 | for (int i = 0; i < Vec::width; i++) { 24 | result += vec[i]; 25 | } 26 | return result; 27 | } 28 | 29 | RowSum() : accum_vec(Vec::zero()), accum_scalar(0) { 30 | } 31 | 32 | 33 | Vec::type accum_vec; 34 | float accum_scalar; 35 | 36 | }; 37 | 38 | template 39 | double sum(const T expr_, const FloatExprType(T) *ptr = NULL) { 40 | 41 | FloatExprType(T) expr(expr_); 42 | 43 | // Compute the domain over which we can vectorize 44 | bool boundedVX = expr.boundedVecX(); 45 | int minVX = expr.minVecX(); 46 | int maxVX = expr.maxVecX(); 47 | 48 | int width = expr.getSize(0); 49 | int height = expr.getSize(1); 50 | int frames = expr.getSize(2); 51 | int channels = expr.getSize(3); 52 | 53 | Expr::Region r = {0, 0, 0, 0, width, height, frames, channels}; 54 | 55 | // Figure out what regions of what functions are required here 56 | expr.prepare(r, 0); 57 | expr.prepare(r, 1); 58 | expr.prepare(r, 2); 59 | 60 | vector rowSums(height); 61 | double total = 0.0; 62 | 63 | for (int c = 0; c < channels; c++) { 64 | for (int t = 0; t < frames; t++) { 65 | 66 | #ifdef _OPENMP 67 | #pragma omp parallel for 68 | #endif 69 | for (int y = 0; y < height; y++) { 70 | RowSum rowSum; 71 | FloatExprType(T)::Iter iter = expr.scanline(0, y, t, c, width); 72 | Expr::evaluateInto(iter, rowSum, 0, width, boundedVX, minVX, maxVX); 73 | rowSums[y] = rowSum.toScalar(); 74 | } 75 | 76 | for (int y = 0; y < height; y++) { 77 | total += rowSums[y]; 78 | } 79 | 80 | } 81 | } 82 | 83 | expr.prepare(r, 3); 84 | 85 | return total; 86 | } 87 | 88 | }; 89 | 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/Stack.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_STACK_H 2 | #define IMAGESTACK_STACK_H 3 | #include 4 | namespace ImageStack { 5 | 6 | // These operations apply only to the stack, so they have no apply 7 | // method. They also have no unit tests. 8 | 9 | class Pop : public Operation { 10 | public: 11 | void help(); 12 | bool test() {return true;} 13 | void parse(vector args); 14 | }; 15 | 16 | class Push : public Operation { 17 | public: 18 | void help(); 19 | bool test() {return true;} 20 | void parse(vector args); 21 | }; 22 | 23 | class Pull : public Operation { 24 | public: 25 | void help(); 26 | bool test() {return true;} 27 | void parse(vector args); 28 | }; 29 | 30 | class Dup : public Operation { 31 | public: 32 | void help(); 33 | bool test() {return true;} 34 | void parse(vector args); 35 | }; 36 | 37 | class Stash : public Operation { 38 | public: 39 | void help(); 40 | bool test() {return true;} 41 | void parse(vector args); 42 | static map stash; 43 | }; 44 | 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /src/WLS.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "WLS.h" 3 | #include "Calculus.h" 4 | #include "Color.h" 5 | #include "Arithmetic.h" 6 | #include "Convolve.h" 7 | #include "Geometry.h" 8 | #include "Paint.h" 9 | #include "Statistics.h" 10 | #include "LAHBPCG.h" 11 | namespace ImageStack { 12 | 13 | void WLS::help() { 14 | pprintf("-wls filters the image with the wls-filter described in the paper" 15 | " Edge-Preserving Decompositions for Multi-Scale Tone and Detail" 16 | " Manipulation by Farbman et al. The first parameter (alpha) controls" 17 | " the sensitivity to edges, and the second one (lambda) controls the" 18 | " amount of smoothing.\n" 19 | "\n" 20 | "Usage: ImageStack -load in.jpg -wls 1.2 0.25 -save blurry.jpg\n"); 21 | } 22 | 23 | bool WLS::test() { 24 | // Make a synthetic noisy image with an edge 25 | Image a(400, 300, 1, 3); 26 | for (int y = 0; y < 300; y++) { 27 | for (int x = 0; x < 300; x++) { 28 | float dy = (y-150)/100.0; 29 | float dx = (x-200)/100.0; 30 | float r = dx*dx + dy*dy; 31 | a(x, y, 0) = (r < 1) ? 1.0 : 0; 32 | a(x, y, 1) = (r < 1) ? 0.5 : 0; 33 | a(x, y, 2) = (r < 1) ? 0.25 : 0; 34 | } 35 | } 36 | Noise::apply(a, -0.2, 0.2); 37 | 38 | a = WLS::apply(a, 1.0, 0.5, 0.01); 39 | 40 | // Make sure wls cleaned it up 41 | for (int i = 0; i < 100; i++) { 42 | int x = randomInt(0, a.width-1); 43 | int y = randomInt(0, a.height-1); 44 | float dy = (y-150)/100.0; 45 | float dx = (x-200)/100.0; 46 | float r = dx*dx + dy*dy; 47 | if (r > 0.9 && r < 1.1) continue; 48 | float correct = (r < 1) ? 1 : 0; 49 | if (fabs(a(x, y, 0) - correct) > 0.1) return false; 50 | if (fabs(a(x, y, 1) - correct*0.5) > 0.1) return false; 51 | if (fabs(a(x, y, 2) - correct*0.25) > 0.1) return false; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | void WLS::parse(vector args) { 58 | float alpha = 0, lambda = 0; 59 | 60 | assert(args.size() == 2, "-wls takes two arguments"); 61 | 62 | alpha = readFloat(args[0]); 63 | lambda = readFloat(args[1]); 64 | 65 | Image im = apply(stack(0), alpha, lambda, 0.01); 66 | 67 | pop(); 68 | push(im); 69 | } 70 | 71 | Image WLS::apply(Image im, float alpha, float lambda, float tolerance) { 72 | 73 | Image L; 74 | 75 | // Precalculate the log-luminance differences Lx and Ly 76 | if (im.channels == 3) { 77 | L = ColorConvert::apply(im, "rgb", "y"); 78 | } else { 79 | vector mat; 80 | for (int c = 0; c < im.channels; c++) { 81 | mat.push_back(1.0f/im.channels); 82 | } 83 | L = ColorMatrix::apply(im, mat); 84 | } 85 | 86 | Stats s(L); 87 | // If min(s) is less than zero, chanses are that we already are in the log-domain. 88 | // In any case, we cannot take the log of negative numbers.. 89 | if (s.minimum() >= 0) { 90 | L += 0.0001; 91 | Log::apply(L); 92 | } 93 | 94 | Image Lx = L.copy(); 95 | Gradient::apply(Lx, 'x'); 96 | 97 | Image Ly = L.copy(); 98 | Gradient::apply(Ly, 'y'); 99 | 100 | // Lx = lambda / (|dl(p)/dx|^alpha + eps) 101 | // Ly = lambda / (|dl(p)/dy|^alpha + eps) 102 | for (int t = 0; t < L.frames; t++) { 103 | for (int y = 0; y < L.height; y++) { 104 | for (int x = 0; x < L.width; x++) { 105 | Lx(x, y, t, 0) = lambda / (powf(fabs(Lx(x, y, t, 0)), alpha) + 0.0001); 106 | Ly(x, y, t, 0) = lambda / (powf(fabs(Ly(x, y, t, 0)), alpha) + 0.0001); 107 | } 108 | // Nuke the weights for the boundary condition 109 | Lx(0, y, t, 0) = 0; 110 | } 111 | for (int x = 0; x < L.width; x++) { 112 | Ly(x, 0, t, 0) = 0; 113 | } 114 | } 115 | 116 | // Data weights equal to 1 all over... 117 | Image w(im.width, im.height, 1, 1); 118 | w.set(1); 119 | 120 | // For this filter gx and gy is 0 all over (target gradient is smooth) 121 | Image zeros(im.width, im.height, 1, im.channels); 122 | 123 | // Solve using the fast preconditioned conjugate gradient. 124 | Image x = LAHBPCG::apply(im, zeros, zeros, w, Lx, Ly, 200, tolerance); 125 | 126 | return x; 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/WLS.h: -------------------------------------------------------------------------------- 1 | #ifndef WLS_H 2 | #define WLS_H 3 | namespace ImageStack { 4 | 5 | class WLS : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static Image apply(Image im, float alpha, float lambda, float tolerance); 11 | }; 12 | 13 | } 14 | #endif 15 | -------------------------------------------------------------------------------- /src/Wavelet.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_WAVELET_H 2 | #define IMAGESTACK_WAVELET_H 3 | namespace ImageStack { 4 | 5 | class Haar : public Operation { 6 | public: 7 | void help(); 8 | bool test(); 9 | void parse(vector args); 10 | static void apply(Image im, int times = -1); 11 | }; 12 | 13 | class InverseHaar : public Operation { 14 | public: 15 | void help(); 16 | bool test(); 17 | void parse(vector args); 18 | static void apply(Image im, int times = -1); 19 | }; 20 | 21 | class Daubechies : public Operation { 22 | public: 23 | void help(); 24 | bool test(); 25 | void parse(vector args); 26 | static void apply(Image im); 27 | }; 28 | 29 | class InverseDaubechies : public Operation { 30 | public: 31 | void help(); 32 | bool test(); 33 | void parse(vector args); 34 | static void apply(Image im); 35 | }; 36 | 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /src/imagestack: -------------------------------------------------------------------------------- 1 | # bash completion rule 2 | 3 | _ImageStack() 4 | { 5 | local cur prev opts 6 | COMPREPLY=() 7 | cur="${COMP_WORDS[COMP_CWORD]}" 8 | prev="${COMP_WORDS[COMP_CWORD-1]}" 9 | opts=$( ImageStack -help | tail -n1 ) 10 | 11 | 12 | if [[ -z ${cur} ]]; then 13 | if [[ ${opts} =~ ${prev} ]]; then 14 | # save cursor pos 15 | echo -e "\033[s" 16 | ImageStack -help "${prev/-/}" 17 | # restore cursor pos 18 | echo 19 | echo -e "${COMP_WORDS[*]}" "\b\c" 20 | return 0 21 | fi 22 | fi 23 | 24 | case "${cur}" in 25 | -*) 26 | COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) 27 | return 0 28 | ;; 29 | *) 30 | COMPREPLY=( $(compgen -o default "${cur}") ) 31 | esac 32 | 33 | } 34 | complete -o filenames -F _ImageStack ImageStack -------------------------------------------------------------------------------- /src/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_MACROS_H 2 | #define IMAGESTACK_MACROS_H 3 | 4 | #include 5 | 6 | namespace ImageStack { 7 | 8 | #ifdef WIN32 9 | #undef min 10 | #undef max 11 | #endif 12 | 13 | template 14 | inline T max(const T &a, const T &b) { 15 | if (a > b) { return a; } 16 | return b; 17 | } 18 | 19 | template 20 | inline T min(const T &a, const T &b) { 21 | if (a < b) { return a; } 22 | return b; 23 | } 24 | 25 | template 26 | inline T max(const T &a, const T &b, const T &c) { 27 | if (a > b && a > c) { return a; } 28 | if (b > c) { return b; } 29 | return c; 30 | } 31 | 32 | template 33 | inline T min(const T &a, const T &b, const T &c) { 34 | if (a < b && a < c) { return a; } 35 | if (b < c) { return b; } 36 | return c; 37 | } 38 | 39 | template 40 | inline T clamp(const T &a, const T &b, const T &c) { 41 | if (a < b) { return b; } 42 | if (a > c) { return c; } 43 | return a; 44 | } 45 | 46 | // Equal to within 1/100. Useful for testing 47 | static inline bool nearlyEqual(float a, float b) { 48 | if (fabs(b) < 1) return fabs(a-b) < 0.01; 49 | return fabs(a/b - 1.0) < 0.01; 50 | } 51 | 52 | #ifndef M_PI 53 | #define M_PI 3.14159265 54 | #endif 55 | 56 | #ifndef E 57 | #define E 2.7182818284590451 58 | #endif 59 | 60 | #define INF (std::numeric_limits::infinity()) 61 | 62 | static inline float sinc(float x) { 63 | return x == 0 ? 1 : sinf(M_PI * x) / (M_PI * x); 64 | } 65 | 66 | // Map high dynamic range values to [0, 255], so that 0->0, and 1->255 67 | static inline unsigned char HDRtoLDR(float x) { 68 | if (x < 0) { return 0; } 69 | if (x > 1) { return 255; } 70 | return (unsigned char)(x * 255.0f + 0.49999f); 71 | } 72 | 73 | // Map low dynamic range values to [0, 1] inclusive. 74 | static inline float LDRtoHDR(unsigned char x) { 75 | return x * (1.0f/255); 76 | } 77 | 78 | static inline float LDR16toHDR(unsigned short x) { 79 | return x * (1.0f/65535); 80 | } 81 | 82 | static inline unsigned short HDRtoLDR16(float x) { 83 | if (x < 0) return 0; 84 | if (x > 1) return 65535; 85 | return (unsigned short)(x * 65535.0f + 0.49999f); 86 | } 87 | 88 | #include 89 | 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGESTACK_MAIN_H 2 | #define IMAGESTACK_MAIN_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | using ::std::shared_ptr; 22 | using ::std::string; 23 | using ::std::vector; 24 | using ::std::pair; 25 | using ::std::make_pair; 26 | using ::std::map; 27 | using ::std::list; 28 | using ::std::swap; 29 | using ::std::isfinite; 30 | 31 | #ifndef __GNUC__ 32 | using ::std::isinf; 33 | using ::std::isnan; 34 | #endif 35 | 36 | #ifdef _MSC_VER 37 | #include 38 | #include 39 | #define popen _popen 40 | #define pclose _pclose 41 | #define isnan _isnan 42 | #define isfinite _finite 43 | inline float isinf(float x) { 44 | return (!_finite(x) && !_isnan(x)); 45 | } 46 | #endif 47 | 48 | // Some core files that everyone should include 49 | #include "macros.h" 50 | #include "Exception.h" 51 | #include "Operation.h" 52 | 53 | namespace ImageStack { 54 | // time since program start in seconds (if using from a library, time since ImageStack::begin) 55 | float currentTime(); 56 | } 57 | 58 | #include "Image.h" 59 | namespace ImageStack { 60 | 61 | // Below are the data structures and functions available to operations: 62 | 63 | // Deal with the stack of images that gives this program its name 64 | Image &stack(size_t index); 65 | void push(Image); 66 | void pop(); 67 | void dup(); 68 | void pull(size_t); 69 | 70 | // Parse ints, floats, chars, and ImageStack commands 71 | int readInt(string); 72 | float readFloat(string); 73 | char readChar(string); 74 | void parseCommands(vector); 75 | 76 | // Fire up and shut down imagestack. This populates the operation map, 77 | // and sets a starting time for timing ops. 78 | void start(); 79 | void end(); 80 | 81 | // Generate a uniform random integer within [min, max] 82 | int randomInt(int min, int max); 83 | 84 | // Generate a uniform random float within [min, max] 85 | float randomFloat(float min, float max); 86 | 87 | // pretty-print some help text, by word wrapping at 79 chars 88 | void pprintf(const char *str); 89 | 90 | // Check if two images are nearly equal for unit testing 91 | bool nearlyEqual(Image a, Image b); 92 | 93 | // The map of operations, which converts strings to operation 94 | // objects. Only meta-operations like help should need to access this. 95 | extern map operationMap; 96 | typedef map::iterator OperationMapIterator; 97 | 98 | } 99 | #endif 100 | -------------------------------------------------------------------------------- /src/precomputations.py: -------------------------------------------------------------------------------- 1 | # this file makes all look up tables needed by ImageStack 2 | 3 | from math import * 4 | 5 | f = open("tables.h", 'w') 6 | 7 | f.write("#ifndef TABLES_H\n") 8 | f.write("#define TABLES_H\n") 9 | f.write("#include \n") 10 | f.write("#include \"header.h\"\n") 11 | 12 | # lanczos filters of various widths 13 | accuracy = 1024 14 | for lobes in [2, 3, 4]: 15 | name = "lanczos_%i" % lobes 16 | size = (lobes + 1) * accuracy * 2 17 | f.write("static float _%s[%i] = {" % (name, size)) 18 | for i in xrange(size): 19 | x = (i - size/2 + 0.5) / float(accuracy) 20 | x *= pi 21 | y = sin(x)/x * sin(x/lobes)/(x/lobes) 22 | if sin(x/lobes)/(x/lobes) < 0: y = 0 23 | f.write(`y`) 24 | if y != 0: f.write('f') 25 | if i < size-1: f.write(', ') 26 | f.write("};\n\n") 27 | 28 | f.write("static inline float %s(float x) {\n" % name) 29 | f.write(" return _%s[(int)(x * %i.0) + %i];\n" % (name, accuracy, size/2)) 30 | f.write("}\n\n") 31 | 32 | 33 | # precomputed exp function for [-10, 10] 34 | size = 4096 35 | f.write("static float _fastexp[%i] = {" % size) 36 | for i in xrange(size): 37 | val = exp(i/float(size)*20 - 10) 38 | f.write(`val`) 39 | if val != 0: f.write('f') 40 | if i < size -1: f.write(', ') 41 | f.write("};\n\n") 42 | f.write("static inline float fastexp(float x) {\n") 43 | f.write(" if (x < -9) return exp(x);") 44 | f.write(" if (x > 9) return exp(x);") 45 | f.write(" return _fastexp[(int)(x * 0.05f * %i) + %i];" % (size, size/2)) 46 | f.write("}\n\n") 47 | 48 | f.write("#include \"footer.h\"\n") 49 | f.write("#endif\n") 50 | 51 | 52 | -------------------------------------------------------------------------------- /util/MATLAB/loadTMP.m: -------------------------------------------------------------------------------- 1 | % Load an ImageStack TMP file, an up to 4-dimensional array of integer or 2 | % floating point data. 3 | % 4 | % output permutes the dimensions so that the output is: 5 | % [height width channels frames] 6 | % 7 | % Format specification is here: 8 | % https://github.com/abadams/ImageStack/blob/master/src/FileTMP.cpp 9 | function output = loadTMP(filename) 10 | 11 | type_strings = {'*float32', '*float64', '*uint8', '*int8', ... 12 | '*uint16', '*int16', '*uint32', '*int32', '*uint64', '*int64'}; 13 | 14 | fid = fopen(filename, 'r'); 15 | header = fread(fid, 5, '*int32'); 16 | 17 | width = header(1); 18 | height = header(2); 19 | frames = header(3); 20 | channels = header(4); 21 | type_code = header(5); 22 | 23 | if width < 1 || height < 1 || frames < 1 || channels < 1 || ... 24 | type_code < 0 || type_code > 9 25 | fclose(fid); 26 | error('Invalid header: %d %d %d %d %d', ... 27 | width, height, frames, channels, type_code); 28 | end 29 | 30 | num_elements = width * height * frames * channels; 31 | type_string = type_strings{type_code + 1}; % MATLAB is one-based. 32 | 33 | output = fread(fid, num_elements, type_string); 34 | fclose(fid); 35 | 36 | % Input is stored row major. 37 | output = reshape(output, [width, height, frames, channels]); 38 | 39 | % Permute dimensions so that each image is column major, and frames comes 40 | % last. 41 | output = permute(output, [2 1 4 3]); 42 | -------------------------------------------------------------------------------- /util/MATLAB/saveTMP.m: -------------------------------------------------------------------------------- 1 | % Write an up to 4-dimensional matrix 'a' to 'filename' in the TMP format. 2 | % 3 | % a should be in the MATLAB convention: [height width channels frames] 4 | % a will be permuted to the TMP file convention: 5 | % [width height frames channels] 6 | % 7 | % Format specification is here: 8 | % https://github.com/abadams/ImageStack/blob/master/src/FileTMP.cpp 9 | function [] = saveTMP(a, filename) 10 | 11 | if ndims(a) > 4 12 | error('TMP only supports up to 4 dimensions.'); 13 | end 14 | 15 | switch class(a) 16 | case 'single' 17 | type_code = int32(0); 18 | case 'double' 19 | type_code = int32(1); 20 | case 'uint8' 21 | type_code = int32(2); 22 | case 'int8' 23 | type_code = int32(3); 24 | case 'uint16' 25 | type_code = int32(4); 26 | case 'int16' 27 | type_code = int32(5); 28 | case 'uint32' 29 | type_code = int32(6); 30 | case 'int32' 31 | type_code = int32(7); 32 | case 'uint64' 33 | type_code = int32(8); 34 | case 'int64' 35 | type_code = int32(9); 36 | otherwise 37 | error('TMP only supports single, double, and {u}int{8,16,32,64} numeric matrices.'); 38 | end 39 | 40 | % Pick a type string for MATLAB's fwrite() based on the type code. 41 | type_strings = {'*float32', '*float64', '*uint8', '*int8', ... 42 | '*uint16', '*int16', '*uint32', '*int32', '*uint64', '*int64'}; 43 | type_string = type_strings{type_code + 1}; 44 | 45 | % Undo permutation from loadTMP: 46 | % Turn MATLAB [height, width, channels, frames] back into TMP format's 47 | % [width, height, frames, channels]. 48 | a = ipermute(a, [2 1 4 3]); 49 | 50 | % Now grab its dimensions. 51 | width = int32(size(a, 1)); 52 | height = int32(size(a, 2)); 53 | frames = int32(size(a, 3)); 54 | channels = int32(size(a, 4)); 55 | 56 | % Turn it into a single giant vector. 57 | a = a(:); 58 | 59 | % Write the file. 60 | fid = fopen(filename, 'w'); 61 | fwrite(fid, [width height frames channels type_code], '*int32'); 62 | fwrite(fid, a, type_string); 63 | fclose(fid); 64 | -------------------------------------------------------------------------------- /util/MATLAB/testTMP.m: -------------------------------------------------------------------------------- 1 | % Test TMP file reading and writing by saving to the given filename, 2 | % reading it back, and checking for equality. 3 | function ok = testTMP(temp_filename) 4 | 5 | % Some decent size that's not too big. 6 | % Pick odd sizes on purpose. 7 | height = 767; 8 | width = 1021; 9 | channels = 3; 10 | frames = 7; 11 | 12 | sz = [height, width, channels, frames]; 13 | 14 | fprintf('Testing single...'); 15 | a = single(rand(sz)); 16 | saveTMP(a, temp_filename); 17 | b = loadTMP(temp_filename); 18 | 19 | if ~isequal(a, b) 20 | fprintf('FAILED\n'); 21 | ok = false; 22 | return; 23 | else 24 | fprintf('passed.\n'); 25 | end 26 | 27 | fprintf('Testing double...'); 28 | a = double(rand(sz)); 29 | saveTMP(a, temp_filename); 30 | b = loadTMP(temp_filename); 31 | 32 | if ~isequal(a, b) 33 | fprintf('FAILED\n'); 34 | ok = false; 35 | return; 36 | else 37 | fprintf('passed.\n'); 38 | end 39 | 40 | fprintf('Testing uint8...'); 41 | a = uint8(rand(sz)); 42 | saveTMP(a, temp_filename); 43 | b = loadTMP(temp_filename); 44 | 45 | if ~isequal(a, b) 46 | fprintf('FAILED\n'); 47 | ok = false; 48 | return; 49 | else 50 | fprintf('passed.\n'); 51 | end 52 | 53 | fprintf('Testing int8...'); 54 | a = int8(rand(sz)); 55 | saveTMP(a, temp_filename); 56 | b = loadTMP(temp_filename); 57 | 58 | if ~isequal(a, b) 59 | fprintf('FAILED\n'); 60 | ok = false; 61 | return; 62 | else 63 | fprintf('passed.\n'); 64 | end 65 | 66 | fprintf('Testing uint16...'); 67 | a = uint16(rand(sz)); 68 | saveTMP(a, temp_filename); 69 | b = loadTMP(temp_filename); 70 | 71 | if ~isequal(a, b) 72 | fprintf('FAILED\n'); 73 | ok = false; 74 | return; 75 | else 76 | fprintf('passed.\n'); 77 | end 78 | 79 | fprintf('Testing int16...'); 80 | a = int16(rand(sz)); 81 | saveTMP(a, temp_filename); 82 | b = loadTMP(temp_filename); 83 | 84 | if ~isequal(a, b) 85 | fprintf('FAILED\n'); 86 | ok = false; 87 | return; 88 | else 89 | fprintf('passed.\n'); 90 | end 91 | 92 | fprintf('Testing uint32...'); 93 | a = uint32(rand(sz)); 94 | saveTMP(a, temp_filename); 95 | b = loadTMP(temp_filename); 96 | 97 | if ~isequal(a, b) 98 | fprintf('FAILED\n'); 99 | ok = false; 100 | return; 101 | else 102 | fprintf('passed.\n'); 103 | end 104 | 105 | fprintf('Testing int32...'); 106 | a = int32(rand(sz)); 107 | saveTMP(a, temp_filename); 108 | b = loadTMP(temp_filename); 109 | 110 | if ~isequal(a, b) 111 | fprintf('FAILED\n'); 112 | ok = false; 113 | return; 114 | else 115 | fprintf('passed.\n'); 116 | end 117 | 118 | fprintf('Testing uint64...'); 119 | a = uint64(rand(sz)); 120 | saveTMP(a, temp_filename); 121 | b = loadTMP(temp_filename); 122 | 123 | if ~isequal(a, b) 124 | fprintf('FAILED\n'); 125 | ok = false; 126 | return; 127 | else 128 | fprintf('passed.\n'); 129 | end 130 | 131 | fprintf('Testing int64...'); 132 | a = int64(rand(sz)); 133 | saveTMP(a, temp_filename); 134 | b = loadTMP(temp_filename); 135 | 136 | if ~isequal(a, b) 137 | fprintf('FAILED\n'); 138 | ok = false; 139 | return; 140 | else 141 | fprintf('passed.\n'); 142 | end 143 | 144 | fprintf('All tests PASSED.'); 145 | ok = true; -------------------------------------------------------------------------------- /util/numpy/loadTMP.py: -------------------------------------------------------------------------------- 1 | # Load an ImageStack TMP file, an up to 4-dimensional array of integer or 2 | # floating point data. 3 | # Format specification is here: 4 | # https://github.com/abadams/ImageStack/blob/master/src/FileTMP.cpp 5 | # 6 | # The output is permutted into the numpy C-contiguous convention: (frames, height, width, channels). 7 | # channels changes the fastest in memory, frames the slowest. 8 | import numpy as np 9 | 10 | def loadTMP(filename): 11 | with open(filename, 'rb') as f: 12 | buffer = f.read() 13 | 14 | type_code_list = \ 15 | [ 16 | np.dtype(np.float32), 17 | np.dtype(np.float64), 18 | np.dtype(np.uint8), 19 | np.dtype(np.int8), 20 | np.dtype(np.uint16), 21 | np.dtype(np.int16), 22 | np.dtype(np.uint32), 23 | np.dtype(np.int32), 24 | np.dtype(np.uint64), 25 | np.dtype(np.int64), 26 | ] 27 | 28 | offset = 0 29 | tmp_dims = np.frombuffer(buffer, count=4, dtype=np.int32) 30 | offset += tmp_dims.nbytes 31 | type_code = np.frombuffer(buffer, count=1, offset=offset, dtype=np.int32) 32 | offset += type_code.nbytes 33 | data_type = type_code_list[int(type_code)] 34 | 35 | # The TMP file writes the dimensions as: 36 | # [width height frames channels] 37 | # Rewrite it in the numpy order: 38 | # (channels, frames, height, width) 39 | a2_dims = np.flipud(tmp_dims) 40 | 41 | # Buffer stores the data as: (channels, frames, height, width). 42 | a2 = np.frombuffer(buffer, offset=offset, dtype=data_type) 43 | a2.shape = a2_dims 44 | 45 | # Permute the dimensions so that the data is returned in the numpy C-contiguous convention: 46 | # (frames, height, width, channels). 47 | return a2.transpose((1, 2, 3, 0)) 48 | 49 | -------------------------------------------------------------------------------- /util/numpy/saveTMP.py: -------------------------------------------------------------------------------- 1 | # Write an up to 4-dimensional numpy.array 'a' to 'filename' in the ImageStack TMP format. 2 | # Format specification is here: 3 | # https://github.com/abadams/ImageStack/blob/master/src/FileTMP.cpp 4 | # 5 | # We assume a is in numpy's C-continguous convention: (frames, height, width, channels). 6 | # channels changes the fastest in memory, frames the slowest. 7 | # It does not have to be stored that way, we just assume those are the dimensions. 8 | # 9 | # a will be written to disk in the TMP file convention: (channels frames height width). 10 | # width changes the fastest in memory, channels the slowest. 11 | # Note that the TMP file writes dimensions in the opposite order from numpy: 12 | # [width, height, frames, channels]. 13 | # 14 | import numpy as np 15 | 16 | def saveTMP(a, filename): 17 | if a.ndim > 4: 18 | raise ValueError('TMP only supports up to 4 dimensions.') 19 | 20 | type_code_map = \ 21 | { 22 | np.dtype(np.float32): np.int32(0), 23 | np.dtype(np.float64): np.int32(1), 24 | np.dtype(np.uint8): np.int32(2), 25 | np.dtype(np.int8): np.int32(3), 26 | np.dtype(np.uint16): np.int32(4), 27 | np.dtype(np.int16): np.int32(5), 28 | np.dtype(np.uint32): np.int32(6), 29 | np.dtype(np.int32): np.int32(7), 30 | np.dtype(np.uint64): np.int32(8), 31 | np.dtype(np.int64): np.int32(9), 32 | } 33 | 34 | type_code = type_code_map.get(a.dtype, np.int32(-1)) 35 | if type_code == -1: 36 | raise ValueError( 37 | 'TMP only supports float{32,64} and {u}int{8,16,32,64} numpy.arrays.') 38 | 39 | # Permute the axes to [width height frames channels]. 40 | # First pad the dimensions 41 | a2 = a.copy() 42 | # f.atleast_3d is nice, but numpy doesn't come with a 4D version. 43 | # I also want to add dimensions to the front, not the end. 44 | a2.shape = (1,) * (4 - a2.ndim) + a2.shape 45 | a2 = a2.transpose((3, 0, 1, 2)) 46 | 47 | # TMP wants dimensions written in the opposite order. 48 | tmp_dims = np.flipud(np.array(a2.shape, dtype=np.int32)) 49 | 50 | with open(filename, 'wb') as f: 51 | f.write(tmp_dims.tobytes()) 52 | f.write(type_code.tobytes()) 53 | f.write(a2.tobytes()) 54 | -------------------------------------------------------------------------------- /util/numpy/testTMP.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from loadTMP import loadTMP 3 | from saveTMP import saveTMP 4 | 5 | # Shift a uniformly distributed array to an integer range. 6 | def _shift_to_int(float_array, lo, hi, dtype): 7 | return (lo + (hi - lo) * float_array).astype(dtype) 8 | 9 | # Test TMP file reading and writing by saving to the given filename, 10 | # reading it back, and checking for equality. 11 | def testTMP(temp_filename): 12 | 13 | # Some decent size that's not too big. 14 | # Pick odd sizes on purpose. 15 | height = 767 16 | width = 1021 17 | channels = 3 18 | frames = 7 19 | int_lo = 37 20 | int_hi = 124 21 | 22 | shape = (height, width, channels, frames) 23 | 24 | print('Testing float32...', end='') 25 | a = np.random.random_sample(shape).astype(np.float32) 26 | saveTMP(a, temp_filename) 27 | b = loadTMP(temp_filename) 28 | 29 | if np.array_equal(a, b): 30 | print('passed.') 31 | else: 32 | print('FAILED.') 33 | return False 34 | 35 | print('Testing double...', end='') 36 | a = np.random.random_sample(shape).astype(np.float64) 37 | saveTMP(a, temp_filename) 38 | b = loadTMP(temp_filename) 39 | 40 | if np.array_equal(a, b): 41 | print('passed.') 42 | else: 43 | print('FAILED.') 44 | return False 45 | 46 | print('Testing uint8...', end='') 47 | a = _shift_to_int(np.random.random_sample(shape), 48 | int_lo, int_hi, np.uint8) 49 | saveTMP(a, temp_filename) 50 | b = loadTMP(temp_filename) 51 | 52 | if np.array_equal(a, b): 53 | print('passed.') 54 | else: 55 | print('FAILED.') 56 | return False 57 | 58 | print('Testing int8...', end='') 59 | a = _shift_to_int(np.random.random_sample(shape), 60 | int_lo, int_hi, np.int8) 61 | saveTMP(a, temp_filename) 62 | b = loadTMP(temp_filename) 63 | 64 | if np.array_equal(a, b): 65 | print('passed.') 66 | else: 67 | print('FAILED.') 68 | return False 69 | 70 | print('Testing uint16...', end='') 71 | a = _shift_to_int(np.random.random_sample(shape), 72 | int_lo, int_hi, np.uint16) 73 | saveTMP(a, temp_filename) 74 | b = loadTMP(temp_filename) 75 | 76 | if np.array_equal(a, b): 77 | print('passed.') 78 | else: 79 | print('FAILED.') 80 | return False 81 | 82 | print('Testing int16...', end='') 83 | a = _shift_to_int(np.random.random_sample(shape), 84 | int_lo, int_hi, np.int16) 85 | saveTMP(a, temp_filename) 86 | b = loadTMP(temp_filename) 87 | 88 | if np.array_equal(a, b): 89 | print('passed.') 90 | else: 91 | print('FAILED.') 92 | return False 93 | 94 | print('Testing uint32...', end='') 95 | a = _shift_to_int(np.random.random_sample(shape), 96 | int_lo, int_hi, np.uint32) 97 | saveTMP(a, temp_filename) 98 | b = loadTMP(temp_filename) 99 | 100 | if np.array_equal(a, b): 101 | print('passed.') 102 | else: 103 | print('FAILED.') 104 | return False 105 | 106 | print('Testing int32...', end='') 107 | a = _shift_to_int(np.random.random_sample(shape), 108 | int_lo, int_hi, np.int32) 109 | saveTMP(a, temp_filename) 110 | b = loadTMP(temp_filename) 111 | 112 | if np.array_equal(a, b): 113 | print('passed.') 114 | else: 115 | print('FAILED.') 116 | return False 117 | 118 | print('Testing uint64...', end='') 119 | a = _shift_to_int(np.random.random_sample(shape), 120 | int_lo, int_hi, np.uint64) 121 | saveTMP(a, temp_filename) 122 | b = loadTMP(temp_filename) 123 | 124 | if np.array_equal(a, b): 125 | print('passed.') 126 | else: 127 | print('FAILED.') 128 | return False 129 | 130 | print('Testing int64...', end='') 131 | a = _shift_to_int(np.random.random_sample(shape), 132 | int_lo, int_hi, np.int64) 133 | saveTMP(a, temp_filename) 134 | b = loadTMP(temp_filename) 135 | 136 | if np.array_equal(a, b): 137 | print('passed.') 138 | else: 139 | print('FAILED.') 140 | return False 141 | 142 | print('All tests PASSED.') 143 | return True 144 | --------------------------------------------------------------------------------
43 | -------------------------------------------------------------------------------- /docs/make-docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | cat header.inc > index.html 3 | #echo "ImageStack Help" > index.html 4 | #echo "" >> index.html 5 | echo "

ImageStack Operation Listing

" >> index.html 6 | ImageStack -help | tail -n2 | sed "s/-\([^ ]*\)/-\1<\/a>/g" >> index.html 7 | OPS=`ImageStack -help | grep "^-" | tail -n1` 8 | for OPERATION in $OPS; do 9 | OPERATION=${OPERATION/-/} 10 | echo "

${OPERATION}

" >> index.html; 11 | echo "

" >> index.html; 12 | ImageStack -help ${OPERATION} | grep -v "Performing operation -help" | sed "s/^$/

/" | sed "s/\\$//g" >> index.html; 13 | echo "

" >> index.html; 14 | done 15 | echo "