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 How can I read barcodes from System.Drawing objects in .NET C#? You can read barcodes from System.Drawing objects by using IronBarcode in conjunction with IronDrawing. First, cast your System.Drawing objects into AnyBitmap using IronDrawing, then use the Read method from IronBarcode to read the barcodes. What is IronDrawing and how does it help with barcode reading? IronDrawing is a free and open-source library by IronSoftware that allows for implicit casting of System.Drawing objects into AnyBitmap. This facilitates barcode reading on non-Windows operating systems by making these objects compatible with IronBarcode. Can I use IronBarcode to read barcodes on MacOS and Linux? Yes, by using IronDrawing, you can cast System.Drawing objects into AnyBitmap, which allows IronBarcode to read barcodes on MacOS and Linux, overcoming the limitation of System.Drawing being Windows-only. What image object types can be cast to AnyBitmap for barcode reading? Besides System.Drawing objects, you can cast System.Drawing.Bitmap, System.Drawing.Image, SkiaSharp.SKBitmap, SkiaSharp.SKImage, and SixLabors.ImageSharp objects to AnyBitmap for barcode reading with IronBarcode. How do I display detected barcode values using IronBarcode? After reading barcodes with IronBarcode’s Read method, iterate through the BarcodeResult array and print each barcode value to the console. Is IronDrawing included when installing a barcode reading library from NuGet? Yes, IronDrawing is automatically included in your project when you install IronBarcode from NuGet, providing seamless integration for barcode reading. How can implicit casting of image objects help in barcode processing? Implicit casting of image objects into AnyBitmap using IronDrawing simplifies the process of making System.Drawing objects compatible with IronBarcode, enhancing barcode processing on various operating systems. 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 ...Read More Ready to Get Started? Free NuGet Download Total downloads: 1,818,593 View Licenses