JpegImage Constructor (RasterImage)
Initializes a new instance of the JpegImage class.

Namespace: Aspose.Imaging.FileFormats.Jpeg
Assembly: Aspose.Imaging (in Aspose.Imaging.dll) Version: 21.04
public JpegImage(
	RasterImage rasterImage


Type: Aspose.ImagingRasterImage
The image to initialize pixel and palette data with.
The example shows how to load a JpegImage from another RasterImage.

string dir = "c:\\temp\\";

// Load a JPEG image from another raster image.
// First, create a temporal PNG image that will be a foundation for building a JPEG image.
// You can also load PNG image from a file or use an image of any other raster format.
Aspose.Imaging.ImageOptions.PngOptions createOptions = new Aspose.Imaging.ImageOptions.PngOptions();
createOptions.Source = new Aspose.Imaging.Sources.StreamSource(new System.IO.MemoryStream(), false);
using (Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)Aspose.Imaging.Image.Create(createOptions, 100, 100))
    // Fill the entire PNG image in red.
    Aspose.Imaging.Graphics graphics = new Aspose.Imaging.Graphics(rasterImage);
    Aspose.Imaging.Brushes.SolidBrush brush = new Aspose.Imaging.Brushes.SolidBrush(Aspose.Imaging.Color.Red);
    graphics.FillRectangle(brush, rasterImage.Bounds);

    // Create a JPEG image based on the PNG image.
    using (Aspose.Imaging.FileFormats.Jpeg.JpegImage jpegImage = new Aspose.Imaging.FileFormats.Jpeg.JpegImage(rasterImage))
        // Save to a JPEG file
        jpegImage.Save(dir + "output.jpg");
See Also