2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "modulesystem.h"
26 #include "ifilesystem.h"
29 #include "generic/reference.h"
31 #include "stream/stringstream.h"
34 typedef Modules<_QERPlugImageTable> ImageModules;
35 ImageModules& Textures_getImageModules();
37 /// \brief Returns a new image for the first file matching \p name in one of the available texture formats, or 0 if no file is found.
38 Image* QERApp_LoadImage(void* environment, const char* name)
41 class LoadImageVisitor : public ImageModules::Visitor
46 LoadImageVisitor(const char* name, Image*& image)
47 : m_name(name), m_image(image)
50 void visit(const char* name, const _QERPlugImageTable& table) const
54 StringOutputStream fullname(256);
55 fullname << m_name << '.' << name;
56 ArchiveFile* file = GlobalFileSystem().openFile(fullname.c_str());
59 m_image = table.loadImage(*file);
66 Textures_getImageModules().foreachModule(LoadImageVisitor(name, image));