private static PagedMemoryStream smethod_0(string uri) { HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri); httpWebRequest.UserAgent = "Foo"; using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK && response.StatusCode != HttpStatusCode.MovedPermanently) { if (response.StatusCode != HttpStatusCode.Found) { goto label_14; } } if (response.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase)) { using (Stream responseStream = response.GetResponseStream()) { PagedMemoryStream pagedMemoryStream = new PagedMemoryStream(); byte[] buffer = new byte[4096]; int count; do { count = responseStream.Read(buffer, 0, buffer.Length); pagedMemoryStream.Write(buffer, 0, count); }while (count != 0); pagedMemoryStream.Position = 0L; return(pagedMemoryStream); } } } label_14: return((PagedMemoryStream)null); }
private void method_16( DxfReader r, Class285 objectBuilder, ref Interface30 binaryDataReader, ref Interface30 stringDataReader, ref long graphicsDataSizeInBytes, ref PagedMemoryStream graphicsData, ref Stream currentStream) { string subclass = (string)r.CurrentGroup.Value; r.method_85(); this.stream_0 = (Stream)null; this.stream_1 = (Stream)null; while (!r.method_92(subclass)) { if (!this.method_17(r, objectBuilder, ref graphicsDataSizeInBytes, ref graphicsData, ref currentStream)) { r.method_85(); } } if (this.stream_0 != null) { this.stream_0.Position = 0L; binaryDataReader = Class444.Create(r.ModelBuilder.Version, this.stream_0); } if (this.stream_1 == null) { return; } this.stream_1.Position = 0L; stringDataReader = Class444.Create(r.ModelBuilder.Version, this.stream_1); }
internal override void vmethod_11(Class434 or, Class285 entityBuilder, long imageSize) { PagedMemoryStream targetStream = new PagedMemoryStream((long)(int)imageSize, System.Math.Min((int)imageSize, 65536)); or.ObjectBitStream.imethod_20((int)imageSize, targetStream); this.proxyGraphics_0 = new ProxyGraphics(); ((DxfProxyEntity.Class287)entityBuilder).ProxyGraphicsBuilder = this.proxyGraphics_0.Read((Stream)targetStream, or.Builder); }
public static IBitmap LoadBitmap( string filename, string modelFilename, int downloadTimeoutMs) { if (!filename.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase)) { if (!filename.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) { string str = filename; if (!System.IO.File.Exists(str) && Path.IsPathRooted(str)) { str = Path.GetFileName(filename); } if (!Path.IsPathRooted(str) && Path.IsPathRooted(modelFilename)) { string directoryName = Path.GetDirectoryName(modelFilename); str = Path.Combine(directoryName, str); if (!System.IO.File.Exists(str)) { str = Path.Combine(directoryName, Path.GetFileName(str)); } } if (System.IO.File.Exists(str)) { MemoryStream memoryStream = new MemoryStream(System.IO.File.ReadAllBytes(str), false); Bitmap bitmap; try { bitmap = (Bitmap)System.Drawing.Image.FromStream((Stream)memoryStream); } catch (Exception ex) { return(GdiBitmap.InvalidBitmap); } return((IBitmap) new GdiBitmap(bitmap)); } goto label_15; } } try { PagedMemoryStream pagedMemoryStream = GdiBitmap.smethod_0(filename); if (pagedMemoryStream != null) { return((IBitmap) new GdiBitmap(new Bitmap((Stream)pagedMemoryStream))); } } catch (Exception ex) { } label_15: return(GdiBitmap.InvalidBitmap); }
public static PagedMemoryStream smethod_1( Stream source, long length, MemoryPageCache memoryPageCache) { long position = source.Position; MemoryStream source1 = source as MemoryStream; PagedMemoryStream pagedMemoryStream = source1 == null ? new PagedMemoryStream(source, length, memoryPageCache.PageSize, (IMemoryPageCache)memoryPageCache) : new PagedMemoryStream(source1, length); source.Position = position; return(pagedMemoryStream); }
public static void smethod_2(PagedMemoryStream from, Interface29 to) { int length1 = (int)from.Length; for (int index = 0; index < from.Pages.Count; ++index) { int length2 = System.Math.Min(length1, from.PageSize); to.imethod_13(from.Pages[index], 0, length2); length1 -= length2; if (length1 <= 0) { break; } } }
private long method_21(DxfWriter w, PagedMemoryStream binData, long binDataSizeInBits) { Class724 class724 = (Class724)Class724.smethod_0(Class885.smethod_4(this.dwgVersion_0), (Stream)binData, Encodings.GetEncoding((int)w.Model.Header.DrawingCodePage)); class724.imethod_47(binDataSizeInBits); if (this.uint_0 > 0U) { this.stream_1.Position = 0L; this.method_14((Interface29)class724, this.stream_1, (long)this.uint_0); class724.imethod_50((long)this.uint_0); } class724.imethod_14(this.uint_0 > 0U); binDataSizeInBits += (long)this.uint_0; return(binDataSizeInBits); }
internal override void Read(DxfReader r, Class259 objectBuilder) { base.Read(r, objectBuilder); Class285 class285 = (Class285)objectBuilder; Interface30 binaryDataReader = (Interface30)null; Interface30 stringDataReader = (Interface30)null; Stream currentStream = (Stream)null; long graphicsDataSizeInBytes = 0; PagedMemoryStream graphicsData = (PagedMemoryStream)null; r.method_85(); while (r.CurrentGroup.Code != 0) { if (r.CurrentGroup.Code == 100) { switch ((string)r.CurrentGroup.Value) { case "AcDbZombieEntity": case "AcDbProxyEntity": this.method_16(r, class285, ref binaryDataReader, ref stringDataReader, ref graphicsDataSizeInBytes, ref graphicsData, ref currentStream); continue; case "AcDbEntity": this.method_8(r, class285); continue; default: if (this.bool_2) { this.method_18(r, objectBuilder); continue; } continue; } } else { this.method_9(r, class285); } } this.method_13(r.ModelBuilder.Version); if (graphicsData == null) { return; } this.proxyGraphics_0 = new ProxyGraphics(); ((DxfProxyEntity.Class287)class285).ProxyGraphicsBuilder = this.proxyGraphics_0.Read((Stream)graphicsData, (Class374)r.ModelBuilder); }
public Stream imethod_0(Class741.Class742 serializer) { PagedMemoryStream pagedMemoryStream = new PagedMemoryStream((long)(int)this.ulong_0); int num = 0; foreach (Class49.Class52.Class58.Class59 class59 in this.list_0) { serializer.Stream.Position = serializer.DataStoreStreamStartPosition + (long)serializer.SegmentIndex.Entries[(int)class59.SegmentIndex].Offset; Class49.Class56 class56 = new Class49.Class56(); class56.Read(serializer); if ((long)class56.BinaryData.Length != (long)class59.Size) { throw new Exception("Blob binary data size does not match expected size."); } StreamUtil.Forward(class56.BinaryData.Stream, class56.BinaryData.Offset, (Stream)pagedMemoryStream, class56.BinaryData.Length); num += (int)class59.Size; } pagedMemoryStream.Position = 0L; return((Stream)pagedMemoryStream); }
public void AddSoftMask(PdfBody body) { int width = this.Width; int height = this.Height; PagedMemoryStream pagedMemoryStream = new PagedMemoryStream((long)(width * height)); bool flag = false; this.ibitmap_0.LockBits(); try { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { byte alpha = this.GetAlpha(x, y); if (alpha != byte.MaxValue) { flag = true; } pagedMemoryStream.WriteByte(alpha); } } } finally { this.ibitmap_0.UnlockBits(); } if (flag) { PdfIndirectObject pdfIndirectObject = new PdfIndirectObject((IPdfObject) new PdfSoftMaskImage() { Width = this.Width, Height = this.Height, OpacityStream = (Stream)pagedMemoryStream }); body.IndirectObjects.Add((IPdfIndirectObject)pdfIndirectObject); this.Dictionary["SMask"] = (IPdfObject) new PdfReference((IPdfIndirectObject)pdfIndirectObject); } else { pagedMemoryStream.Dispose(); } }
internal override void vmethod_12(Class432 ow) { Interface29 objectWriter = ow.ObjectWriter; objectWriter.imethod_14(this.proxyGraphics_0 != null); if (this.proxyGraphics_0 == null) { return; } PagedMemoryStream from = new PagedMemoryStream(4096L, 4096); this.proxyGraphics_0.Write((Stream)from, ow.Model); if (ow.Version < DxfVersion.Dxf24) { objectWriter.imethod_19((int)from.Length); } else { objectWriter.imethod_34(from.Length); } from.Position = 0L; Class724.smethod_2(from, objectWriter); }
internal override void Write(DxfWriter w) { base.Write(w); if (this.method_24(true, w.Version)) { this.method_20(w); } else { if (w.Version < DxfVersion.Dxf14) { w.method_234("AcDbZombieEntity"); } else { w.method_234(this.AcClass); } w.Write(90, (object)(this.dxfClass_0 == null ? 498 : (int)this.dxfClass_0.ItemClassId)); w.Write(91, (object)(this.dxfClass_0 == null ? 568 : (int)this.dxfClass_0.ClassNumber)); if (w.Version > DxfVersion.Dxf14) { w.Write(95, (object)(int)(this.dwgVersion_0 | (DwgVersion)((int)this.short_1 << 16))); w.method_221(70, this.bool_2); } if (this.proxyGraphics_0 != null) { PagedMemoryStream pagedMemoryStream = new PagedMemoryStream(4096L, 4096); this.proxyGraphics_0.Write((Stream)pagedMemoryStream, w.Model); pagedMemoryStream.Position = 0L; this.method_22(w, 92, 160, pagedMemoryStream.Length); w.method_145(310, (Stream)pagedMemoryStream, (int)pagedMemoryStream.Length); } else { this.method_22(w, 92, 160, 8L); DxfWriter dxfWriter = w; byte[] numArray1 = new byte[8]; numArray1[0] = (byte)8; byte[] numArray2 = numArray1; dxfWriter.Write(310, (object)numArray2); } if (this.bool_2) { this.method_20(w); } else { PagedMemoryStream stream0 = this.stream_0 as PagedMemoryStream; PagedMemoryStream binData; if (stream0 == null) { binData = new PagedMemoryStream((long)(int)this.stream_0.Length); this.stream_0.Position = 0L; binData.Write(this.stream_0, (int)this.stream_0.Length); } else { binData = stream0.Clone(); } long binDataSizeInBits = this.long_0; if (w.Version >= DxfVersion.Dxf21) { if (this.uint_0 > 0U) { this.method_22(w, 96, 162, (long)this.uint_0); this.stream_1.Position = 0L; w.method_145(311, this.stream_1, (int)(this.uint_0 + 7U >> 3)); } } else if (this.dwgVersion_0 > DwgVersion.Dwg1018) { binDataSizeInBits = this.method_21(w, binData, binDataSizeInBits); } this.method_22(w, 93, 161, binDataSizeInBits); binData.Position = 0L; w.method_145(310, (Stream)binData, (int)(binDataSizeInBits + 7L >> 3)); if (this.list_0.Count <= 0) { return; } foreach (DxfTypedObjectReference typedObjectReference in this.list_0) { int code; switch (typedObjectReference.ReferenceType) { case ReferenceType.SoftPointerReference: code = 330; break; case ReferenceType.HardPointerReference: code = 340; break; case ReferenceType.SoftOwnershipReference: code = 350; break; case ReferenceType.HardOwnershipReference: code = 360; break; default: throw new Exception("Unexpected reference type " + (object)typedObjectReference.ReferenceType + "."); } w.method_218(code, (DxfHandledObject)typedObjectReference.ObjectReference.Value); } w.Write(94, (object)0); } } }
private bool method_17( DxfReader r, Class285 objectBuilder, ref long graphicsDataSizeInBytes, ref PagedMemoryStream graphicsData, ref Stream currentStream) { switch (r.CurrentGroup.Code) { case 1: string cPlusPlusClassName = (string)r.CurrentGroup.Value; this.dxfClass_0 = r.Model.Classes.GetClassWithCPlusPlusName(cPlusPlusClassName); break; case 70: this.bool_2 = (short)r.CurrentGroup.Value != (short)0; break; case 90: int num1 = (int)r.CurrentGroup.Value; break; case 91: int num2 = (int)r.CurrentGroup.Value; this.dxfClass_0 = r.Model.Classes.GetClassWithClassNumber((short)num2); break; case 92: graphicsDataSizeInBytes = (long)(int)r.CurrentGroup.Value; if (graphicsData == null) { graphicsData = new PagedMemoryStream((long)(int)graphicsDataSizeInBytes, System.Math.Min((int)graphicsDataSizeInBytes, 65536)); } else { graphicsData.SetLength(graphicsDataSizeInBytes); } currentStream = (Stream)graphicsData; break; case 93: this.long_0 = (long)(int)r.CurrentGroup.Value; if (this.long_0 != 0L) { int val1 = (int)this.long_0 + 7 >> 3; if (this.stream_0 == null) { this.stream_0 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536)); } else { this.stream_0.SetLength((long)val1); } } currentStream = this.stream_0; break; case 94: int num3 = (int)r.CurrentGroup.Value; break; case 95: int num4 = (int)r.CurrentGroup.Value; this.dwgVersion_0 = (DwgVersion)(num4 & (int)ushort.MaxValue); this.short_1 = (short)(num4 >> 16); break; case 96: this.uint_0 = (uint)(int)r.CurrentGroup.Value; if (this.uint_0 != 0U) { int val1 = (int)(this.uint_0 + 7U >> 3); if (this.stream_1 == null) { this.stream_1 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536)); } else { this.stream_1.SetLength((long)val1); } } currentStream = this.stream_1; break; case 160: graphicsDataSizeInBytes = (long)r.CurrentGroup.Value; if (graphicsData == null) { graphicsData = new PagedMemoryStream((long)(int)graphicsDataSizeInBytes, System.Math.Min((int)graphicsDataSizeInBytes, 65536)); } else { graphicsData.SetLength(graphicsDataSizeInBytes); } currentStream = (Stream)graphicsData; break; case 161: this.long_0 = (long)r.CurrentGroup.Value; if (this.long_0 != 0L) { int val1 = (int)this.long_0 + 7 >> 3; if (this.stream_0 == null) { this.stream_0 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536)); } else { this.stream_0.SetLength((long)val1); } } currentStream = this.stream_0; break; case 162: this.uint_0 = (uint)(long)r.CurrentGroup.Value; if (this.uint_0 != 0U) { int val1 = (int)this.uint_0 + 7 >> 3; if (this.stream_1 == null) { this.stream_1 = (Stream) new PagedMemoryStream((long)val1, System.Math.Min(val1, 65536)); } else { this.stream_1.SetLength((long)val1); } } currentStream = this.stream_1; break; case 310: if (currentStream == null) { throw new Exception("No stream size specified."); } byte[] buffer1 = (byte[])r.CurrentGroup.Value; currentStream.Write(buffer1, 0, buffer1.Length); break; case 311: if (currentStream == null) { throw new Exception("No stream size specified."); } if (currentStream != this.stream_1) { throw new Exception("Wrong stream"); } byte[] buffer2 = (byte[])r.CurrentGroup.Value; currentStream.Write(buffer2, 0, buffer2.Length); break; case 330: this.method_19(r, (Class259)objectBuilder, ReferenceType.SoftPointerReference); break; case 340: this.method_19(r, (Class259)objectBuilder, ReferenceType.HardPointerReference); break; case 350: this.method_19(r, (Class259)objectBuilder, ReferenceType.SoftOwnershipReference); break; case 360: this.method_19(r, (Class259)objectBuilder, ReferenceType.HardOwnershipReference); break; default: return(this.method_9(r, objectBuilder)); } r.method_85(); return(true); }
public uint imethod_21(PagedMemoryStream targetStream) { return(this.interface30_0.imethod_21(targetStream)); }
public void imethod_20(int length, PagedMemoryStream targetStream) { this.interface30_0.imethod_20(length, targetStream); }
public static PagedMemoryStream smethod_0(PagedMemoryStream source) { return(new PagedMemoryStream(source)); }
private void method_14(Interface29 w, Stream stream, long dataSizeInBits) { int length1 = (int)(dataSizeInBits >> 3); int num1 = (int)dataSizeInBits & 7; PagedMemoryStream pagedMemoryStream = stream as PagedMemoryStream; if (pagedMemoryStream != null) { int val2 = length1; foreach (byte[] page in pagedMemoryStream.Pages) { int length2 = System.Math.Min(page.Length, val2); if (length2 > 0) { w.imethod_13(page, 0, length2); } val2 -= length2; if (val2 <= 0) { break; } } } else { MemoryStream memoryStream = stream as MemoryStream; if (memoryStream != null) { w.imethod_13(memoryStream.GetBuffer(), 0, length1); } else { byte[] numArray = new byte[1024]; int num2 = length1 / 1024; for (int index = 0; index < num2; ++index) { stream.Read(numArray, 0, 1024); w.imethod_13(numArray, 0, 1024); } int num3 = length1 % 1024; if (num3 > 0) { stream.Read(numArray, 0, num3); w.imethod_13(numArray, 0, num3); } } } if (num1 == 0) { return; } stream.Position = (long)length1; int num4 = stream.ReadByte(); for (; num1 > 0; --num1) { w.imethod_14((num4 & 128) != 0); num4 <<= 1; } stream.Position = 0L; }
protected override bool vmethod_0(DxfReader r) { bool flag; if (!(flag = base.vmethod_0(r))) { flag = true; switch (this.DataType) { case Enum26.const_0: case Enum26.const_1: case Enum26.const_2: case Enum26.const_3: case Enum26.const_4: case Enum26.const_5: case Enum26.const_6: case Enum26.const_7: case Enum26.const_8: case Enum26.const_10: case Enum26.const_11: this.Data = new Struct18(r.CurrentGroup.Code, r.CurrentGroup.Value); r.method_85(); break; case Enum26.const_9: if (r.CurrentGroup.Code == 161) { this.Data = new Struct18(r.CurrentGroup.Code, r.CurrentGroup.Value); } else { this.Data = new Struct18(r.CurrentGroup.Code, (object)DxfHandledObject.Parse(r.CurrentGroup.ValueString)); } r.method_85(); break; case Enum26.const_12: break; case Enum26.const_14: int num = (int)r.CurrentGroup.Value; r.method_85(); PagedMemoryStream pagedMemoryStream = (PagedMemoryStream)null; while (r.CurrentGroup.Code == 310) { if (pagedMemoryStream == null) { pagedMemoryStream = new PagedMemoryStream((long)num); this.Data = new Struct18(r.CurrentGroup.Code, (object)pagedMemoryStream); } byte[] buffer = (byte[])r.CurrentGroup.Value; pagedMemoryStream.Write(buffer, 0, buffer.Length); r.method_85(); } if (pagedMemoryStream != null) { pagedMemoryStream.Position = 0L; break; } break; default: flag = false; break; } } return(flag); }