1/*
2 Large image displaying library.
3
4 Copyright (C) 2004,2005 Maks Orlovich (maksim@kde.org)
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23*/
24#ifndef PLANE_H
25#define PLANE_H
26
27#include "tile.h"
28
29namespace khtmlImLoad
30{
31
32/**
33 All picture data, whether image or pixmap-related, logically
34 denotes a plane: logically, some collection of tiles, which has
35 some geometry. This class incorporates this abstraction, and
36 provides helper methods for dealing with the tiles
37*/
38class Plane
39{
40public:
41 unsigned int width; //width in pixels
42 unsigned int height; //height in pixels
43 unsigned int tilesWidth; //width in tiles
44 unsigned int tilesHeight; //height in tiles
45
46 Plane(unsigned int _width, unsigned int _height)
47 {
48 width = _width;
49 height = _height;
50 tilesWidth = (width + Tile::TileSize - 1) / Tile::TileSize;
51 tilesHeight = (height + Tile::TileSize - 1) / Tile::TileSize;
52 }
53
54 unsigned int tileWidth(unsigned int tileX)
55 {
56 if (tileX == (tilesWidth - 1)) {
57 return width - tileX * Tile::TileSize;
58 }
59 return Tile::TileSize;
60 }
61
62 unsigned int tileHeight(unsigned int tileY)
63 {
64 if (tileY == (tilesHeight - 1)) {
65 return height - tileY * Tile::TileSize;
66 }
67 return Tile::TileSize;
68 }
69
70};
71
72}
73
74#endif
75