1 /*      _______   __   __   __   ______   __   __   _______   __   __
2  *     / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___  /\ /  |\/ /\
3  *    / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4  *   / / /__   / / // / // / // / /    / ___  / // ___  / // /| ' / /
5  *  / /_// /\ / /_// / // / // /_/_   / / // / // /\_/ / // / |  / /
6  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8  *
9  * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess�n and Per Larsson
10  *
11  *                                                         Js_./
12  * Per Larsson a.k.a finalman                          _RqZ{a<^_aa
13  * Olof Naess�n a.k.a jansem/yakslem                _asww7!uY`>  )\a//
14  *                                                 _Qhm`] _f "'c  1!5m
15  * Visit: http://guichan.darkbits.org             )Qk<P ` _: :+' .'  "{[
16  *                                               .)j(] .d_/ '-(  P .   S
17  * License: (BSD)                                <Td/Z <fP"5(\"??"\a.  .L
18  * Redistribution and use in source and          _dV>ws?a-?'      ._/L  #'
19  * binary forms, with or without                 )4d[#7r, .   '     )d`)[
20  * modification, are permitted provided         _Q-5'5W..j/?'   -?!\)cam'
21  * that the following conditions are met:       j<<WP+k/);.        _W=j f
22  * 1. Redistributions of source code must       .$%w\/]Q  . ."'  .  mj$
23  *    retain the above copyright notice,        ]E.pYY(Q]>.   a     J@\
24  *    this list of conditions and the           j(]1u<sE"L,. .   ./^ ]{a
25  *    following disclaimer.                     4'_uomm\.  )L);-4     (3=
26  * 2. Redistributions in binary form must        )_]X{Z('a_"a7'<a"a,  ]"[
27  *    reproduce the above copyright notice,       #}<]m7`Za??4,P-"'7. ).m
28  *    this list of conditions and the            ]d2e)Q(<Q(  ?94   b-  LQ/
29  *    following disclaimer in the                <B!</]C)d_, '(<' .f. =C+m
30  *    documentation and/or other materials      .Z!=J ]e []('-4f _ ) -.)m]'
31  *    provided with the distribution.          .w[5]' _[ /.)_-"+?   _/ <W"
32  * 3. Neither the name of Guichan nor the      :$we` _! + _/ .        j?
33  *    names of its contributors may be used     =3)= _f  (_yQmWW$#(    "
34  *    to endorse or promote products derived     -   W,  sQQQQmZQ#Wwa]..
35  *    from this software without specific        (js, \[QQW$QWW#?!V"".
36  *    prior written permission.                    ]y:.<\..          .
37  *                                                 -]n w/ '         [.
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT       )/ )/           !
39  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY         <  (; sac    ,    '
40  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,               ]^ .-  %
41  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF            c <   r
42  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR            aga<  <La
43  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE          5%  )P'-3L
44  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR        _bQf` y`..)a
45  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,          ,J?4P'.P"_(\?d'.,
46  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES               _Pa,)!f/<[]/  ?"
47  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT      _2-..:. .r+_,.. .
48  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     ?a.<%"'  " -'.a_ _,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                     ^
50  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
53  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
54  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55  */
56 
57 /*
58  * For comments regarding functions please see the header file.
59  */
60 
61 #include "guichan/image.hpp"
62 
63 #include "guichan/exception.hpp"
64 #include "guichan/imageloader.hpp"
65 
66 namespace gcn
67 {
68 
69     ImageLoader* Image::mImageLoader = NULL;
70 
Image()71     Image::Image()
72     {
73     }
74 
~Image()75     Image::~Image()
76     {
77     }
78 
setImageLoader(ImageLoader * imageLoader)79     void Image::setImageLoader(ImageLoader* imageLoader)
80     {
81         mImageLoader = imageLoader;
82     }
83 
getImageLoader()84     ImageLoader* Image::getImageLoader()
85     {
86         return mImageLoader;
87     }
88 
load(const std::string & filename,bool convertToDisplayFormat)89     Image* Image::load(const std::string& filename, bool convertToDisplayFormat)
90     {
91         if (mImageLoader == NULL)
92         {
93             throw GCN_EXCEPTION("Trying to load an image but no image loader is set.");
94         }
95 
96         return mImageLoader->load(filename, convertToDisplayFormat);
97     }
98 }
99