protected void RegisterDynamicImage(ref Stream dynamicImageStream, ref string streamName, string extension, string mimeType, PageContext pageContext, out System.Drawing.Rectangle offsets)
 {
     offsets = System.Drawing.Rectangle.Empty;
     if (dynamicImageStream != null && dynamicImageStream.Length != 0)
     {
         if (pageContext.ImageConsolidation != null)
         {
             ImageConsolidation imageConsolidation = pageContext.ImageConsolidation;
             offsets = imageConsolidation.AppendImage(dynamicImageStream);
             if (offsets != System.Drawing.Rectangle.Empty)
             {
                 dynamicImageStream = null;
                 streamName         = imageConsolidation.GetStreamName();
             }
         }
         else if (!pageContext.RegisteredStreamNames.Contains(streamName))
         {
             pageContext.RegisteredStreamNames.Add(streamName, null);
             Stream stream = pageContext.CreateAndRegisterStream(streamName, extension, null, mimeType, false, StreamOper.CreateAndRegister);
             if (stream != null)
             {
                 dynamicImageStream.Position = 0L;
                 int    num   = (int)dynamicImageStream.Length;
                 byte[] array = new byte[4096];
                 while (num > 0)
                 {
                     int num2 = dynamicImageStream.Read(array, 0, Math.Min(array.Length, num));
                     stream.Write(array, 0, num2);
                     num -= num2;
                 }
                 dynamicImageStream = null;
             }
         }
     }
 }