Visual C#.NET - How to Create Images from Stream

How to Generate an Image in Visual C# from Stream with .NET Imaging DLL
Yiigo.Image for .NET is a professional imaging component SDK which allows developers to easily draw, view, edit, and convert image files in their .NET projects as well as web applications. As long as you have a Microsoft Visual Studio 2005 or above installed (Visual Studio Express will also do), you can simply create, manipulate images as you wish using Visual C# and Visual Basic.NET programming.
This library dll package is extremely flexible and powerful, as it provides a variety of imaging features which can meet both the basic and advanced imaging requirements. This page is a simple walk-through on how to create, draw Jpeg / Png/ Gif/ Tiff images from stream in Visual C#.NET projects.
C# Guide - How to Create an Image from Stream

C# Image Creation from Stream - Requirements

  • Verify that you have installed MS Visual Studio 2005 or above/Visual Studio Express.
  • You are using .NET 2.0 or later versions.
  • You are programming with Visual C#.NET language.

C# Image Creation from Stream - Preparation

  • Download imaging SDK: Click on the "Download" button to get the trial package for evaluation.
  • Install imaging SDK: Double click on the exe file to run setup, after you have unzipped the download package.
  • Activate imaging SDK License: If you have purchased the product, type in your serial number to activate the license. If not, request an evaluation license and follow the activation wizard.

C# Image Creation from Stream - Draw Image Using Stream

  • Now start your Visual Studio, and create/open a .NET imaging project.
  • Click on "Add Reference..." and then browse to add the Yiigo.Image.dll in the unzipped download file to your project reference.
  • You will need to create an instance of stream source by passing a stream object to its constructor, and then assign it to the source property.
  • Below is the namespace and sample code to generate images from stream in Visual C#. Feel free to copy to your project for an evaluation.
  • You can add more codings in the end for more image manipulation such as resizing, converting, and annotating.
using System.IO;
using System.Drawing.Printing;
using Yiigo.Imaging;
using Yiigo.Imaging.Processing;

//Creates an instance of BmpOptions and set its various properties
Yiigo.Imaging.ImageOptions.BmpOptions ImageOptions = new Yiigo.Imaging.ImageOptions.BmpOptions();
ImageOptions.BitsPerPixel = 24;


//Create an instance of System.IO.Stream
System.IO.Stream stream = new System.IO.FileStream(@"C:\sample.bmp", System.IO.FileMode.Create);


//Define the source property for the instance of BmpOptions
//Second boolean parameter determines if the Stream is disposed once get out of scope
ImageOptions.Source = new Yiigo.Imaging.Sources.StreamSource(stream, true);


//Creates an instance of Image and call Create method by passing the BmpOptions object
using (Yiigo.Imaging.Image image = Yiigo.Imaging.Image.Create(ImageOptions, 500, 500))
{
//You can do some image processing if necessary
}
Products
Other Plugins
Image Viewer CoreBarcode PluginPDF Read & WriteTesseract OCR PluginForm Processing PluginJBIG2 CodecJPEG2000 CodecISIS ScannerTwain ScannerDICOM ReaderCAD Scanner