We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issue to generate BMP files


I am working in a project to transform stream (jpg,gif,bmp,png) to tiff image, but I have found an issue with the BMP file type, the JPG and GIF file types are working as expected. The source code I am using is the folllowing:

LogMessage("DEBUG: ", “STEP1: Start the imaging trans.”);

System.IO.MemoryStream tmpMemStream = null;
tmpMemStream = new System.IO.MemoryStream(this.FileBytes.Length);
tmpMemStream.Write(this.FileBytes, 0, this.FileBytes.Length);
LogMessage("DEBUG: ", “STEP2: Stream assigned”);

string filetype = Aspose.Imaging.Image.GetFileFormat(tmpMemStream).ToString();

LogMessage("DEBUG: ", "FILETYPE: " + filetype);

Aspose.Imaging.Image imgInput = Aspose.Imaging.Image.Load(tmpMemStream);
LogMessage("DEBUG: ", “STEP3: stream loaded to aspose imaging.”);
MemoryStream outputStream = new MemoryStream();
imgInput.Save(outputStream, new Aspose.Imaging.SaveOptions.TiffSaveOptions());
LogMessage("DEBUG: ", “STEP4: stream transformed.”);
byte[] ConvertedBytes = null;
ConvertedBytes = outputStream.ToArray();

The log file report this:
[2012-01-03 11:56:19.1911] -1 4 DEBUG:Going to ImageAttachment.cs file. .bmp
[2012-01-03 11:56:21.9568] -1 4 DEBUG: STEP1: Start the imaging trans.
[2012-01-03 11:56:21.9568] -1 4 DEBUG: STEP2: Stream assigned
[2012-01-03 11:56:22.0193] -1 4 DEBUG: FILETYPE: Bmp
[2012-01-03 11:56:22.0349] -1 4 Error with convert to tiff:Object reference not set to an instance of an object.
[2012-01-03 11:56:22.0349] -1 4 Error with load for convert:Error with load for convert:Object reference not set to an instance of an object.

I really appreciate if you can take a look on this.

Thank you,

Danilo Ac

This message was posted using Page2Forum from Saving Image files - Aspose.Imaging for .NET

Hi Danilo,

Thank you for your inquiry.

I have verified your said issue with my below source code and I was able to convert the BMP format to Tiff by reading the image through MemoryStream. I have used the latest version of Aspose.Imaging for .NET v1.3.0 for my testing. Attached to my reply are the input and output files in an archive.


using (var inMemStream = new System.IO.MemoryStream())
using (var inStream = System.IO.File.OpenRead(“Header.bmp”))
inStream.Read(inMemStream.GetBuffer(), 0, (int)inStream.Length);
using (var imgInput = Aspose.Imaging.Image.Load(inMemStream))
using (var outputStream = new System.IO.MemoryStream())
imgInput.Save(outputStream, new Aspose.Imaging.SaveOptions.TiffSaveOptions());
outputStream.WriteTo(new System.IO.FileStream(“Bmp2Tiff.tiff”, System.IO.FileMode.Create));

In case you have further queries or comments, please feel free to write back.