public static void MakePalette(string[] astr) { // -makepal 16 templates.tc palsize fixpalsize backgroundpalsize fixed.pal out.pal // tile size Size sizTile = new Size(0, 0); sizTile.Width = int.Parse(astr[1]); sizTile.Height = sizTile.Width; // Load template collection TemplateDoc tmpd = (TemplateDoc)DocManager.OpenDocument(astr[2]); // palette size int cPalEntries = int.Parse(astr[3]); // entries fixed int cPalEntriesFixed = int.Parse(astr[4]); // entries for background int cPalEntriesBackground = int.Parse(astr[5]); // fixed palette Palette palFixed = new Palette(astr[6]); // output palette string strFilePalOut = astr[7]; // If this template collection already has a palette it has already been quantized; we don't // want that. if (tmpd.GetPalette() != null) { new Exception("Template collection has already been quantized!"); } // Scale templates if needed if (sizTile.Width != tmpd.TileSize.Width || sizTile.Height != tmpd.TileSize.Height) { TemplateTools.ScaleTemplates(tmpd, sizTile); } // Quantize TemplateTools.QuantizeTemplates(tmpd, palFixed, cPalEntries, cPalEntriesFixed, cPalEntriesBackground); // Save the new palette out Palette palNew = tmpd.GetPalette(); palNew.SaveJasc(strFilePalOut); }
private void menuItemScaleDown_Click(object sender, System.EventArgs e) { // If no template doc active, bail if (m_tmpdActive == null) { return; } // Make sure 24 x 24 (could actually allow any sort of conversion...) if (m_tmpdActive.TileSize.Width != 24 && m_tmpdActive.TileSize.Height != 24) { MessageBox.Show(DocManager.GetFrameParent(), "The current template collection must be 24 x 24 tile size"); return; } // Get busy TemplateDoc tmpdDst = TemplateTools.CloneTemplateDoc(m_tmpdActive); TemplateTools.ScaleTemplates(tmpdDst, new Size(16, 16)); TemplateTools.QuantizeTemplates(tmpdDst, null, 0, 0, 0); DocManager.SetActiveDocument(typeof(TemplateDoc), tmpdDst); }
private void menuItemQuantizeOnly_Click(object sender, System.EventArgs e) { if (m_tmpdActive == null) { return; } TemplateDoc tmpdDst = TemplateTools.CloneTemplateDoc(m_tmpdActive); TemplateTools.QuantizeTemplates(tmpdDst, null, 0, 0, 0); DocManager.SetActiveDocument(typeof(TemplateDoc), tmpdDst); }