Esempio n. 1
0
 private Image LoadImage(string imageExpression)
 {
     try
     {
         using (IDataValue imageData = FrontendSession.Pipe.RequestDocument(imageExpression))
         {
             var    streamCopy = new MemoryStream();
             Stream stream     = imageData.OpenStream();
             try
             {
                 StreamUtility.CopyStream(stream, streamCopy);
             }
             finally
             {
                 stream.Close();
             }
             return(Image.FromStream(streamCopy));
         }
     }
     catch (Exception exception)
     {
         Dataphoria.Warnings.AppendError(this, exception, true);
         // Don't rethrow
     }
     return(null);
 }
Esempio n. 2
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            IDataValue tempValue = arguments[0] as IDataValue;

            if (tempValue == null)
            {
                tempValue = DataValue.FromNative(program.ValueManager, arguments[0]);
            }

            if (tempValue.IsPhysicalStreaming)
            {
                using (Stream stream = tempValue.OpenStream())
                {
                    return((int)CRC32Utility.GetCRC32(stream));
                }
            }
            else
            {
                byte[] physical = new byte[tempValue.GetPhysicalSize(true)];
                tempValue.WriteToPhysical(physical, 0, true);
                return((int)CRC32Utility.GetCRC32(physical));
            }
        }