本文整理汇总了C#中System.IO.UnmanagedMemoryStream.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# UnmanagedMemoryStream.Dispose方法的具体用法?C# UnmanagedMemoryStream.Dispose怎么用?C# UnmanagedMemoryStream.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.UnmanagedMemoryStream
的用法示例。
在下文中一共展示了UnmanagedMemoryStream.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: received_data
/// <summary>
/// A portion of the file contents have been received. This method will
/// be called multiple times until the download is complete. Return
/// |true| to continue receiving data and |false| to cancel.
/// </summary>
private int received_data(cef_download_handler_t* self, void* data, int data_size)
{
ThrowIfObjectDisposed();
var m_stream = new UnmanagedMemoryStream((byte*)data, data_size, data_size, FileAccess.Read);
var handled = this.ReceivedData(m_stream);
m_stream.Dispose();
return handled ? 1 : 0;
}
示例2: process_data
/// <summary>
/// Set |substitute_data| to the replacement for the data in |data| if
/// data should be modified.
/// </summary>
private void process_data(cef_content_filter_t* self, /*const*/ void* data, int data_size, cef_stream_reader_t** substitute_data)
{
ThrowIfObjectDisposed();
var m_stream = new UnmanagedMemoryStream((byte*)data, data_size, data_size, FileAccess.Read);
CefStreamReader m_substitute_data;
this.ProcessData(m_stream, out m_substitute_data);
if (m_substitute_data != null)
{
*substitute_data = m_substitute_data.GetNativePointerAndAddRef();
}
m_stream.Dispose();
}
示例3: InitDna
//.........这里部分代码省略.........
if (!codes.Equals("SDNANAME"))
{
throw new InvalidDataException();
}
int dataLen = reader.ReadInt32();
_names = new Dna.NameInfo[dataLen];
for (int i = 0; i < dataLen; i++)
{
List<byte> name = new List<byte>();
byte ch = reader.ReadByte();
while (ch != 0)
{
name.Add(ch);
ch = reader.ReadByte();
}
_names[i] = new Dna.NameInfo(ASCIIEncoding.ASCII.GetString(name.ToArray()));
}
stream.Position = (stream.Position + 3) & ~3;
// TYPE
code = reader.ReadBytes(4);
codes = ASCIIEncoding.ASCII.GetString(code);
if (!codes.Equals("TYPE"))
{
throw new InvalidDataException();
}
dataLen = reader.ReadInt32();
_types = new Dna.TypeDecl[dataLen];
for (int i = 0; i < dataLen; i++)
{
List<byte> name = new List<byte>();
byte ch = reader.ReadByte();
while (ch != 0)
{
name.Add(ch);
ch = reader.ReadByte();
}
string type = ASCIIEncoding.ASCII.GetString(name.ToArray());
_types[i] = new Dna.TypeDecl(type);
}
stream.Position = (stream.Position + 3) & ~3;
// TLEN
code = reader.ReadBytes(4);
codes = ASCIIEncoding.ASCII.GetString(code);
if (!codes.Equals("TLEN"))
{
throw new InvalidDataException();
}
for (int i = 0; i < _types.Length; i++)
{
_types[i].Length = reader.ReadInt16();
}
stream.Position = (stream.Position + 3) & ~3;
// STRC
code = reader.ReadBytes(4);
codes = ASCIIEncoding.ASCII.GetString(code);
if (!codes.Equals("STRC"))
{
throw new InvalidDataException();
}
dataLen = reader.ReadInt32();
_structs = new Dna.StructDecl[dataLen];
long shtPtr = stream.Position;
for (int i = 0; i < dataLen; i++)
{
Dna.StructDecl structDecl = new Dna.StructDecl();
_structs[i] = structDecl;
if (!BitConverter.IsLittleEndian)
{
throw new NotImplementedException();
}
else
{
short typeNr = reader.ReadInt16();
structDecl.Type = _types[typeNr];
structDecl.Type.Struct = structDecl;
int numElements = reader.ReadInt16();
structDecl.Elements = new Dna.ElementDecl[numElements];
for (int j = 0; j < numElements; j++)
{
typeNr = reader.ReadInt16();
short nameNr = reader.ReadInt16();
structDecl.Elements[j] = new Dna.ElementDecl(_types[typeNr], _names[nameNr]);
}
}
}
reader.Dispose();
stream.Dispose();
// build reverse lookups
_structReverse = new Dictionary<string, Dna.StructDecl>(_structs.Length);
foreach (Dna.StructDecl s in _structs)
{
_structReverse.Add(s.Type.Name, s);
}
}
示例4: Open
public override void Open(string filePath)
{
_content = File.ReadAllText(filePath);
int i = _content.IndexOf("%!");
if (i > 0)
{
_content = _content.Substring(i, _content.Length - i - 1);
}
i = _content.IndexOf("%%EOF");
if (i > -1)
{
_content = _content.Substring(0, i + 5);
}
if (this.Viewer.EPSClip)
{
unsafe
{
fixed (char* p = _content)
{
UnmanagedMemoryStream ums = new UnmanagedMemoryStream((byte*)p, _content.Length);
DSCTokenizer tokenizer = new DSCTokenizer(ums, true, BitConverter.IsLittleEndian);
DSCToken token = null;
while ((token = tokenizer.GetNextDSCKeywordToken()) != null)
{
if (token.Text == "%%BoundingBox:")
{
try
{
DSCToken v1 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
DSCToken v2 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
DSCToken v3 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
DSCToken v4 = tokenizer.GetNextDSCValueToken(DSCTokenEnding.Whitespace | DSCTokenEnding.LineEnd);
this.BoundingBox = new GhostscriptRectangle(
float.Parse(v1.Text, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(v2.Text, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(v3.Text, System.Globalization.CultureInfo.InvariantCulture),
float.Parse(v4.Text, System.Globalization.CultureInfo.InvariantCulture));
}
catch { }
break;
}
}
tokenizer.Dispose(); tokenizer = null;
ums.Close(); ums.Dispose(); ums = null;
}
}
}
this.FirstPageNumber = 1;
this.LastPageNumber = 1;
}
示例5: getImage
//returns bitmap image converted from the PANGU stream
public Bitmap getImage(float x, float y, float z, float yaw, float pitch, float roll , float fov)
{
try
{
unsafe
{
pan_protocol_set_aspect_ratio(sock, 1); //sets aspect ratio
pan_protocol_set_boulder_view(sock, 1, 0); //view boulders
pan_protocol_set_field_of_view(sock, fov); //set field of view
ulong t = 1024;
char* img;
img = pan_protocol_get_viewpoint_by_angle(sock, x, y, z, yaw, pitch, roll, &t); //gets the image
UnmanagedMemoryStream readStream = new UnmanagedMemoryStream((byte*)img, (long)t);
Bitmap bitmap = fetchImage(readStream);
readStream.Close();
readStream.Dispose();
return bitmap;
}
}
catch
{
return null; //Error at PANGU end.
}
}