Ejemplo n.º 1
0
 QPixmap createPixmap(const TileSet* pTileSet, CACHE::Tiles& tileCache)
 {
     QPixmap pixmap;
     if (pTileSet)
     {
         pixmap = QPixmap(pTileSet->getSize().getWidth() * MAP::TILE_SIZE, pTileSet->getSize().getHeight() * MAP::TILE_SIZE);
         pixmap.fill();
         QPainter painter(&pixmap);
         GEOMETRY::Point<uint32> pos;
         for (pos.getX() = 0; pos.getX() < pTileSet->getSize().getWidth(); ++pos.getX())
         {
             for (pos.getY() = 0; pos.getY() < pTileSet->getSize().getHeight(); ++pos.getY())
             {
                 auto info = tileCache.get(pTileSet->getTileID(pos));
                 if (info.isValid())
                     painter.drawPixmap(pos.getX()*MAP::TILE_SIZE, pos.getY()*MAP::TILE_SIZE, *info.getPixmap(), info.getPosition().getX(), info.getPosition().getY(),
                     MAP::TILE_SIZE, MAP::TILE_SIZE);
             }
         }
     }
     return pixmap;
 }
Ejemplo n.º 2
0
	/**
	 * 画像のブロック転送
	 * @param dest 転送先のデバイスコンテキストオブジェクト
	 * @param sourcePosition 転送元の矩形範囲
	 * @param destPosition 転送先の矩形範囲
	 */
	bool blockTransfer(const DeviceContext& dest,
					   const geometry::Rectangle<int>& sourcePosition,
					   const geometry::Point<int>& destPosition) const throw()
	{
		return ::BitBlt(this->deviceContext,
						destPosition.getX(),
						destPosition.getY(),
						sourcePosition.getWidth(),
						sourcePosition.getHeight(),
						dest.getDeviceContext(),
						sourcePosition.getLeft(),
						sourcePosition.getTop(),
						SRCCOPY) == TRUE;
	}
Ejemplo n.º 3
0
            void Single::_do(const MapTileInfo& info, MapTileInfoVec& tiles, PointVec<uint32>& borderTiles)
            {
                // first set complete brush size -> bitset is checked
                sl::Bitset2D bitset;
                for (GEOMETRY::Point<uint32> pos; pos.getX() < getBrushSize().getWidth(); ++pos.getX())
                {
                    for (pos.getY() = 0; pos.getY() < getBrushSize().getHeight(); ++pos.getY())
                    {
                        try
                        {
                            auto mapTileInfo = m_Layer.getMapTile(pos + getStartPosition());
                            tiles.push_back(mapTileInfo);
                            if (pos.getX() == 0 || pos.getX() + 1 == getBrushSize().getWidth())
                            {
                                if (pos.getY() == 0 || pos.getY() + 1 == getBrushSize().getHeight())
                                    borderTiles.push_back(mapTileInfo.getPosition());
                            }

                            // resize bitset if needed
                            bitset.resize(std::max(bitset.getWidth(), pos.getX() + mapTileInfo.getPosition().getX() + 1),
                                std::max(bitset.getHeight(), pos.getY() + mapTileInfo.getPosition().getY() + 1));

                            bitset.set(pos + mapTileInfo.getPosition());
                        }
                        catch (const EXCEPTION::TileOutOfRangeException&) {}
                    }
                }

                // after that, we can really check borders
                for (GEOMETRY::Point<uint32> pos; pos.getX() < getBrushSize().getWidth(); ++pos.getX())
                {
                    for (pos.getY() = 0; pos.getY() < getBrushSize().getHeight(); ++pos.getY())
                        _storeBorder(getStartPosition() + pos, borderTiles, bitset);
                }
                
            }
Ejemplo n.º 4
0
            void Single::_storeBorder(const GEOMETRY::Point<uint32>& pos, PointVec<uint32>& borderTiles, sl::Bitset2D& bitset)
            {
                for (uint32 i = 0; i < 8; ++i)
                {
                    try
                    {
                        auto mapTileInfo = m_Layer.getBorderTileInfo(pos, static_cast<BorderTile>(i));
                        // resize bitset if needed
                        bitset.resize(std::max(bitset.getWidth(), pos.getX() + mapTileInfo.getPosition().getX() + 1),
                            std::max(bitset.getHeight(), pos.getY() + mapTileInfo.getPosition().getY() + 1));
                        if (bitset.get(mapTileInfo.getPosition()))
                            continue;
                        bitset.set(mapTileInfo.getPosition());

                        if (mapTileInfo.isValid() && mapTileInfo.isAutoTile())
                            borderTiles.push_back(mapTileInfo.getPosition());
                    }
                    catch (const EXCEPTION::TileOutOfRangeException&) {}
                }
            }