Inheritance: ICloneable
Example #1
0
		public EditorPane(XCImage img)
		{
			this.SetStyle(ControlStyles.DoubleBuffer|ControlStyles.UserPaint|ControlStyles.AllPaintingInWmPaint,true);
			this.img = img;
			pal=null;
			lines=false;

			imgWidth = PckImage.Width*square;
			imgHeight = PckImage.Height*square;
		}
Example #2
0
		public static int EncodePck(System.IO.BinaryWriter output, XCImage tile)
		{
			int count = 0;
			bool flag = true;
			byte[] input = tile.Bytes;
			List<byte> bytes = new List<byte>();
			//Color trans = pal.Transparent;
			//pal.SetTransparent(false);

			int totalCount = 0;
			for (int i = 0; i < input.Length; i++)
			{
				byte idx = input[i];
				totalCount++;

				if (idx == TransIdx)
					count++;
				else
				{
					if (count != 0)
					{
						if (flag)
						{
							bytes.Add((byte)(count / tile.Image.Width)); //# of initial rows to skip
							count = (byte)(count % tile.Image.Width);//where we currently are in the transparent row
							flag = false;
							//Console.WriteLine("count, lines: {0}, cells {1}",count/PckImage.IMAGE_WIDTH,count%PckImage.IMAGE_WIDTH);
						}

						while (count >= 255)
						{
							bytes.Add(TransIdx);
							bytes.Add(255);
							count -= 255;
						}

						if (count != 0)
						{
							bytes.Add(TransIdx);
							bytes.Add((byte)count);
						}
						count = 0;
					}
					bytes.Add(idx);
				}
			}

			bool throughLoop = false;
			while (count >= 255)
			{
				bytes.Add(254);
				bytes.Add(255);
				count -= 255;
				throughLoop = true;
			}

			if ((byte)bytes[bytes.Count - 1] != 255 || throughLoop)
				bytes.Add(255);

			//if (bytes.Count % 2 == 1 || throughLoop)
			//    bytes.Add(255);

			output.Write(bytes.ToArray());

			return bytes.Count;
		}