Documentation / Marblecore Imaging / Methods / SaveToStream
SaveToStream method
Saves the current image (in the specified format) and returns the stream. The stream data contains all binary information which is normally saved to a physic file when you save the image to a file using the
SaveToFile method. You can use the stream to save the image to a file using your own custom function. You can also use the stream to transfer image objects within your application, so you don't have to save the image to (temporary) files. If you just want to transfer image data from one image object to another image object, use the
Serialize,
Deserialize and
LoadFromSerializedStream functions. Those methods give better performance for internal image data transfers.
Syntax
Stream SaveToStream(nFormat As Format, nBPP As Number, nLeft As Number, nTop As Number, nWidth As Number, nHeight As Number)
Return value
Returns a stream with the binairy data.
Parameters
Parameter | Type | Required | Description |
nFormat | Format (Enumeration) | No | Optional parameter containing the format for the file. |
nBPP | Number | No | Optional parameter containing the number of bits per pixel for the file. |
nLeft | Number | No | Optional parameter which specifies the left coordinate of the rectangle to return. |
nTop | Number | No | Optional parameter which specifies the top coordinate of the rectangle to return. |
nWidth | Number | No | Optional parameter which specifies the width of the rectangle to return. |
nHeight | Number | No | Optional parameter which specifies the height of the rectangle to return. |
Example
The
SaveToStream method can be used to save an image and stream it to a webserver. The example below shows how to use this method in
classic ASP to create an image and stream it to the browser using
VBScript. In this example we also disabled the ASP session support using the
ENABLESESSIONSTATE directive. This gives better performance for returning images through ASP.
1 <%@ Language=VBScript @ENABLESESSIONSTATE=FALSE %>
2 <%
3
4 Dim MyImage
5
6
7 Set MyImage = CreateObject("Marblecore.Imaging")
8
9
10 MyImage.Create 200, 200
11
12
13 MyImage.DrawRectangleFilled 0, 0, 200, 200, MyImage.GetColorFromHTML("#ff0000")
14
15
16 Response.ContentType = MyImage.GetMIMEFromFormat("PNG")
17 Response.BinaryWrite MyImage.SaveToStream("PNG")
18
19 %>
Category
Basic operations
See also
Create |
Deserialize |
LoadFromBase64 |
LoadFromFile |
LoadFromSerializedStream |
LoadFromStream |
LoadFromURL |
Reset |
SaveToBase64 |
SaveToFile |
SaveToHBitmap |
SaveToHBitmapPreMultiplied |
Serialize |
Working with streams