Beispiel #1
0
        private void bitmapButton_Click(object sender, EventArgs e)
        {
            if (bitmapDialog == null)
            {
                bitmapDialog            = new OpenFileDialog();
                bitmapDialog.DefaultExt = "*.jpg;*.png";
            }
            if (bitmapDialog.ShowDialog() == DialogResult.OK)
            {
                string filename = bitmapDialog.FileName;
                currentBitmap = BitmapUtilities.LoadBitmapFromFile(renderTarget, wicFactory, filename);

                currentShapeType = Shape.Bitmap;
                SwitchDrawMode(sender);
            }
        }
        private void addBitmapBrushBotton_Click(object sender, EventArgs e)
        {
            ExtendMode ex = extendedModeXComboBox.SelectedIndex > 0 ? (ExtendMode)extendedModeXComboBox.SelectedIndex : ExtendMode.Wrap;
            ExtendMode ey = extendedModeYComboBox.SelectedIndex > 0 ? (ExtendMode)extendedModeYComboBox.SelectedIndex : ExtendMode.Wrap;

            D2DBitmap   brushBitmap = BitmapUtilities.LoadBitmapFromFile(renderTarget, parent.wicFactory, imageFilename);
            BitmapBrush brush       = renderTarget.CreateBitmapBrush(
                brushBitmap,
                new BitmapBrushProperties(
                    ex, ey,
                    BitmapInterpolationMode.NearestNeighbor),
                new BrushProperties(
                    opacity,
                    Matrix3x2F.Identity));

            parent.brushes.Add(brush);
            parent.currentBrushIndex = parent.brushes.Count - 1;
            FillBrushesListBox();
        }