Exemplo n.º 1
0
        private void updateBitmapPreview()
        {
            if (checkGroupBoxFontImage.Checked && m_currentLoadedBitmap != null)
            {
                int w            = (int)numericUpDownInputImageTileSizeX.Value;
                int h            = (int)numericUpDownInputImageTileSizeY.Value;
                int tilesPerLine = (int)numericUpDownInputImageTilesPerLine.Value;

                Point p = new Point(hScrollBarInputImageCharacterPos.Value % tilesPerLine * w, hScrollBarInputImageCharacterPos.Value / tilesPerLine * h);

                Rectangle r = new Rectangle(p, new Size(w, h));
                Color     c;
                if (colorList.ContainsValue(true))
                {
                    c = MyExtensions.GetEnabledKeys(colorList)[0];
                }
                else
                {
                    c = Color.Transparent;
                }
                Bitmap character = MyExtensions.Clone(m_currentLoadedBitmap, r, PixelFormat.Format32bppArgb, c);;

                Size newSize = r.Size;
                int  faktor  = 1;

                while (newSize.Height <= 32)
                {
                    newSize.Height *= 2;
                    newSize.Width  *= 2;
                    faktor         *= 2;
                }

                //convert to black white image
                character = MyExtensions.ToBitmap(MyExtensions.ToArgbArray(character).Select(argb =>
                {
                    return(colorList[Color.FromArgb(argb)] ? Color.Black.ToArgb() : Color.White.ToArgb());
                }).ToArray(), r.Size);

                pictureBoxInputImageFontCharacterPreview.Image = MyExtensions.ResizeImage(character, faktor);
                pictureBoxInputImageFontCharacterPreview.Size  = newSize;
            }
        }