Android can not handle a image that converted via aspose.image library

Hi~ Aspose.

I'm using Aspose.Imaging for changing image format to png.
after changed format, mobile app will get the files over the web service.
then using android's native code (BmpFactory.decodeByteArray()) to show image, but it returns null (means decode fail).
even it shown correctly any other viewer (or browser).

I knows files are all right.
But other image files (output of Aspose.cell, slide, word, pdf.) are handled with same function as well. so very confused.

I think, this is a issue of Android.
or maybe it depends on png file format?

May I ask you, some idea about this?

I attache files (source, target[converted by aspose])
And source code likes below.
Thank you.

Source code
public Stream Convert(Stream source)
{
source.Position = 0;
var opt = GetOption();
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(source))
{
Stream stream = new MemoryStream();
image.Save(stream, opt);
return stream;
}
}

private Aspose.Imaging.ImageOptionsBase GetOption(double ratio = 100)
{
double rate = ratio; // some value
var de = new PngOptions();

return new PngOptions
{
ResolutionSettings = new ResolutionSetting(rate, rate),
ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha,
};
}

Hi Ethan,


Thank you for contacting Aspose support.

I am afraid, I haven’t encountered such issue before, nor I have an idea at the moment if the said issue is on the part of Aspose.Imaging APIs. However, we will try our best to investigate the matter thoroughly and log appropriate tickets for correction purposes, in case the issue is identified as a bug of Aspose.Imaging APIs. In order to investigate the matter, we will also require your cooperation.

First of all, I am not sure which version of Aspose.Imaging for .NET you are currently using to convert the image formats so I have used your source.jpg to generate 3 PNG files (as attached in an archive) while using the latest version of Aspose.Imaging for .NET 2.8.0. Could you please pass them through your system to see if you are able to see any difference?
I'm using Aspose.Imaging -v 2.8.0 on Windows 2008, Windows 8.1 (x64)
the files which you provide, also can not draw on android app.

and I tried convert image with various option as possible using below code.
test result is same - not working too.

but jpeg format files are working well... in android.
I prefer png more than jpeg. (lossless data compression)

any of changes or possibility that makes solve this, please let me know.
Thank you for your concern.

Source code
private IEnumerable GetPngOption()
{
double rate = 100; // some value

foreach (PngColorType color in Enum.GetValues(typeof(PngColorType)))
{
for (int i = 0; i <= 9; i++)
{
PngOptions opt = new PngOptions();
opt.ResolutionSettings = new ResolutionSetting(rate, rate);
opt.ColorType = color;
opt.CompressionLevel = i;

yield return opt;
};
}
}

Hi Ethan,


I am sorry to know that the latest version of Aspose.Imaging for .NET didn’t help in your scenario. Please allow me some time to perform more tests, and get back to you with updates in this regard. In the meanwhile, could you please confirm the Android version that present this issue so I could perform all test in an equivalent environment.
Hi Babar Raza

Test environment is like below.
OS: android 4.2.2 or later.
mobile device: Samsung galaxy note II, LG G3(cat 6) etc.

Thank you for your help.

Hi Ethan,


Thank you for providing the environment details. I will keep you posted with my investigation results.

Hi Ethan,


I have investigated your presented scenario with Android 5.0.1 API 21 (Nexus emulator), and I was unable to notice any issue with BitmapFactory.decodeByteArray or BitmapFactory.decodeFile methods while loading the images posted in this response. In order to simulate your scenario, I have copied the samples in sdcard and used a custom method to convert the file to byte array and then loaded the image data using the BitmapFactory.decodeByteArray to display it in ImageView. I have attached my Android Studio’s sample project here for your reference.

I have recently acquired Samsung Galaxy emulator so I will continue the investigation with this emulator as well as lower revisions of Android. In the meanwhile, could you try the same case with Android 5.0.1 and post your results?

Yes, I’ll do to various environment as possible, and will share the result.

thank you very much.

Test device: LG G3 cat.6

OS version: 5.0.1

Sample code works fine.

additional info.
I tried to show png image which created via Adobe photoshop, It works fine at same device of older android.

Hi Ethan,


Thank you for testing the presented scenario with latest revision of Android. As per our testing results, the issue isn’t reproducible with Android v 5.0.1 so we need to discuss the matter internally first if we could log an investigation in this regard for previous Android versions. We will shortly get back to you with updates in this regard.

Hi Ethan,


First of all, please accept our sincere apologies for a bit delayed response.

We have discussed the matter internally, and we have concluded that the presented problem is probably in the image decoder of previous Android revisions, that has already been fixed with the recent releases of Android (as per our testing). Moreover, it will not be feasible for us to launch an investigation to find out the problem cause with the previous releases of Android as it may involve debugging of third party (Android) libraries thus consuming a lot of time & resources. That being said, we may log an investigation to find out the differences in the binary code of Aspose.Cells/Words generated PNG files as compared to Aspose.Imaging’s, if this suffice your needs.

I think Android library has been fixed means, it has bugs in previous version.

I am trying change library in android app, to not use BmpFactory object.

Please do not worry about this for me.
thank you deeply.

Hi Ethan,


Thank you for the confirmation. Please feel free to get in touch if you need our further assistance with Aspose APIs.