private bool SetBitmap(Bitmap bm) { if ((bm.Width % Doc.TileSize.Width) != 0 && (bm.Height % Doc.TileSize.Height) != 0) { MessageBox.Show("Tile dimensions not a multiple of tile size"); return(false); } bm.MakeTransparent(Color.FromArgb(255, 0, 255)); Bitmap = bm; UpdateMaps(); m_doct.OnTemplateChanged(Doc, "Bitmap", m_strName, null); return(true); }
public void SetPalette(Palette pal, bool fColorMatch) { m_pal = pal; SetModified(true); if (!fColorMatch) { return; } ArrayList alsColors = new ArrayList(); foreach (Template tmpl in m_alsTemplates) { Bitmap bm = tmpl.Bitmap; bool[,] afOccupancy = tmpl.OccupancyMap; int ctx = afOccupancy.GetLength(1); int cty = afOccupancy.GetLength(0); for (int ty = 0; ty < cty; ty++) { for (int tx = 0; tx < ctx; tx++) { if (!afOccupancy[ty, tx]) { continue; } int xOrigin = tx * m_sizTile.Width; int yOrigin = ty * m_sizTile.Height; for (int y = yOrigin; y < yOrigin + m_sizTile.Height; y++) { for (int x = xOrigin; x < xOrigin + m_sizTile.Width; x++) { Color clrOld = bm.GetPixel(x, y); Color clrNew = pal[pal.FindClosestEntry(clrOld)]; bm.SetPixel(x, y, clrNew); } } } } TemplateDocTemplate doct = (TemplateDocTemplate)m_doct; doct.OnTemplateChanged(this, "Bitmap", tmpl.Name, null); } }