public static IRobustHash Hash(IRobustlyHashable hashable) { IRobustHash robustHash = new StrongHash(); hashable.AccumulateRobustHash(robustHash); return(robustHash); }
public override string ToString() { StrongHash strongHash = new StrongHash(); strongHash.ms.Write(this.ms.GetBuffer(), 0, (int)this.ms.Length); strongHash.DoHash(); return(StrongHash.ByteArrayToHex(strongHash.hashValue)); }
public override bool Equals(object obj) { if (obj is StrongHash) { StrongHash strongHash = (StrongHash)obj; this.DoHash(); strongHash.DoHash(); return(this.ArraysEqual(strongHash)); } return(false); }
private bool ArraysEqual(StrongHash rh2) { bool result = true; if (this.hashValue.Length != rh2.hashValue.Length) { result = false; } else { for (int i = 0; i < this.hashValue.Length; i++) { if (this.hashValue[i] != rh2.hashValue[i]) { result = false; break; } } } return(result); }
public static IRobustHash Hash(IRobustlyHashable hashable) { IRobustHash robustHash = new StrongHash(); hashable.AccumulateRobustHash(robustHash); return robustHash; }
private bool ArraysEqual(StrongHash rh2) { bool result = true; if (this.hashValue.Length != rh2.hashValue.Length) { result = false; } else { for (int i = 0; i < this.hashValue.Length; i++) { if (this.hashValue[i] != rh2.hashValue[i]) { result = false; break; } } } return result; }
public override string ToString() { StrongHash strongHash = new StrongHash(); strongHash.ms.Write(this.ms.GetBuffer(), 0, (int)this.ms.Length); strongHash.DoHash(); return StrongHash.ByteArrayToHex(strongHash.hashValue); }
public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 4); MapRectangleParameter parameter = (MapRectangleParameter)paramList[0]; SizeParameter parameter2 = (SizeParameter)paramList[1]; Present present = paramList[2]; Present present2 = paramList[3]; double num = Math.Min(parameter.value.LonExtent, parameter.value.LatExtent); int num2 = Math.Max(parameter2.value.Width, parameter2.value.Height); if ((num > 1.0) && (num2 <= 0x400)) { IFuture future = this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, new MapRectangleParameter(this.unitRectangle), TermName.OutputSize, new SizeParameter(this.memoizedSize), TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })); StrongHash hash = new StrongHash(); future.AccumulateRobustHash(hash); D.Sayf(0, "Future {0} hashes to {1}", new object[] { RobustHashTools.DebugString(future), hash.ToString() }); Present present3 = future.Realize("sourceImageDownsampler-memo"); if (present3 is ImageRef) { try { ImageRef ref2 = (ImageRef)present3; GDIBigLockedImage image = new GDIBigLockedImage(parameter2.value, "sourceImageDownsampler-downsample"); lock (ref2.image) { lock (image) { Graphics graphics = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics(); MapRectangle region = parameter.value.Intersect(this.unitRectangle); if (!region.IsEmpty()) { RectangleF srcRect = this.SelectSubRectangle(this.unitRectangle, region, this.memoizedSize); RectangleF destRect = this.SelectSubRectangle(parameter.value, region, parameter2.value); Image image2 = ref2.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(); graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel); } graphics.Dispose(); return new ImageRef(new ImageRefCounted(image)); } } } catch (ArgumentException) { return new PresentFailureCode("Image processing overflow"); } catch (OverflowException) { return new PresentFailureCode("Image processing overflow"); } catch (Exception exception) { return new PresentFailureCode(exception); } finally { present3.Dispose(); } } return present3; } return this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, parameter, TermName.OutputSize, parameter2, TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })).Realize("sourceImageDownsampler-passthru"); }
public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 4); MapRectangleParameter parameter = (MapRectangleParameter)paramList[0]; SizeParameter parameter2 = (SizeParameter)paramList[1]; Present present = paramList[2]; Present present2 = paramList[3]; double num = Math.Min(parameter.value.LonExtent, parameter.value.LatExtent); int num2 = Math.Max(parameter2.value.Width, parameter2.value.Height); if ((num > 1.0) && (num2 <= 0x400)) { IFuture future = this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, new MapRectangleParameter(this.unitRectangle), TermName.OutputSize, new SizeParameter(this.memoizedSize), TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })); StrongHash hash = new StrongHash(); future.AccumulateRobustHash(hash); D.Sayf(0, "Future {0} hashes to {1}", new object[] { RobustHashTools.DebugString(future), hash.ToString() }); Present present3 = future.Realize("sourceImageDownsampler-memo"); if (present3 is ImageRef) { try { ImageRef ref2 = (ImageRef)present3; GDIBigLockedImage image = new GDIBigLockedImage(parameter2.value, "sourceImageDownsampler-downsample"); lock (ref2.image) { lock (image) { Graphics graphics = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheGraphics(); MapRectangle region = parameter.value.Intersect(this.unitRectangle); if (!region.IsEmpty()) { RectangleF srcRect = this.SelectSubRectangle(this.unitRectangle, region, this.memoizedSize); RectangleF destRect = this.SelectSubRectangle(parameter.value, region, parameter2.value); Image image2 = ref2.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage(); graphics.InterpolationMode = InterpolationMode.HighQualityBilinear; graphics.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel); } graphics.Dispose(); return(new ImageRef(new ImageRefCounted(image))); } } } catch (ArgumentException) { return(new PresentFailureCode("Image processing overflow")); } catch (OverflowException) { return(new PresentFailureCode("Image processing overflow")); } catch (Exception exception) { return(new PresentFailureCode(exception)); } finally { present3.Dispose(); } } return(present3); } return(this.prototype.Curry(new ParamDict(new object[] { TermName.ImageBounds, parameter, TermName.OutputSize, parameter2, TermName.UseDocumentTransparency, present, TermName.ExactColors, present2 })).Realize("sourceImageDownsampler-passthru")); }