Hauptseite   Klassenhierarchie   Auflistung der Dateien  

painter.cpp

00001 /**********************************************************************************
00002 * Copyright (c) 2003, Christoph Rueegg <opendev@cdrnet.ch> and Matthias Bader     *
00003 * Partially based on ideas of Tim Weyrich <weyrich@inf.ethz.ch>                   *
00004 * and/or the Swiss Federal Institute of Technology http://www.ethz.ch             *
00005 * All rights reserved.                                                            *
00006 *                                                                                 *
00007 * Project Website: http://www.cdrnet.net/projects/painter/                        *
00008 *                                                                                 *
00009 * Redistribution and use in source and binary forms, with or without modification,*
00010 * are permitted provided that the following conditions are met:                   *
00011 *                                                                                 *
00012 * 1. Redistributions of source code must retain the above copyright notice,       *
00013 * this list of conditions and the following disclaimer.                           *
00014 *                                                                                 *
00015 * 2. Redistributions in binary form must reproduce the above copyright notice,    *
00016 * this list of conditions and the following disclaimer in the documentation       *
00017 * and/or other materials provided with the distribution.                          *
00018 *                                                                                 *
00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"     *
00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE       *
00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE      *
00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE        *
00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR             *
00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF            *
00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS        *
00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN         *
00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)         *
00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF          *
00029 * THE POSSIBILITY OF SUCH DAMAGE.                                                 *
00030 **********************************************************************************/
00031 
00032 #include <iostream>
00033 #include "image/grayimage.h"
00034 #include "image/rgbimage.h"
00035 #include "image/alphaimage.h"
00036 #include "container/container.h"
00037 #include "filter/filterblockfill.h"
00038 #include "filter/filterinvert.h"
00039 #include "filter/filtercopyblock.h"
00040 #include "filter/filterfloodfill.h"
00041 #include "filter/filterdiff.h"
00042 #include "filter/filterlevel.h"
00043 #include "filter/filtercontrast.h"
00044 #include "filter/filteredge.h"
00045 #include "filter/filtergrave.h"
00046 #include "filter/filternoise.h"
00047 #include "filter/filterswirl.h"
00048 #include "filter/filtertest.h"
00049 #include "filter/filterunsharp.h"
00050 #include "filter/filterstamp.h"
00051 #include "filter/filterpr.h"
00052 #include "filter/filterpixel8.h"
00053 #include "filter/filterposterize.h"
00054 
00055 //#include "image/hybridchannel.cpp"
00056 //#include "image/channel.cpp"
00057 
00058 using namespace std;
00059 
00060 void PrintFunctions()
00061 {
00062   cout << "##### Painter Function List ################" << endl;
00063   cout << "#                                          #" << endl;
00064   cout << "# *** General **************************** #" << endl;
00065   cout << "# q:     Quit Painter                      #" << endl;
00066   cout << "# 1-7:   Load Image in Grayscale Mode      #" << endl;
00067   cout << "# 8-0:   Load Image in Color Mode          #" << endl;
00068   cout << "# s:     Save Image                        #" << endl;
00069   cout << "#                                          #" << endl;
00070   cout << "# *** Basic Filters ********************** #" << endl;
00071   cout << "# i:     Invert                            #" << endl;
00072   cout << "# b:     Block Fill                        #" << endl;
00073   cout << "# f:     Flood Fill                        #" << endl;
00074   cout << "# c:     Copy Block                        #" << endl;
00075   cout << "#                                          #" << endl;
00076   cout << "# *** Static Filters ********************* #" << endl;
00077   cout << "# l:     Auto Level                        #" << endl;
00078   cout << "# o:     Contrast                          #" << endl;
00079   cout << "# d:     Difference                        #" << endl;
00080   cout << "# e:     Edge                              #" << endl;
00081   cout << "# g:     Grave (Edge Sharpen)              #" << endl;
00082   cout << "# n:     Noise (Edge)                      #" << endl;
00083   cout << "# n:     Unsharp                           #" << endl;
00084   cout << "# x:     Mr. Bond                          #" << endl;
00085   cout << "# a:     Pixel8                            #" << endl;
00086   cout << "# z:     Posterize                         #" << endl;
00087   cout << "#                                          #" << endl;
00088   cout << "# *** Animated Filters ******************* #" << endl;
00089   cout << "# r:     Refraction                        #" << endl;
00090   cout << "# w:     Distort                           #" << endl;
00091   cout << "# p:     PR                                #" << endl;
00092   cout << "#                                          #" << endl;
00093   cout << "############################################" << endl;
00094   
00095 }
00096 
00097 int main()
00098 {
00099   PrintFunctions();
00100   Container::Init();
00101   Container::SetImage(GrayImage::CreateFromTiff("in0.tif"));
00102   Container::StartMainLoop();                      
00103   Container::Dispose();
00104   return 0;
00105 }
00106 
00107 void Container::KeyboardCallback(unsigned char key, int x, int y)
00108 {
00109   switch (key)
00110   {
00111     case 'h':
00112       PrintFunctions();
00113       break;
00114     case 'q':
00115       exit(0); //can't believe there's no cleaner way than this..
00116       break;
00117     
00118     // ## IMAGES ##
00119     case 's':
00120       Container::currentimage->WriteToTiff("out.tif");
00121       break;
00122     case '1':
00123       Container::SetImage(GrayImage::CreateFromTiff("in0.tif"));
00124       break;
00125     case '2':
00126       Container::SetImage(GrayImage::CreateFromTiff("in1.tif"));
00127       break;
00128     case '3':
00129       Container::SetImage(GrayImage::CreateFromTiff("in2.tif"));
00130       break;
00131     case '4':
00132       Container::SetImage(GrayImage::CreateFromTiff("in3.tif"));
00133       break;
00134     case '5':
00135       Container::SetImage(GrayImage::CreateFromTiff("in4.tif"));
00136       break;
00137     case '6':
00138       Container::SetImage(GrayImage::CreateFromTiff("in7.tif"));
00139       break;
00140     case '7':
00141       Container::SetImage(GrayImage::CreateFromTiff("in6.tif"));
00142       break;
00143     case '8':
00144       Container::SetImage(RgbImage::CreateFromTiff("in0.tif"));
00145       break;
00146     case '9':
00147       Container::SetImage(RgbImage::CreateFromTiff("in1.tif"));
00148       break;
00149     case '0':
00150       Container::SetImage(RgbImage::CreateFromTiff("in5.tif"));
00151       break;
00152     
00153     // ## FILTERS ##
00154     case 'b': //Block Fill Effect
00155       Container::SetFilter(new BlockFillFilter());
00156       break;
00157     case 'f': //Flood Fill Effect
00158       Container::SetFilter(new FloodFillFilter());
00159       break;
00160     case 'i': //Invert Effect
00161       Container::SetFilter(new InvertFilter());
00162       break;
00163     case 'c': //Copy Block Effect
00164       Container::SetFilter(new CopyBlockFilter());
00165       break;
00166     case 'd': //Diff Effect
00167       Container::SetFilter(new DiffFilter());
00168       break;
00169     case 'e': //Edge Effect
00170       Container::SetFilter(new EdgeFilter());
00171       break;
00172     case 'l': //Level Effect
00173       Container::SetFilter(new LevelFilter());
00174       break;
00175     case 'o': //Contrast Effect
00176       Container::SetFilter(new ContrastFilter());
00177       break;
00178     case 'g': //Grave Effect
00179       Container::SetFilter(new GraveFilter());
00180       break;
00181     case 'n': //Noise Effect
00182       Container::SetFilter(new NoiseFilter());
00183       break;
00184     case 'u': //Unsharp Effect
00185       Container::SetFilter(new UnsharpFilter());
00186       break;
00187     case 'x': //Stamp Effect
00188       Container::SetFilter(new StampFilter());
00189       break;
00190     case 'a': //Pixel8 Effect
00191       Container::SetFilter(new Pixel8Filter());
00192       break;
00193     case 'r': //Refraction Effect (animated)
00194       Container::SetFilter(new TestFilter());
00195       break;
00196     case 'w': //Distort Effect (animated)
00197       Container::SetFilter(new SwirlFilter());
00198       break;
00199     case 'p': //PR Effect (animated)
00200       Container::SetFilter(new PrFilter());
00201       break;
00202     case 'z': //Posterize Effect
00203       Container::SetFilter(new PosterizeFilter());
00204       break;
00205     default:
00206       Container::DeleteFilter();
00207       Container::Redisplay();
00208       break;
00209   }
00210 }
00211 

Erzeugt am Fri Jan 31 15:27:35 2003 für OOP Miniprojekt von doxygen1.3-rc2