private void addCell(Loop loop, int pos, int loopNo, int celNo) { byte width = fileData[pos]; byte height = fileData[pos + 1]; byte mirror = getLeftSide(fileData[pos + 2]); byte transparentColor = getRightSide(fileData[pos + 2]); bool isMirrored = mirror >> 3 == 1; if (isMirrored) { isMirrored = (mirror - 8) != loopNo; } Cel cel = new Cel(width, height, transparentColor, isMirrored); int i = 3; while (!cel.IsFinished()) { byte c = fileData[pos + i++]; if (c == 0) { cel.NextLine(); } else { byte color = getLeftSide(c); byte runLength = getRightSide(c); cel.AddChunk(color, runLength); } } loop.AddCell(cel, celNo); }
private void addCell(Loop loop, int pos, int loopNo, int celNo) { byte width = fileData[pos]; byte height = fileData[pos + 1]; byte mirror = getLeftSide(fileData[pos + 2]); byte transparentColor = getRightSide(fileData[pos + 2]); bool isMirrored = mirror >> 3 == 1; if (isMirrored) isMirrored = (mirror - 8) != loopNo; Cel cel = new Cel(width, height, transparentColor, isMirrored); int i = 3; while (!cel.IsFinished()) { byte c = fileData[pos + i++]; if (c == 0) { cel.NextLine(); } else { byte color = getLeftSide(c); byte runLength = getRightSide(c); cel.AddChunk(color, runLength); } } loop.AddCell(cel, celNo); }
internal void AddCell(Cel cel, int celNo) { cels[celNo] = cel; width += cel.width; height = Math.Max(height, cel.height); }
private void renderCanvas() { XmlElement viewNode = doc.CreateElement("view"); viewNode.SetAttribute("id", "" + id); doc.AppendChild(viewNode); if (Description != "") { XmlElement descEl = doc.CreateElement("description"); viewNode.AppendChild(descEl); descEl.AppendChild(doc.CreateTextNode(Description)); } canvas = new Canvas(viewWidth * zoomX, viewHeight * zoomY); for (int i = 0; i < colorPalette.Length; i++) { canvas.SetColor(colorPalette[i]); } int celY = 0; Loop loop; for (int loopNr = 0; loopNr < loopCount; loopNr++) { int celX = 0; loop = loops[loopNr]; int celCount = loop.cels.Length; XmlElement loopNode = doc.CreateElement("loop"); viewNode.AppendChild(loopNode); for (int celNr = 0; celNr < celCount; celNr++) { Cel cel = loop.cels[celNr]; XmlElement celNode = doc.CreateElement("cel"); loopNode.AppendChild(celNode); celNode.SetAttribute("width", "" + cel.width); celNode.SetAttribute("height", "" + cel.height); for (int y = 0; y < cel.height; y++) { for (int x = 0; x < cel.width; x++) { int colorIndex = cel.data[x, y]; //canvas.SetPixel(celX + x, celY + y, colorIndex); int vX = celX + x; int vY = celY + y; // draw pixels in zoomed fashion for (int zY = vY * zoomY; zY < (vY + 1) * zoomY; zY++) { for (int zX = vX * zoomX; zX < (vX + 1) * zoomX; zX++) { canvas.SetPixel(zX, zY, colorIndex); } } } } celX += cel.width; } celY += loop.height; } canvas.SetTransparentColor(16); }
internal Loop(int cellCount) { cels = new Cel[cellCount]; }