Creating a Single Output File of an Original Image and its Annotation Layers

You can create a single output JPEG or BMP file that is a composite of the original image file and its annotation layers in Snowbound’s RasterMaster .NET imaging SDK. This allows you to print out a single file of the image with its annotations.

To save a combined image as a JPEG or BMP file, add the following to the Annotation Save to Image sample that appears below:

Bitmap Bmp = simage.CIMG_create_bitmap_class(panImage.Width, panImage.Height);

Graphics g = Graphics.FromImage(Bmp);

int xs = 0;

int ys = 0;

int xsize = panImage.Width;

int ysize = panImage.Height;

simage.CSANN_display_annotations(g, xs, ys, xsize, ysize);

Bmp.Save("c:\\annotationimage.bmp"); //your file name

The following is the Annotation Save to Image sample:

int AnnotationSavetoImage(Snowbnd simage, System.Windows.Forms.Panel panImage));

{

string strImageName = "c:\\user\\test\\Color.jpg";

// original image File

string strAnnName = "c:\\user\\test\\Color.ann";

// original annotation file

string strAnnImage; = "C:\\User\\test\\AnnColor.bmp"

// output file annotation with image

// read original image

status = simage.CIMG_decompress_bitmap(strImageName);

if( status < 0 )

return status;

// read annotation from file

status = simage.CSANN_read_ann(panImage, strAnnName);

if( status < 0 )

return status;

//create bitmap class

Bitmap Bmp = simage.CIMG_create_bitmap_class(panImage.Width, panImage.Height);

Graphics g = Graphics.FromImage(Bmp);

int xs = 0;

int ys = 0;

int xsize = panImage.Width;

int ysize = panImage.Height;

//combine annotation to bitmap

simage.CSANN_display_annotations(g, xs, ys, xsize, ysize);

Bmp.Save(strAnnImage);

return 0;

}

Category:

Online Demo