# Align Image

Use DsImaging to align an image to center, scale, or stretch&nbsp;with respect to the bitmap. Learn more in DsImaging docs.

## Content

DsImaging provides you an option to set the alignment of an image within its container using the [ImageAlign](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.ImageAlign.html) class. This class provides you an option to center, scale, or stretch an image with respect to the bitmap.
![Image of a beautiful home aligned to the center](https://cdn.mescius.io/document-site-files/images/a5680f0e-2d32-45dc-8048-d3ef11d0dae7/images/alignedimage.png)
To align an image at the center of its container:

1. Initialize the GcBitmap class.
2. Create a drawing surface to draw shapes using [CreateGraphics](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.GcBitmap.CreateGraphics.html) method of the **GcBitmap** class which returns an instance of the [GcBitmapGraphics](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Imaging.GcBitmapGraphics.html) class.
3. Invoke the [DrawImage](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.DrawImage.html) method of GcGraphics class to draw an image and set the image alignment to center using the **ImageAlign** class to pass it as a parameter to the method.

    ```csharp
    //Initialize GcBitmap
    GcBitmap origBmp = new GcBitmap(1000, 1000, true);
    
    //Create the graphics for the Bitmap
    GcBitmapGraphics g = origBmp.CreateGraphics(Color.AliceBlue);
    
    //Get the image and define the image rectangle
    var image = Image.FromFile(Path.Combine("Resources", "Images", "tudor.jpg"));
    var imgRec = new Rectangle(50, 50, image.Width + 100, image.Height + 100);
    g.FillRectangle(imgRec, Color.Gray);
    
    //Draw the image with "CenterImage" alignment mode
    g.DrawImage(image, imgRec, null, ImageAlign.CenterImage);
    
    //Save the image
    origBmp.SaveAsJpeg("AlignImageCenter.jpeg");
    ```

    > !type=note
    > **Note**: For rendering large or complex text and graphics, you can use [Skia](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging.Skia/GrapeCity.Documents.Imaging.Skia.html) library. For more information about the library and its usage, see [Render using Skia Library](/document-solutions/dot-net-imaging-api/docs/online/render-using-skia).