---
title: "C# .NET 1D linear barcode generator | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/barcodes/generation/1d-linear/"
md_url: "https://www.nutrient.io/guides/dotnet/barcodes/generation/1d-linear.md"
last_updated: "2026-05-21T17:12:02.199Z"
description: "Learn to create 1D barcodes in C# using Nutrient .NET SDK (formerly GdPicture.NET). Follow our step-by-step guide to generate and save barcodes."
---

# Generate 1D barcodes in C#

Nutrient.NET SDK (formerly GdPicture.NET) enables you to generate one-dimensional (1D or linear) and two-dimensional (2D) barcodes.

Nutrient.NET SDK supports all 1D barcode formats and the following 2D barcode formats:

- Aztec Code

- Data Matrix

- MaxiCode

- Micro QR

- PDF417

- QR

To generate a 1D barcode, follow these steps:

1. Create a `GdPictureImaging` object.

2. Create an empty GdPicture image with the `CreateNewGdPictureImage` method of the `GdPictureImaging` object. This method takes the following parameters:
   - The width of the image in pixels.
   - The height of the image in pixels.
   - The bit depth of the image.
   - The background color of the image. Use the `ARGB` method of the `GdPictureImaging` object to specify the color with the ARGB standard. For example, for a white background, set `gdpictureImaging.ARGB(255, 255, 255)`.

3. Write the barcode to the empty image with the `Barcode1DWrite` method of the `GdPictureImaging` object. This method takes the following parameters:
   - The image ID of the newly created image.
   - The barcode type. This parameter is a member of the `Barcode1DWriterType` enumeration.
   - The data encoded in the barcode.
   - The distance between the left side of the image and the barcode in pixels.
   - The distance between the top side of the image and the barcode in pixels.
   - The width of the barcode in pixels.
   - The height of the barcode in pixels.
   - The color of the barcode. Use the `ARGB` method of the `GdPictureImaging` object to specify the color with the ARGB standard. For example, for black, set `gdpictureImaging.ARGB(0, 0, 0)`.
   - Optional: The alignment of the barcode. This parameter is a member of the `BarcodeAlign` enumeration.

4. Save the image as a PNG file with the `SaveAsPNG` method of the `GdPictureImaging` object.

5. Release unnecessary resources.

The example below generates a 1D barcode:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create an empty GdPicture image.
int imageID = gdpictureImaging.CreateNewGdPictureImage(300, 100, 32, gdpictureImaging.ARGB(255, 255, 255));
// Write the barcode to the empty image.
gdpictureImaging.Barcode1DWrite(imageID, Barcode1DWriterType.Barcode1DWriterStandard2of5, "0123456789", 0, 0, 300, 100, gdpictureImaging.ARGB(0, 0, 0), BarcodeAlign.BarcodeAlignCenter);
// Save the image as a PNG file.
gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
// Release unnecessary resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Create an empty GdPicture image.
    Dim imageID As Integer = gdpictureImaging.CreateNewGdPictureImage(300, 100, 32,
        gdpictureImaging.ARGB(255, 255, 255))
    ' Write the barcode to the empty image.
    gdpictureImaging.Barcode1DWrite(imageID, Barcode1DWriterType.Barcode1DWriterStandard2of5, "0123456789",
        0, 0, 300, 100, gdpictureImaging.ARGB(0, 0, 0), BarcodeAlign.BarcodeAlignCenter)
    ' Save the image as a PNG file.
    gdpictureImaging.SaveAsPNG(imageID, "C:\temp\output.png")
    ' Release unnecessary resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID)
End Using

```

#### Used methods and properties

- [`ARGB`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~ARGB.html)

- [`Barcode1DWrite`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~Barcode1DWrite.html)

- [`Barcode1DWriterType`](/api/gdpicture/GdPicture.NET.14~GdPicture14.Barcode1DWriterType.html)

- [`CreateNewGdPictureImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~CreateNewGdPictureImage.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~SaveAsPNG.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

---

## Related pages

- [Generate barcodes in C#](/guides/dotnet/barcodes/generation.md)
- [Generate Data Matrix barcodes in C# .NET](/guides/dotnet/barcodes/generation/datamatrix.md)
- [Generate MaxiCode barcodes in C# .NET](/guides/dotnet/barcodes/generation/maxicode.md)
- [Generate QR codes with C# .NET](/guides/dotnet/barcodes/generation/qr.md)
- [Generate Aztec barcodes in C# .NET](/guides/dotnet/barcodes/generation/aztec-code.md)
- [Generate PDF417 barcodes in C# .NET](/guides/dotnet/barcodes/generation/pdf417.md)
- [Generate Micro QR codes in C# .NET](/guides/dotnet/barcodes/generation/microqr.md)
- [Write a QR code to an image](/guides/dotnet/barcodes/generation/write-qr-code-to-image.md)
- [Write a 1D barcode to an image](/guides/dotnet/barcodes/generation/write-1d-barcode-to-image.md)

