コード例 #1
0
        void LoadDefaultImage()
        {
            Assembly asm = typeof(Crop).Assembly;

            using (Stream stream = asm.GetManifestResourceStream("BitmapSamples.Resources.GrapeCity.jpg"))
            {
                _bitmap.Load(stream, new FormatConverter(PixelFormat.Format32bppPBGRA));
            }
            image.Source     = _bitmap.ToWriteableBitmap();
            imageGrid.Width  = _bitmap.PixelWidth;
            imageGrid.Height = _bitmap.PixelHeight;
            InitSelection();
        }
コード例 #2
0
        void LoadDefaultImage()
        {
            Assembly asm = typeof(Crop).Assembly;

            using (Stream stream = asm.GetManifestResourceStream("BitmapSamples.Resources.HousePlan.jpg"))
            {
                _bitmap.Load(stream, new FormatConverter(PixelFormat.Format32bppPBGRA));
            }

            ClearSavedCopy();
            _savedCopy = _bitmap.Transform();

            UpdateImage();
        }
コード例 #3
0
        void LoadDefaultImage()
        {
            Assembly asm = typeof(Crop).Assembly;

            using (Stream stream = asm.GetManifestResourceStream("BitmapSamples.Resources.Sheep.jpg"))
            {
                _bitmap.Load(stream, new FormatConverter(C1.WPF.Bitmap.PixelFormat.Format32bppPBGRA));
            }

            ClearSavedCopy();
            _savedCopy = _bitmap.Transform();

            image.Source = _bitmap.ToWriteableBitmap();
        }
コード例 #4
0
        async Task LoadDefaultImage()
        {
            Assembly asm = typeof(Crop).GetTypeInfo().Assembly;

            using (Stream stream = asm.GetManifestResourceStream("BitmapSamples.Assets.GrapeCity.jpg"))
            {
                _bitmap.Load(stream, new FormatConverter(PixelFormat.Format32bppPBGRA));
            }
            await UpdateImageSource();
        }
