private void btn_gerarBitmap_Click(object sender, RoutedEventArgs e) { if (this.app.ActiveDocument == null) { global::System.Windows.MessageBox.Show("Abra um novo documento para gerar"); return; } CreateBitmapLocal(); this.app.ActiveLayer.Name = "QrCode JPG"; this.app.ActiveDocument.Unit = this.app.ActiveDocument.Rulers.HUnits; Corel.Interop.VGCore.Shape q = this.app.ActiveLayer.FindShape("temp_qrcode.jpg"); int strSize = 221; if (Int32.TryParse(txt_size.Text, out strSize)) { q.SetSize(strSize, strSize); } else { System.Windows.MessageBox.Show("Formato de tamanho inválido", "Aviso para Você!"); } }
private void CreateVetorLocal2() { CreateBitmapLocal(); Shapes shapes = this.app.ActiveLayer.Shapes; foreach (Corel.Interop.VGCore.Shape shape in shapes) { if (shape.Name == "temp_qrcode.jpg") { double x, y, w, h; shape.GetPosition(out x, out y); shape.GetSize(out w, out h); TraceSettings traceSettings = shape.Bitmap.Trace(cdrTraceType.cdrTraceLineDrawing); traceSettings.DetailLevelPercent = 100; traceSettings.BackgroundRemovalMode = cdrTraceBackgroundMode.cdrTraceBackgroundAutomatic; traceSettings.CornerSmoothness = 0; traceSettings.DeleteOriginalObject = true; traceSettings.RemoveBackground = true; traceSettings.RemoveEntireBackColor = true; traceSettings.RemoveOverlap = true; traceSettings.SetColorCount(2); traceSettings.SetColorMode(cdrColorType.cdrColorGray, cdrPaletteID.cdrCustom); traceSettings.Smoothing = 0; traceSettings.TraceType = cdrTraceType.cdrTraceClipart; traceSettings.Finish(); Corel.Interop.VGCore.ShapeRange sr = new Corel.Interop.VGCore.ShapeRange(); foreach (Corel.Interop.VGCore.Shape s in this.app.ActiveLayer.Shapes) { sr.Add(s); } sr.CreateSelection(); Corel.Interop.VGCore.Shape qrShape = this.app.ActiveSelection; Corel.Interop.VGCore.Shape cod = this.app.ActiveSelection.Weld(qrShape); cod.Name = "Cod"; Corel.Interop.VGCore.Color cWhite = new Corel.Interop.VGCore.Color(); cWhite.CMYKAssign(0, 0, 0, 0); Corel.Interop.VGCore.Shape border = this.app.ActiveLayer.CreateRectangle2(x, y - h, w, h); border.Fill.ApplyUniformFill(cWhite); border.Outline.Width = 0; border.OrderToBack(); border.Name = "Borda"; int strSize = 221; cod.AddToSelection(); border.AddToSelection(); Corel.Interop.VGCore.Shape g = this.app.ActiveSelection.Group(); this.app.ActiveDocument.Unit = this.app.ActiveDocument.Rulers.HUnits; if (Int32.TryParse(txt_size.Text, out strSize)) { g.SetSize(strSize, strSize); } else { System.Windows.MessageBox.Show("Formato de tamanho inválido", "Aviso para Você!"); } } } this.app.ActiveLayer.Name = "QrCode Vetor"; }