-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmap.cpp
More file actions
45 lines (38 loc) · 1.04 KB
/
map.cpp
File metadata and controls
45 lines (38 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (C) 2016 Dmitry Morozov <dmorozov@outlook.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "map.h"
#include "skin.h"
#include "bitmap.h"
#include <QDebug>
Map::Map(QObject *parent) : QObject(parent) {}
void Map::load(const QString &id)
{
Bitmap *b = Skin::instance()->bitmap(id.toLower());
if (b == Q_NULLPTR) {
qWarning("%s: could not find bitmap '%s'", Q_FUNC_INFO, qUtf8Printable(id));
return;
}
m_image = b->pixmap().toImage();
if (m_image.isNull()) {
qWarning("%s: image for '%s' is null", Q_FUNC_INFO, qUtf8Printable(id));
return;
}
}
bool Map::contains(int x, int y) const
{
return m_image.rect().contains(x, y);
}
int Map::value(int x, int y) const
{
return qGray(m_image.pixel(x, y));
}
const QImage& Map::image() const
{
return m_image;
}