Exemplo n.º 1
0
        private void ApplyFilter(bool preview)
        {
            if (previewBitmap == null || cmbFilterSize.SelectedIndex == -1)
            {
                return;
            }

            Bitmap selectedSource = null;
            Bitmap bitmapResult   = null;

            if (preview == true)
            {
                selectedSource = previewBitmap;
            }
            else
            {
                selectedSource = originalBitmap;
            }

            if (selectedSource != null)
            {
                if (cmbFilterSize.SelectedItem.ToString() == "None")
                {
                    bitmapResult = selectedSource;
                }
                else
                {
                    int filterSize = 0;

                    ExtBitmap.ColorShiftType  shiftType = (ExtBitmap.ColorShiftType)cmbColorShiftType.SelectedItem;
                    ExtBitmap.EdgeTracingType edgeType  = (ExtBitmap.EdgeTracingType)cmbEdgeTracing.SelectedItem;

                    if (Int32.TryParse(cmbFilterSize.SelectedItem.ToString(), out filterSize))
                    {
                        bitmapResult = selectedSource.AbstractColorsFilter(filterSize, (byte)numEdgeThreshold.Value, chkB.Checked, chkG.Checked, chkR.Checked, edgeType, shiftType);
                    }
                }
            }

            if (bitmapResult != null)
            {
                if (preview == true)
                {
                    picPreview.Image = bitmapResult;
                }
                else
                {
                    resultBitmap = bitmapResult;
                }
            }
        }