Guide for C#
Open Image from File
Core Document Formats
Additional Features

C# Imaging - Load Image from File in C#.NET

Free Visual C# Codes for Loading Image from Local File with .NET Imaging SDK

Visual C#
Home > .NET Imaging SDK > C# > Load Image from File
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

RasterEdge .NET Imaging SDK contains several library DLLs to fulfill multiple image processing & manipulation tasks. Among all the controls, there are RasterEdge.Imaging.Basic.dll and RasterEdge.Imaging.Basic.Codec.dll which are designed for C# and VB.NET developers to perform some basic imaging functions, such as loading image from a file, loading file from .NET graphics, creating a new image, and printing or saving an image to your local disk, and so on. As for loading image from a file in C# project, please see details as below.
  • Loading an image from local file by specifying path
  • Support loading images in png, gif, jpeg, tiff and bmp image formats
  • Only two lines of C# coding are needed for opening an image locally
  • Open and display an image with Visual C# samples codes
  • Easy to integrate into Microsoft Visual Studio 2005 and above versions
  • Compatible with .NET Framework 2.0 or later
This Visual C# tutorial for loading an image from local file includes the following parts:
  • C# project and library preparation
  • C# methods for image loading
  • C# sample codes to load image from file
  • Some more related C# imaging tutorials
If you are a Visual Basic programmer, please go to Load Image from Files in VB.NET. If you are looking for tutorials on how to view Image and document in WinForms or ASP.NET Web application, please go to tutorials for loading Image from files in Windows Forms and Web Document Image.
C# Project and Library Preparation
  • At the very beginning, please download the trial package or the licensed software to your computer and unzip it.
  • Start up your MS Visual Studio and create a new Visual C# project such as Windows Application.
  • Activate license of DocImage SDK for .NET.
  • Add the library components to your project reference. Simply right click on Solution Explorer, choose Add Reference..., and then browse to locate your libraries.
  • You can now call the following RasterEdge DocImageSDK namespaces in your C# imaging program.
using RasterEdge.Imaging.Basic.Core;
using RasterEdge.Imaging.Basic;
using RasterEdge.Imaging.Basic.Codec;
Image Loading C# Methods
RasterEdge provides mature methods for developers to load an image using Visual C# programming language. Please note that the commonly used image formats are all supported by .NET imaging library SDK package, such as png, gif, jpeg, tiff and bmp. Image loading functionality is the basis for many imaging features such as C#.NET image resizing, scaling, cropping, rotating, flipping, and converting, to name just a few.
public REImage(String filename);
public REImage(String fileName, ImageType sourceType);
How to Load Image from File with C# Sample Codes
After the introduction for the setup, namespace and methods, here we provide the visual C# sample codes to load from multiple image files under a directory by using RasterEdge .NET Imaging SDK. Now please copy the C# demo coding to your program to open an image. Make sure that you have made necessary adjustments according to your file directory where the image is stored.
When the image is loaded, users can conduct a variety of image processing and manipulation actions. You can resize the loaded image with C# coding, rotate it within 360 degrees, add a barcode in the image, or decode the barcode in it, duplicate / flip the image, and convert the images to other image formats such as png, jpeg, gif, tiff and bmp.
// invoke this method only once at the beginning of your code register all assemblies you referenced to your project
WorkRegistry.Reset();

List<REImage> tmpImgList = new List<REImage>();

DirectoryInfo d = new DirectoryInfo(filepath);

foreach (FileInfo file in d.GetFiles())
{
// construct image source from jpeg and png images
if (file.Extension.ToLower().Contains("jpeg") || file.Extension.ToLower().Contains("png"))
{
REImage img = new REImage(file.FullName);
tmpImgList.Add(img);
}
}

REImage[] ImageSource = tmpImgList.ToArray();
More Imaging Viewing Guide!


Recommend this to Google+