Hello,I am trying to create a multi-page single TIFF from a powerpoint document.I use this function to get one bitmap from powerpoint slide (by using Aspose.Slides)var bitmap = slides[i].GetThumbnail(options);
but I want to use this bitmap for TiffImage and TiffFrame in Aspose.Imagingfirstly I take bitmap into a memorystream and then when i tried to call this functionImage.Load(ms); (by using Aspose.Imaging)
I got an exception{“Cannot open an image. The image file format may be not supported at the moment.”}" at Aspose.Imaging.Image.\u0002(StreamContainer \u0002, LoadOptions \u0003)\r\n at Aspose.Imaging.Image.Load(Stream stream)\r\n at Converter.Business.AsposeSdk.AsposeImageDoc.CreateThumbnailFromBitmaps(List`1 bitmaps)"{Aspose.Imaging.Image (Aspose.Imaging.StreamContainer, Aspose.Imaging.LoadOptions)}
But If i save my bitmap as a file like png and after I take it into my memorystream (reading from directly file) then Image.Load function worksI have similar error in Aspose.Words. When something is in memorystream, it throws out the same exception.Well my question is that how to use my bitmap (windows drawing) objects in Aspose.Imagingwithout saving?
using(System.IO.FileStream stream = new System.IO.FileStream(@"sample.bmp",System.IO.FileMode.Open))
{
//Create an instance of Image class and load an existing file through FileStream object by calling Load method
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(stream))
{
//do some image processing.
}
}
Thank you for your reply but i think there is a missunderstanding.
Hey, Okay I prepared a project, you can find it as an attachment. and here is the sample code also
var stream = new MemoryStream(File.ReadAllBytes(@“Test.pptx”));
Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation(stream);<span style="color:blue;">var</span> bitmap= presentation.Slides[0].GetThumbnail(<span style="color:blue;">new</span> <span style="color:#2b91af;">Size</span>(160, 160)); <span style="color:blue;">var</span> tmpStream = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>(); bitmap.Save(tmpStream,<span style="color:#2b91af;">ImageFormat</span>.Tiff); <span style="color:green;">//doesnt mather png or tiff or.. in anycase exception is throw</span> <span style="color:green;">//when i save bitmap in a file and after, read from the file it works. but from the stream, not working</span> <span style="color:blue;">try</span> { Aspose.Imaging.<span style="color:#2b91af;">Image</span> image = Aspose.Imaging.<span style="color:#2b91af;">Image</span>.Load(tmpStream); } <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex) { <span style="color:#2b91af;">MessageBox</span>.Show(ex.Message + <span style="color:#2b91af;">Environment</span>.NewLine + ex.InnerException); }</pre></pre></div><div><br></div><div><b><br></b></div><div><b><br></b></div><div><b><br></b></div><div><b>My expectation is that the code must work. I DO NOT WANT TO SAVE "bitmap object" in a physical file, i want to use it as a stream object. (NOT FROM THE FILE)</b></div><div><br></div><div><br></div><div><br></div>
Hello,
var stream = new MemoryStream(File.ReadAllBytes(@“Test.pptx”));
Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation(stream);<span style="color: blue;">var</span> bitmap= presentation.Slides[0].GetThumbnail(<span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Size</span>(160, 160)); <span style="color: blue;">var</span> tmpStream = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">MemoryStream</span>(); bitmap.Save(tmpStream,<span style="color: rgb(43, 145, 175);">ImageFormat</span>.Tiff); <span style="color: green;">//doesnt mather png or tiff or.. in anycase exception is throw</span> <span style="color: green;">//when i save bitmap in a file and after, read from the file it works. but from the stream, not working</span>
tmpStream.Seek(0, SeekOrigin.Begin);try
{
Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(tmpStream);} <span style="color: blue;">catch</span> (<span style="color: rgb(43, 145, 175);">Exception</span> ex) { <span style="color: rgb(43, 145, 175);">MessageBox</span>.Show(ex.Message + <span style="color: rgb(43, 145, 175);">Environment</span>.NewLine + ex.InnerException); }</pre></div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);"><br></div></div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);">it will work. I dont know why it occurs an exception, even it is needed to seek index 0, you could do that in the load function, couldnt you?</div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);"><br></div><div style="color: rgb(51, 51, 51); font-family: Arial, Helvetica; font-size: 13px; background-color: rgb(255, 255, 255);">When I always want to use a stream like that I have to call always this Seek method and when i sometimes forget, i have to find out the problem. (I am writing a complete wrapper for aspose modules in order to create thumbnails)</div>
The issues you have found earlier (filed as ) have been fixed in this Aspose.Words for JasperReports 18.3 update.