I found it to be a very simple change to enhance the image class to have an AddImage overload that took a stream and a name instead of a filepath.
Essentially:
Code:
// Add a new Image constructor that takes a MemoryStream.
public Image(MemoryStream imageStream) : this()
{
ImageSteam = imageStream; // Added new property to hold the stream
FileName = String.Empty; // When no filename, we'll look for the stream.
}
// for convenience, added Image class property to indicate whether this image is file or stream
public bool StreamBased
{
get { return ImageStream != null; }
}
// Altered Image.GetFilePath to return string.empty if the image is StreamBased.
// ---------------------------------------------------------------------
///Another file I needed to make changes to was in the ImageRenderer class (ImageRenderer.cs)
1) internal override void Format(Area area, FormatInfo previousFormatInfo) needed to be altered slightly
only perform the "does a bit of searching to try to locate the image" behavior when we're a file based image
2) in the Render() method, we needed to add a conditional for when image is StreamBased.
if (image.StreamBased)
xImage = XImage.FromStream(image.ImageStream) <<-- XImage already knows how to load from stream so call it!
else
xImage = XImage.FromFile(formatInfo.ImagePath)
3) Exact same thing in the CalculateImageDimensions() method.
While a set of diffs would be the *best* way to convey this change info, this should get you on your way. It's really simple.
Cheers,
-Jeff