Image Export Example for WPF

Nevron NOV Barcode for WPF ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All WPF Barcode examples are also available as a stand-alone Visual Studio solution in C# and VB.NET, which you can download from the links below.

Image Export Example for WPF Description

This example demonstrates how export barcodes to raster images. Enter some text in the text box on the right and click the Generate Image button.


Barcode Image Export Example

C# Image Export Example Code for Nevron Barcode for WPF
Language: C#

using Nevron.Nov;
using Nevron.Nov.Barcode;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NBarcodeImageExportExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

		#region Example

		private NWidget CreateExampleContent()
		{
			return null;
		}
		private NWidget CreateExampleControls()
		{
			return null;
		}

		#endregion

		#region Implementation
		#endregion

		#region Event Handlers

		private void OnBarcodeTextBoxTextChanged(NValueChangeEventArgs arg)
		{
			string text = (string)arg.NewValue;
			m_GenerateImageButton.Enabled = text != null && text.Length > 0;
		}
		private void OnGenerateImageButtonClick(NEventArgs arg)
		{
			NMatrixBarcodePainter painter = new NMatrixBarcodePainter();
			painter.Symbology = ENMatrixBarcodeSymbology.QrCode;
			painter.Text = m_BarcodeTextBox.Text;
			NRaster qrRaster = painter.CreateRaster(100, 100, NRaster.DefaultResolution);
			NImage qrImage = new NImage(qrRaster);

			m_ImageBox.Image = qrImage;
		}

		#endregion

		#region Fields

		private NImageBox m_ImageBox;
		private NTextBox m_BarcodeTextBox;
		private NButton m_GenerateImageButton;

		#endregion

		#region Static Methods
		#endregion

		#region Constants
		#endregion

		#region Nested Types
		#endregion
	}
}

Download a fully functional C# (.cs) Image Export Example for WPF Solution

VB.NET Image Export Example Code for Nevron Barcode for WPF
Language: VB.NET

Imports Nevron.Nov
Imports Nevron.Nov.Barcode
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Wpf
Imports System

Class MainWindow

#Region "Constructors"

	Public Sub New()
		' This call is required by the designer.
		InitializeComponent()

		' Add any initialization after the InitializeComponent() call.

		' Set form title
		Title = "NOV WPF - NBarcodeImageExportExample"

		' Create the NOV example and its controls
		Dim exampleContent As NWidget = CreateExampleContent()
		Dim exampleControls As NWidget = CreateExampleControls()
		If Not exampleControls Is Nothing Then
			exampleControls.PreferredWidth = 300
		End If

		' Place the example and its controls in a pair box
		Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
		pairBox.FillMode = ENStackFillMode.First
		pairBox.FitMode = ENStackFitMode.First
		pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)

		' Host the example in the form
		Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
		Content = host
	End Sub


#End Region

#Region "Example"

	Private Function CreateExampleControls() As NWidget
		Return Nothing
	End Function

	Private Function CreateExampleContent() As NWidget
		Return Nothing
	End Function

#End Region

#Region "Implementation"
#End Region

#Region "Event Handlers"

        Private Sub OnBarcodeTextBoxTextChanged(arg As NValueChangeEventArgs)
            Dim text = CStr(arg.NewValue)
            m_GenerateImageButton.Enabled = Not Equals(text, Nothing) AndAlso text.Length > 0
        End Sub
        Private Sub OnGenerateImageButtonClick(arg As NEventArgs)
            Dim painter As NMatrixBarcodePainter = New NMatrixBarcodePainter()
            painter.Symbology = ENMatrixBarcodeSymbology.QrCode
            painter.Text = m_BarcodeTextBox.Text
            Dim qrRaster = painter.CreateRaster(100, 100, NRaster.DefaultResolution)
            Dim qrImage As NImage = New NImage(qrRaster)

            m_ImageBox.Image = qrImage
        End Sub

#End Region

#Region "Fields"

        Private m_ImageBox As NImageBox
        Private m_BarcodeTextBox As NTextBox
        Private m_GenerateImageButton As NButton

#End Region

#Region "Static Methods"
#End Region

#Region "Constants"
#End Region

#Region "Nested Types"
#End Region

End Class

Download a fully functional VB.NET (.vb) Image Export Example for WPF Solution