Images Fail To Upload with TestClient
Using TestClient and trying to upload an image with uploadimage results in a NullReferenceException error:
System.NullReferenceException: Object reference not set to an instance of an object.
at CoreJ2K.Util.ImageFactory.New(Int32 width, Int32 height, Byte[] bytes)
at CoreJ2K.Util.PortableImage.As[T]()
at OpenMetaverse.TestClient.UploadImageCommand.LoadImage(String fileName) in
C:\Users\danny\Desktop\libremetaverse\Programs\examples\TestClient\Commands\Inventory\UploadImageCommand.cs:line 109 SL Image Upload
Also, in the last part of ExportBitmap in ManagedImage.cs if you go the other way around and try to convert to a ManagedImage first and then use ExportBitmap, the following code in ManagedImage.cs also throws a NullReferenceException:
var img = SKImage.FromEncodedData(raw);
return SKBitmap.FromImage(img);
with img turning out to be null with SKImage.FromEncodedData not managing to convert the image? Either way it seems that there is no way to upload an image.
I'm including SkiaSharp native assets in TestClient on head. That should hopefully resolve your issue. What format is the image you are intending to upload?
As I understand it there are two formats that pertain to JPEG2000, one ending in JP2 which is a JPEG2000 Profile 1 and a J2C that is a JPEG2000 codestream. Neither seem to work. Including the SkiaSharp native assets might not be enough. There also seems to be another upstream issue where after the byte array is provided, the CreateInventoryItemFromAsset fails with No Error and InvalidAsset when looking at the OSD response. All parameters passed to CreateInventoryItemFromAsset seem correct though.
Interestingly, image downloads work without issue (!) which is frustrating because you'd think they'd just fail together if it were a library issue!
Well, if it's a library issue, I'll get it figured out anyways as CoreJ2K is also my library. SkiaSharp has some unfortunate limitations with file formats, but it seems to be the de facto cross-platform imaging library these days.
Thank you for your efforts: the OpenJPEG issue is a long-standing problem that nobody wanted to touch with a 10ft pole. I remember there were so many issues even within the JPEG2000 with either .jp2 or .j2k not being recognized. IIRC JP2 was JPEG2000 version 2 or something like that and J2K is JPEG2000 codestream and only one of those was a valid upload with OpenMetaverse but the other one was not. Such a nightmare and for such a small issue. It's not like JPEG2000 is not clearly defined.
Apparently KDU does not like CoreJ2K's encoding. Working on it...
Fixed in 2.1.3 069ceac85869feffd34b6d64847468a710186838