source: trunk/src/image/image.cpp @ 1162

Last change on this file since 1162 was 1162, checked in by gary, 10 years ago

win32: various compilation fixes, mostly project updates, but also a
workaround for a Visual Studio compiler bug (Connect Id #730878).

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cmath>
16
17#include "core.h"
18#include "image-private.h"
19
20using namespace std;
21
22namespace lol
23{
24
25static bool RegisterAllLoaders()
26{
27    /* We cannot make this an ImageLoader member function, because the
28     * REGISTER_IMAGE_LOADER macro forward-declares free functions from
29     * the "lol" namespace. An apparent bug in Visual Studio's compiler
30     * makes it think these functions are actually in the top-level
31     * namespace when the forward declaration is in a class member function.
32     * To avoid the problem, we make the forward declaration in a free
33     * function. */
34#if defined __ANDROID__
35    REGISTER_IMAGE_LOADER(AndroidImageData)
36#endif
37    REGISTER_IMAGE_LOADER(DummyImageData)
38#if defined USE_GDIPLUS
39    REGISTER_IMAGE_LOADER(GdiPlusImageData)
40#endif
41#if defined __APPLE__ && defined __MACH__ && defined __arm__
42    REGISTER_IMAGE_LOADER(IosImageData)
43#endif
44#if defined __CELLOS_LV2__
45    REGISTER_IMAGE_LOADER(Ps3ImageData)
46#endif
47#if defined USE_SDL_IMAGE
48    REGISTER_IMAGE_LOADER(SdlImageData)
49#endif
50
51    return true;
52}
53
54/*
55 * Public Image class
56 */
57
58Image::Image(char const *path)
59{
60    static bool unused = RegisterAllLoaders();
61
62    data = ImageLoader::Load(path);
63}
64
65ivec2 Image::GetSize() const
66{
67    return data->size;
68}
69
70Image::format_t Image::GetFormat() const
71{
72    return data->format;
73}
74
75void * Image::GetData() const
76{
77    return data->GetData();
78}
79
80Image::~Image()
81{
82    data->Close();
83    delete data;
84}
85
86} /* namespace lol */
87
Note: See TracBrowser for help on using the repository browser.