Marblecore Imaging Library Documentation

Documentation Introduction
Documentation / Marblecore Imaging / Methods / Serialize

Serialize method

Serializes the current bitmap to a memory stream. This stream is a binary representation of the image object. You can use this function to transfer images from an image object to another image object. The stream cannot be used to save an image to a file, because the stream does not contain a valid image format like JPEG, PNG or BMP. If you want to do that, use the SaveToStream method instead.

Syntax

Stream Serialize(nLeft As Number, nTop As Number, nWidth As Number, nHeight As Number)

Return value

Returns a stream with the binairy data.

Parameters

ParameterTypeRequiredDescription
nLeftNumberNoOptional parameter which specifies the left coordinate of the rectangle to return.
nTopNumberNoOptional parameter which specifies the top coordinate of the rectangle to return.
nWidthNumberNoOptional parameter which specifies the width of the rectangle to return.
nHeightNumberNoOptional parameter which specifies the height of the rectangle to return.

Example

The Serialize method is a great way to combine image objects. It can be used to insert an image object into another image object with high speed. The example below shows you how to do this. The example consists of two separate images which are blended together using the InsertFromSerializedStream method.
 
1 // Create the first image and draw a red rectangle on it
2 Imaging1.Create(200, 200);
3 Imaging1.DrawRectangleFilled(0, 0, 200, 200, Imaging1.GetColorFromHTML("#ff0000"));
4 
5 // Create the second image and draw a blue circle on it
6 Imaging2.Create(100, 100);
7 Imaging2.DrawEllipseFilled(0, 0, 100, 100, Imaging2.GetColorFromHTML("#0000ff"));
8 
9 // Insert the second image into the first image with 75% opacity
10 Imaging1.InsertFromSerializedStream(Imaging2.Serialize(), 50, 50, 75);

Category

Basic operations

See also

Create | Deserialize | FilterTextureFromSerializedStream | InsertFromSerializedStream | LoadFromBase64 | LoadFromFile | LoadFromSerializedStream | LoadFromStream | LoadFromURL | LoadHistogramFromSerializedStream | MaskOverlayFromSerializedStream | Reset | SaveHistogramToSerializedStream | SaveToBase64 | SaveToFile | SaveToHBitmap | SaveToHBitmapPreMultiplied | SaveToStream | Working with streams