Example #1
0
		/// <summary>
		/// Gets a subimage from the image.
		/// </summary>
		/// <returns>The sub image.</returns>
		/// <param name="x">The x coordinate.</param>
		/// <param name="y">The y coordinate.</param>
		/// <param name="w">The width.</param>
		/// <param name="h">The height.</param>
		public Image8i GetSubimage(uint x, uint y, uint w, uint h)
		{
			if (x >= Width || y >= Height) throw new ArgumentOutOfRangeException("x or y", "Out of image.");

			Image8i ret = new Image8i(w, h, ChannelFormat);
			ret.Draw(-(int)x, -(int)y, this);
			return ret;
		}
Example #2
0
		private Image8i Render(int width, int height, string onlyLayer)
		{
			Image8i ret = new Image8i((uint)width, (uint)height, ChannelFormat.RGBA);
			ret = ret.ToAlphaInvertedImage();

			foreach (LayerData i in Layers)
			{
				if (onlyLayer == "")
				{
					if (i.name == "Collision") continue;
				}
				else
				{
					if (i.name != onlyLayer) continue;
				}

				for (int y = 0; y < i.height; y++)
				{
					for (int x = 0; x < i.width; x++)
					{
						int number = i.data[x, y];
						if (number <= 0) continue; 
						Image8i Tile = GetTile(number);

						int CorFactorX = 0;
						int CorFactorY = (int)(Tile.Height - TileHeight);

						ret.Draw(x * TileWidth - CorFactorX, y * TileHeight - CorFactorY, Tile, true);
					}
				}
			
			}

			return ret;
		}