How to C#: Imaging
Using Imaging SDK for C#.NET
Winforms Controls
Image Load
Load Image
Image Access and Modify
Load Image
  |  
Home ›› XImage.Raster ›› C# Raster: Load Image

How to C#: Load Image Using XImage.Raster


Overview for How to Use XImage.Raster to load raster image in C# .NET Programming Project




RasterEdge XImage.Raster has provided five ways to create raster image object that are load from file, load from stream, load from url, load from bitmap and clone raster image from object.


The site Advanced Load Options has explained how to use the loading options. When loading image from to RasterImage object, if the parameter LoadOptions was not set, XImage.Raster SDK will load the image according to the default load option settings. That is, if you don't have any special needs, or don't know how to preset the load options, you can load image from file with the default load options whether it is PNG/BMP such a single frame image or GIF/TIFF such a multi frame image.




Load Image from file Using C#



You can load image from file using the codes as follows.


Sample Code (load image with default load option)




RasterImage img = new  RasterImage(@"C:\input.jpeg"); 




Sample Code (load image with load option)




//use specified load option load image from file
LoadOption option = new LoadOption();
option.LoadAlphaChannel = false;
option.Resize = new Size(100, 100);
//load image from file according to specified load options
RasterImage img = new RasterImage(@"input.jpeg", option);





Load Image from Stream Using C#



With the XImage.Raster SDK, you can load image from a memory or filestream. While, you can load a single frame image or multi frame image in the same way. You can load image from stream as follows.


Sample Code(load image from file stream with default load option)




//load image from stream without load options
FileStream fs = new FileStream(@"input.jpeg", FileMode.Open,  FileAccess.Read);
RasterImage img = new RasterImage(fs);




Sample Code(load image from file stream with load option)




/load image from stream with load options
FileStream fs = new  FileStream(@"input.jpeg", FileMode.Open, FileAccess.Read);
LoadOption option = new  LoadOption();
option.LoadAlphaChannel = false;
option.Resize = new Size(100,  100);
RasterImage img = new RasterImage(fs,  option); 





Load Image from Bitmap or DIB Using C#



With the XImage.Raster SDK, you can load image from System.Drawing.Bitmap or DIB data to the RasterImage object.


Sample Code (load image from bitmap with default option)




//load image from bitmap without load options
RasterImage img = new RasterImage(bm);




Sample Code (load image from bitmap with option)




//load image from bitmap with load options/
LoadOption option = new LoadOption();
option.LoadAlphaChannel = false;
option.Resize = new Size(100, 100);
RasterImage img = new RasterImage(bm, option);