Applies to
Declaration
int InputPictureStream(IUnknown Stream, string FileExt, int Width, int Height);
Description
Insert a picture data specified as Stream.
Parameters:
| Stream: | If you use the OCX you can use any IStream reference. |
When using .NET convert an "Stream" using the Stream2WPStream class: TextCursor.InputPictureStream(new WPDynamic.Stream2WPStream(stream1),".PNG",0,0);
| FileExt: | The file extension - it is used to use the correct loading algorithm. Values can be "BMP", "EMF", "WMF", "JPG" and "PNG" |
| Width: | 0 or the desired width in twips (= 1/1440 twips) |
| Height: | 0 or the desired height in twips |
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change image properties.
Example 1:
Create a file stream from an image file and insert it.
IWPTextCursor TextCursor = WPDLLInt1.Memo.TextCursor;
FileStream stream = new FileStream(
"C:\\WPCubedLogo.jpg",FileMode.Open);
TextCursor.InputPictureStream(
new WPDynamic.Stream2WPStream(stream),"jpg",
0,0);
stream.Close();
Width and Height are always measured in twips (= 1/1440 inch). If 0, the content width and height will be used.
Example 2:
Create an image "on the fly" and insert it.
Bitmap aBitmap = new Bitmap(320, 200);
Graphics aGraphic = Graphics.FromImage(aBitmap);
System.IO.MemoryStream aStream = new System.IO.MemoryStream();
IWPMemo Memo = wpdllInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
aGraphic.Clear(Color.AntiqueWhite);
SolidBrush RedBrush = new SolidBrush(Color.Red);
aGraphic.FillEllipse(RedBrush, 10, 10, 300, 180);
aBitmap.Save(aStream,System.Drawing.Imaging.ImageFormat.Bmp);
TextCursor.InputPictureStream(new WPDynamic.Stream2WPStream(aStream), "BMP", 0, 0);
// clean up
aStream.Dispose();
aGraphic.Dispose();
aBitmap.Dispose();
// ReleaseInt was added to TextDynamic V1.31
wpdllInt1.ReleaseInt(TextCursor);
wpdllInt1.ReleaseInt(Memo);