Exemplo n.º 1
0
 public BitmapInfo(OutputConfiguration outConfig, Bitmap bmp, Color borderColor)
 {
     OutConfig      = outConfig;
     Original       = bmp;
     OriginalBorder = Border.GetBorders(Original, borderColor);
     ColorList      = MyExtensions.GetColorList(Original).Aggregate(new Dictionary <Color, bool>(), (dic, c) => { dic.Add(c, c.ToArgb() == borderColor.ToArgb()); return(dic); });
 }
Exemplo n.º 2
0
        private void btnBitmapLoad_Click(object sender, EventArgs e)
        {
            // set filter
            dlgOpenFile.Filter = string.Format("Image Files ({0})|{0}", "*.jpg; *.jpeg; *.gif; *.bmp; *.png");

            // open the dialog
            if (dlgOpenFile.ShowDialog() != DialogResult.Cancel)
            {
                if (m_currentLoadedBitmap != null)
                {
                    m_currentLoadedBitmap.Dispose();
                }
                m_currentLoadedBitmap = MyExtensions.ChangePixelFormat(new Bitmap(dlgOpenFile.FileName), PixelFormat.Format32bppArgb);

                // set the path
                txtImagePath.Text = dlgOpenFile.FileName;

                // guess a name
                txtImageName.Text = Path.GetFileNameWithoutExtension(dlgOpenFile.FileName);

                //
                colorList = MyExtensions.GetColorList(m_currentLoadedBitmap).ToDictionary <Color, Color, bool>(x => x, x => false);
                colorList[colorList.ElementAt(0).Key] = true;

                if (colorList.Count > 16)
                {
                    MessageBox.Show("Convert the image into black/white in a proper image processing program, to get better results.");
                }

                dataGridViewBackgroundColor.RowCount = colorList.Count;
                dataGridViewBackgroundColor.Refresh();

                // Set picterbox background
                pbxBitmap.BackColor = GetBackColorForPicturbox();

                Size sz = DetectTileSize();

                updateBitmapAllowed = false;
                numericUpDownInputImageTilesPerLine.Value = 16;
                numericUpDownInputImageTileSizeX.Value    = sz.Width;
                numericUpDownInputImageTileSizeY.Value    = sz.Height;
                updateBitmapAllowed = true;

                UpdateInputImageFont(sender, e);
            }
        }