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

Last change on this file since 2183 was 2183, checked in by sam, 7 years ago

build: fix the WTFPL site URL in all code comments.

  • 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://www.wtfpl.net/ for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16#include "image-private.h"
17
18using namespace std;
19
20namespace lol
21{
22
23static bool RegisterAllLoaders()
24{
25    /* We cannot make this an ImageLoader member function, because the
26     * REGISTER_IMAGE_LOADER macro forward-declares free functions from
27     * the "lol" namespace. An apparent bug in Visual Studio's compiler
28     * makes it think these functions are actually in the top-level
29     * namespace when the forward declaration is in a class member function.
30     * To avoid the problem, we make the forward declaration in a free
31     * function. */
32#if defined __ANDROID__
33    REGISTER_IMAGE_LOADER(AndroidImageData)
34#endif
35    REGISTER_IMAGE_LOADER(DummyImageData)
36#if defined USE_GDIPLUS
37    REGISTER_IMAGE_LOADER(GdiPlusImageData)
38#endif
39#if defined __APPLE__ && defined __MACH__ && defined __arm__
40    REGISTER_IMAGE_LOADER(IosImageData)
41#endif
42#if defined __CELLOS_LV2__
43    REGISTER_IMAGE_LOADER(Ps3ImageData)
44#endif
45#if defined USE_SDL_IMAGE
46    REGISTER_IMAGE_LOADER(SdlImageData)
47#endif
48
49    return true;
50}
51
52/*
53 * Public Image class
54 */
55
56Image::Image(char const *path)
57{
58    static bool unused = RegisterAllLoaders();
59
60    data = ImageLoader::Load(path);
61}
62
63ivec2 Image::GetSize() const
64{
65    return data->size;
66}
67
68Image::format_t Image::GetFormat() const
69{
70    return data->format;
71}
72
73void * Image::GetData() const
74{
75    return data->GetData();
76}
77
78Image::~Image()
79{
80    data->Close();
81    delete data;
82}
83
84} /* namespace lol */
85
Note: See TracBrowser for help on using the repository browser.