IronBarcode How-Tos Read Barcodes from System.Drawing How to Read Barcodes From System.Drawing Objects Hairil Hasyimi Bin Omar Updated:July 28, 2025 System.Drawing objects are widely used in .NET for tasks related to image processing by developers. However, Microsoft has discontinued support for System.Drawing on other operating systems, such as MacOS and Linux, and now exclusively supports Windows. This significant change has caused multiple issues for developers using IronBarcode on operating systems other than Windows. This is because working with barcodes typically involves using objects like graphics, images, and fonts. To address this problem, we have introduced an alternative solution: IronDrawing. This free and open-source library, initiated by IronSoftware, aims to simplify the process of making it work on operating systems other than Windows. This provides a user-friendly experience for our users. Once you install IronBarcode from NuGet, IronDrawing will be automatically included in your project. Get started with IronBarcode Start using IronBarcode in your project today with a free trial. First Step: Start for Free How to Read Barcodes From System.Drawing Objects Download the C# library for reading barcodes from System.Drawing Utilize IronDrawing to cast System.Drawing objects into AnyBitmap Use the Read method to read barcodes from AnyBitmap objects Display the detected barcode values on the console Explore another article to learn how IronDrawing is used for handling color and fonts Cast System.Drawing to AnyBitmap Reading barcodes from System.Drawing simply involves casting the object to AnyBitmap. IronDrawing was designed with ease of use in mind. Consequently, IronDrawing supports implicit casting for image objects from System.Drawing into IronSoftware.Drawing image objects called AnyBitmap. In addition to System.Drawing objects, we also support casting from other types of objects, including: System.Drawing.Bitmap System.Drawing.Image SkiaSharp.SKBitmap SkiaSharp.SKImage SixLabors.ImageSharp Users can refer to the following code example for casting objects above. Below is a code snippet that demonstrates how to cast images of barcodes from System.Drawing objects into IronSoftware.Drawing.AnyBitmap. Here is a simple example: :path=/static-assets/barcode/content-code-examples/how-to/read-barcodes-from-system-drawing-cast-to-anybitmap.cs using IronSoftware.Drawing; using System.Collections.Generic; List<AnyBitmap> barcodes = new List<AnyBitmap>(); // Instantiate System.Drawing.Bitmap System.Drawing.Bitmap bitmapFromBitmap = new System.Drawing.Bitmap("test1.jpg"); // Cast from System.Drawing.Bitmap to AnyBitmap AnyBitmap barcode1 = bitmapFromBitmap; barcodes.Add(barcode1); // Instantiate System.Drawing.Bitmap System.Drawing.Image bitmapFromFile = System.Drawing.Image.FromFile("test2.png"); // Cast from System.Drawing.Image to AnyBitmap AnyBitmap barcode2 = bitmapFromFile; barcodes.Add(barcode2); Imports IronSoftware.Drawing Imports System.Collections.Generic Private barcodes As New List(Of AnyBitmap)() ' Instantiate System.Drawing.Bitmap Private bitmapFromBitmap As New System.Drawing.Bitmap("test1.jpg") ' Cast from System.Drawing.Bitmap to AnyBitmap Private barcode1 As AnyBitmap = bitmapFromBitmap barcodes.Add(barcode1) ' Instantiate System.Drawing.Bitmap Dim bitmapFromFile As System.Drawing.Image = System.Drawing.Image.FromFile("test2.png") ' Cast from System.Drawing.Image to AnyBitmap Dim barcode2 As AnyBitmap = bitmapFromFile barcodes.Add(barcode2) $vbLabelText $csharpLabel From the code snippet above, we loaded two barcode images as System.Drawing.Bitmap and System.Drawing.Image. We then implicitly cast them into AnyBitmap simply by assigning them to AnyBitmap objects. Subsequently, we added these objects to an AnyBitmap list. Read Barcodes from AnyBitmap IronBarcode can readily accept IronSoftware.Drawing.AnyBitmap objects in all of its methods without requiring any additional configuration. This offers ease of use to developers who use IronBarcode with System.Drawing objects that are not supported on operating systems other than Windows. The code snippet below demonstrates how to do this. :path=/static-assets/barcode/content-code-examples/how-to/read-barcodes-from-system-drawing-read-anybitmap.cs using IronBarCode; using IronSoftware.Drawing; using System; using System.Collections.Generic; List<AnyBitmap> barcodes = new List<AnyBitmap>(); System.Drawing.Bitmap bitmapFromBitmap = new System.Drawing.Bitmap("test1.jpg"); AnyBitmap barcode1 = bitmapFromBitmap; barcodes.Add(barcode1); System.Drawing.Image bitmapFromFile = System.Drawing.Image.FromFile("test2.png"); AnyBitmap barcode2 = bitmapFromFile; barcodes.Add(barcode2); foreach (var barcode in barcodes) { // Read the barcode var results = BarcodeReader.Read(barcode); foreach (var result in results) { // Output the detected barcode value Console.WriteLine(result.Value); } } Imports IronBarCode Imports IronSoftware.Drawing Imports System Imports System.Collections.Generic Private barcodes As New List(Of AnyBitmap)() Private bitmapFromBitmap As New System.Drawing.Bitmap("test1.jpg") Private barcode1 As AnyBitmap = bitmapFromBitmap barcodes.Add(barcode1) Dim bitmapFromFile As System.Drawing.Image = System.Drawing.Image.FromFile("test2.png") Dim barcode2 As AnyBitmap = bitmapFromFile barcodes.Add(barcode2) For Each barcode In barcodes ' Read the barcode Dim results = BarcodeReader.Read(barcode) For Each result In results ' Output the detected barcode value Console.WriteLine(result.Value) Next result Next barcode $vbLabelText $csharpLabel The code snippet above is an extension of the previous one. Once we populated the AnyBitmap list, we iterated through the list and called the Read method on each AnyBitmap object as the parameter, which then returned IronBarcode.BarcodeResults. We then iterated through the returned object to print the barcode value to the console. The area of functionality in IronSoftware.Drawing is not only limited to casting images. It is also heavily used in other image processing aspects, such as colors and fonts that are useful in styling barcodes and QR codes. Users can explore how we utilize IronDrawing to customize and add logos to QR codes. Frequently Asked Questions What is the alternative to System.Drawing for reading barcodes on non-Windows operating systems? The alternative to System.Drawing for reading barcodes on non-Windows operating systems is IronDrawing, a free and open-source library initiated by IronSoftware. How do you cast image objects to AnyBitmap in C#? You can cast System.Drawing objects to AnyBitmap in IronDrawing by utilizing implicit casting. This allows you to convert image objects from System.Drawing into IronSoftware.Drawing image objects called AnyBitmap. Can a .NET library read barcodes from AnyBitmap objects? Yes, IronBarcode can readily accept IronSoftware.Drawing.AnyBitmap objects in all of its methods without requiring any additional configuration. What types of image formats can be cast to AnyBitmap? In addition to System.Drawing objects, you can cast System.Drawing.Bitmap, System.Drawing.Image, SkiaSharp.SKBitmap, SkiaSharp.SKImage, and SixLabors.ImageSharp objects to AnyBitmap. What is the purpose of using an open-source library with barcode reading? The purpose of using IronDrawing with IronBarcode is to enable barcode reading from System.Drawing objects on operating systems other than Windows, providing a user-friendly experience and broader compatibility. Is an open-source drawing library included automatically when installing a barcode reading library from NuGet? Yes, once you install IronBarcode from NuGet, IronDrawing will be automatically included in your project. How can developers display detected barcode values using a .NET library? Developers can display detected barcode values by iterating through the BarcodeResult array returned by the Read method and printing each barcode value to the console. Hairil Hasyimi Bin Omar Chat with engineering team now Software Engineer Like all great engineers, Hairil is an avid learner. He’s refining his knowledge of C#, Python, and Java, using that knowledge to add value to team members across Iron Software. Hairil joined the Iron Software team from Universiti Teknologi MARA in Malaysia, where he graduated with a Bachelor's degree in Chemical and Process Engineering. Ready to Get Started? Free NuGet Download Total downloads: 1,743,856 View Licenses