XImage.Raster
Features
Tech Specs
How-to C#
Pricing

C# Image Process Library
How to create new image object in C#?


With XImage.Raster, you can Create New Image in C# .NET







How to create, load BMP, PNG raster images using C#?

  1. Download XImage.Raster C# imaging library
  2. Install C# library to create new or loading existing TIFF, BMP, PNG, JPG images in .NET applications
  3. Step by Step Tutorial








Class RasterImage


RasterEdge XImage.Raster C# library has one class RasterImage, which is used for representing images in your C# ASP.NET Core, MVC, Windows Forms and WPF applications.

RasterImage includes the following image properties

  • Width. The width of the image in pixels.
  • Height. The height of the image in pixels.
  • HResolution. Image horizontal resolution. The number of pixels per inch.
  • VResolution. Image vertical resolution. The number of pixels per inch.
  • ColorSpace. Image color space.
  • Compress. Image compression.
  • Palette. Image color palette.
  • format. Image format.





Create images in C#



Create image from scratch

Using RasterEdge XImage.Raster C# image library, you can easily create a blank image from scratch in C# application.

The following C# example codes will create a new image with specified image size and background color.

  1. Create a RasterImage object, with specified image width, height in pixel, and image background color in rgb.
  2. Call method Save to print the image to the specified image file path.

    1. RasterImage anImage = new RasterImage(200, 200, Color.LightBlue);
      anImage.Save("C:\\output\\raster-image-new-from-scratch.png");
      





Load image from existing image file

Create a new RasterImage object from an existing image file, you can further process the image in C# application.

RasterImage anImage = new RasterImage("C:\\Input\\raster-sample-image.png");




Create image from other RasterImage object

You can use Clone method to copy and create a new RasterImage object from another existing RasterImage object.

The C# code below creates a new copy of the existing image. Any updates on the new image object will not affect the old image.

RasterImage anImage = new RasterImage("C:\\Input\\raster-sample-image.png");
RasterImage clonedImage = anImage.Clone();




Create image from Stream object in memory

Using XImage.Raster C# library, you can create RasterImage object directly from image in memory, such as Stream, byte array objects. The C# source codes below show how to load an image in the Stream object in C# program.

Stream imageInStream = new FileStream("C:\\Input\\raster-sample-image.png",
    FileMode.Open, FileAccess.Read, FileShare.Read);
RasterImage anImage = new RasterImage(imageInStream);




Create image from other sources

Using XImage.Raster C# image library, you can also create RasterImage from other sources, including:
  • System.Drawing.Bitmap object
  • byte array
  • Hbitmap




What's Next?



After you have created a RasterImage object, you can do the following tasks on the loaded image object.
  • Process the image object through new ImageProcess(img)
  • Save, export the image object to a image file, Stream object, byte array.