コード例 #5
0
        void btnLoad_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "Image Files|*.ico;*.bmp;*.gif;*.png;*.jpg;*.jpeg;*.jxr;*.tif;*.tiff";
            ofd.Title  = "Select the Image";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    _bitmap.Load(ofd.FileName, new FormatConverter(PixelFormat.Format32bppPBGRA));
                    UpdateImage();
                }
                catch (Exception ex)
                {
                    LoadDefaultImage();
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #6
0
        private static C1Bitmap Base64ToImage(string base64String)
        {
            // Convert base 64 string to byte[]
            byte[] imageBytes = Convert.FromBase64String(base64String);
            var    bitmap     = new C1Bitmap();

            // Convert byte[] to Image
            using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
            {
                bitmap.Load(ms);
            }

            return(bitmap);
        }
コード例 #7
0
 // C1Bitmap holder.
 public Picture(Bitmap source)
 {
     Bitmap = new C1Bitmap();
     if (source != null)
     {
         using (MemoryStream stream = new MemoryStream())
         {
             source.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
             Bitmap.Load(stream);
         }
     }
     SizeMode = PictureBoxSizeMode.StretchImage;
     Image    = Bitmap.ToGdiBitmap();
     Width    = 120;
     Height   = 120;
 }
コード例 #8
0
        void InitResources()
        {
            // load the image into C1Bitmap
            _bitmap = new C1Bitmap();
            Assembly asm = typeof(MainWindow).Assembly;

            using (Stream stream = asm.GetManifestResourceStream("Direct2DEffects.Resources.GcLogo.png"))
            {
                _bitmap.Load(stream, new FormatConverter(C1.WPF.Bitmap.PixelFormat.Format32bppPBGRA));
            }

            // create Direct2D and DirectWrite factories
            _d2dFactory = D2D.Factory2.Create(D2D.FactoryType.SingleThreaded);
            _dwFactory  = DW.Factory.Create(DW.FactoryType.Shared);

            // create GPU resources
            CreateDeviceResources();
        }
コード例 #9
0
        public MainForm()
        {
            InitializeComponent();

            // load the image into C1Bitmap
            _bitmap = new C1Bitmap();
            Assembly asm = typeof(MainForm).Assembly;

            using (Stream stream = asm.GetManifestResourceStream("Direct2DEffects.Resources.GcLogo.png"))
            {
                _bitmap.Load(stream, new FormatConverter(PixelFormat.Format32bppPBGRA));
            }

            // create Direct2D and DirectWrite factories
            _d2dFactory = D2D.Factory2.Create(D2D.FactoryType.SingleThreaded);
            _dwFactory  = DW.Factory.Create(DW.FactoryType.Shared);

            // create GPU resources
            CreateDeviceResources();

            // fill the list of available effects
            var coll = effectsCombo.Items;

            coll.Add(new EffectItem(ImageEffect.Original, "Original Image"));
            coll.Add(new EffectItem(ImageEffect.GaussianBlur, "Gaussian Blur"));
            coll.Add(new EffectItem(ImageEffect.Sharpen, "Sharpen"));
            coll.Add(new EffectItem(ImageEffect.HorizontalSmear, "Horizontal Smear"));
            coll.Add(new EffectItem(ImageEffect.Shadow, "Shadow"));
            coll.Add(new EffectItem(ImageEffect.DisplacementMap, "Displacement Map"));
            coll.Add(new EffectItem(ImageEffect.Emboss, "Emboss"));
            coll.Add(new EffectItem(ImageEffect.EdgeDetect, "Edge Detect"));
            coll.Add(new EffectItem(ImageEffect.Sepia, "Sepia"));
            effectsCombo.SelectedIndex             = 0;
            effectsCombo.SelectionChangeCommitted += effectsCombo_SelectionChangeCommitted;

            // display the original image
            UpdateImageSource(ImageEffect.Original);
        }
コード例 #10
0
        public static C1Bitmap LoadImage(string resourceName)
        {
            C1Bitmap bitmap   = null;
            var      resource = "BitmapExplorer.Properties.Resources";
            Assembly assembly = Assembly.GetExecutingAssembly();
            var      manager  = new ResourceManager(resource, assembly);

            if (manager != null)
            {
                Bitmap image = manager.GetObject(resourceName, CultureInfo.InvariantCulture) as Bitmap;
                if (image != null)
                {
                    bitmap = new C1Bitmap();
                    using (MemoryStream stream = new MemoryStream())
                    {
                        image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                        bitmap.Load(stream);
                    }
                }
            }

            return(bitmap);
        }
コード例 #11
0
ファイル: MainPage.xaml.cs プロジェクト: yuuya45/codezine
        private async void ExcelButton_Click(object sender, RoutedEventArgs e)
        {
            // 現在、FlexGrid に表示されている順のデータ
            var currentData = this.flexgrid1.Rows.Select(r => r.DataItem).Cast <Book>();

            // Excel データの作成
            // https://docs.grapecity.com/help/c1/uwp/uwp_excel/#Step_2_of_4-_Adding_Content_to_a_C1XLBook.html

            // 新しい Excel ワークブックを作成
            var xlBook = new C1XLBook();

            // デフォルトで作成されたシートを取得
            XLSheet sheet = xlBook.Sheets[0];

            // シートの中身を書き込みます
            int rowIndex = 0;

            // ヘッダー行
            sheet[rowIndex, 0].Value = "書名";
            sheet[rowIndex, 1].Value = "ISBN";
            sheet[rowIndex, 2].Value = "バーコード";
            sheet.Columns[2].Width
                = C1XLBook.PixelsToTwips(this.HiddenBarCode.ActualWidth);
            sheet[rowIndex, 3].Value = "価格";
            // データ行
            foreach (var book in currentData)
            {
                rowIndex++;

                // バーコードの画像を作る
                this.HiddenBarCode.Text = book.IsbnWithoutCheckDigit;
                C1Bitmap bitmap = new C1Bitmap();
                using (var ms = new InMemoryRandomAccessStream().AsStream())
                {
                    await this.HiddenBarCode.SaveAsync(ms, ImageFormat.Png);

                    bitmap.Load(ms);
                }

                // 行の高さをバーコードの画像に合わせる
                sheet.Rows[rowIndex].Height
                    = C1XLBook.PixelsToTwips(this.HiddenBarCode.ActualHeight);

                // 1行分のデータとバーコード画像をセット
                sheet[rowIndex, 0].Value = book.Title;
                sheet[rowIndex, 1].Value = book.Isbn;
                sheet[rowIndex, 2].Value = bitmap;
                sheet[rowIndex, 3].Value = book.Price;
            }

            // Excel ファイルへの書き出し
            // https://docs.grapecity.com/help/c1/uwp/uwp_excel/#Step_3_of_4-_Saving_the_XLSX_File.html
            var picker = new FileSavePicker()
            {
                SuggestedStartLocation = PickerLocationId.DocumentsLibrary
            };

            picker.FileTypeChoices.Add("Open XML Excel ファイル", new string[] { ".xlsx", });
            picker.FileTypeChoices.Add("BIFF Excel ファイル", new string[] { ".xls", });
            picker.SuggestedFileName = "BarCodeControlSample";
            var file = await picker.PickSaveFileAsync();

            if (file != null)
            {
                var fileFormat = Path.GetExtension(file.Path).Equals(".xls") ? FileFormat.OpenXmlTemplate : FileFormat.OpenXml;
                await xlBook.SaveAsync(file, fileFormat);
            }
        }