IronBarcode Logo

Lire un code-barres à partir d'une image C#

  • Extraction de codes-barres à partir d'images.
  • Prise en charge de plusieurs types de codes-barres.
  • Grande précision de lecture des codes-barres.
  • Intégration simple à l'application C#.
  • Lire les codes-barres dans les cours d'eau.
Confiance
par :
Logo de la NasaLogo Hertzlogo 3MLogo Tesla

Commencez GRATUITEMENT

No credit card or account creation required
Test Icon

Test dans un environnement réel

Test en production sans filigrane.
Fonctionne partout où vous en avez besoin.

Functional Icon

Produit entièrement fonctionnel

Obtenez 30 jours de produit entièrement fonctionnel.
Il est opérationnel en quelques minutes.

Support Icon

assistance technique 24/5

Accès complet à notre équipe d'ingénieurs pendant la période d'essai du produit

Écrire sur des types de documents
Encodage des données de code-barres
Styliser les codes-barres

Démarrage rapide du code-barres

using IronBarCode;
using System.Drawing;

// Creating a barcode is as simple as:
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg");

Image myBarcodeImage = myBarcode.Image; // Can be used as Image
Bitmap myBarcodeBitmap = myBarcode.ToBitmap(); // Can be used as Bitmap

// Reading a barcode is easy with IronBarcode:
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf

// After creating a barcode, we may choose to resize and save which is easily done with:
var myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
myNewBarcode.ResizeTo(400, 100);
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg");

// To set more options and optimization with your Barcode Reading,
// Please utilize the BarcodeReaderOptions paramter of read:
var myOptionsExample = new BarcodeReaderOptions
{
    // Choose a speed from: Faster, Balanced, Detailed, ExtremeDetail
    // There is a tradeoff in performance as more Detail is set
    Speed = ReadingSpeed.Balanced,

    // Reader will stop scanning once a barcode is found, unless set to true
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for.
    // Specifying one or more, performance will increase.
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilizes multiple threads to reads barcodes from multiple images in parallel.
    Multithreaded = true,

    // Maximum threads for parallel. Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes.
    // Will improve performance significantly and avoid unwanted results and avoid noisy parts of the image.
    CropArea = new Rectangle(),

    // Special Setting for Code39 Barcodes.
    // If a Code39 barcode is detected. Try to use extended mode for the full ASCII Character Set
    UseCode39ExtendedMode = true
};

// And, apply:
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
Imports IronBarCode
Imports System.Drawing

' Creating a barcode is as simple as:
Private myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg")

Dim myBarcodeImage As Image = myBarcode.Image ' Can be used as Image
Dim myBarcodeBitmap As Bitmap = myBarcode.ToBitmap() ' Can be used as Bitmap

' Reading a barcode is easy with IronBarcode:
Dim resultFromFile = BarcodeReader.Read("file/barcode.png") ' From a file
Dim resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp")) ' From a bitmap
Dim resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")) ' From an image
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf") ' From PDF use ReadPdf

' After creating a barcode, we may choose to resize and save which is easily done with:
Dim myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)
myNewBarcode.ResizeTo(400, 100)
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg")

' To set more options and optimization with your Barcode Reading,
' Please utilize the BarcodeReaderOptions paramter of read:
Dim myOptionsExample = New BarcodeReaderOptions With {
	.Speed = ReadingSpeed.Balanced,
	.ExpectMultipleBarcodes = True,
	.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
	.Multithreaded = True,
	.MaxParallelThreads = 2,
	.CropArea = New Rectangle(),
	.UseCode39ExtendedMode = True
}

' And, apply:
Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)
Install-Package BarCode

Explorez le code et exécutez-le pour voir l'exemple.

Une ingénierie de classe mondiale,
assistance 24 heures sur 24