Answered by:
Lumia Imaging SDK System Argument Exception value does not fall within expected range

Question
-
I am trying to use the Lumia Imaging SDK 2.0 to set greyscale on an image. I have achieved this ok with the code below with images encodes as JPEG but if I load an image encoded as ARW (Sony RAW) the image displays ok but when I try to run the code for greyscale it crashes with the Argument Exception value does not fall within expected range. Whilst debugging I cannot see any difference with the writable bitmap.
Code to load the image which works ok for JPEG and ARW
if (sourceFile != null) { byte[] srcPixels; RandomAccessStreamReference streamRef = RandomAccessStreamReference.CreateFromFile(sourceFile); using (IRandomAccessStreamWithContentType filestream = await streamRef.OpenReadAsync()) { BitmapDecoder decoder = await BitmapDecoder.CreateAsync(filestream); BitmapFrame frame = await decoder.GetFrameAsync(0); PixelDataProvider pixelProvider = await frame.GetPixelDataAsync(); srcPixels = pixelProvider.DetachPixelData(); wid = (int)frame.PixelWidth; hgt = (int)frame.PixelHeight; writableBitmap = new WriteableBitmap(wid, hgt); Stream pixelStream = writableBitmap.PixelBuffer.AsStream(); pixelStream.Seek(0, SeekOrigin.Begin); pixelStream.Write(srcPixels, 0, (int)srcPixels.Length); source = new StorageFileImageSource(sourceFile); effect = new FilterEffect(source); writableBitmapRenderer = new WriteableBitmapRenderer(source); canvasMain.Width = wid; canvasMain.Height = hgt; filestream.Seek(0); target.Source = writableBitmap; } }
Code for the greyscale filter:
filterlist.Add(new Lumia.Imaging.Adjustments.GrayscaleFilter()); effect.Filters = filterlist; writableBitmapRenderer = new WriteableBitmapRenderer(effect, writableBitmap); await writableBitmapRenderer.RenderAsync(); isRendering = false; CanUndo = true; buttonUndo.IsEnabled = true; writableBitmap.Invalidate();
Mal
Tuesday, January 20, 2015 10:52 AM
Answers
-
Hi Mal,
The best practices page suggests using Bitmap over WriteableBitmap. Try this to see if the problem can be avoid. See more from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/best-practices.html. Also you can try to use sony raw image in the following code sample to see if the problem is still persisting. Get the sample from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/quick-start/qs-w81-wp81.html.
If not help, please post repro project with the sony raw image for test. Use your OneDrive and share a link here.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
Yes I have looked these thanks, however, I need to use a writable bitmap because I am doing other things with it such as drawing on it.
I have now sorted this in another way, basically loading the image from RAW and saving a temporary file as JPEG, I then use this to work on.
Thanks for your response though
Mal
- Marked as answer by MalBall Wednesday, January 21, 2015 8:57 AM
Wednesday, January 21, 2015 8:57 AM
All replies
-
Hi Mal,
The best practices page suggests using Bitmap over WriteableBitmap. Try this to see if the problem can be avoid. See more from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/best-practices.html. Also you can try to use sony raw image in the following code sample to see if the problem is still persisting. Get the sample from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/quick-start/qs-w81-wp81.html.
If not help, please post repro project with the sony raw image for test. Use your OneDrive and share a link here.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
Wednesday, January 21, 2015 2:06 AMModerator -
Hi Mal,
The best practices page suggests using Bitmap over WriteableBitmap. Try this to see if the problem can be avoid. See more from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/best-practices.html. Also you can try to use sony raw image in the following code sample to see if the problem is still persisting. Get the sample from http://developer.nokia.com/resources/library/Lumia/nokia-imaging-sdk/quick-start/qs-w81-wp81.html.
If not help, please post repro project with the sony raw image for test. Use your OneDrive and share a link here.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
Yes I have looked these thanks, however, I need to use a writable bitmap because I am doing other things with it such as drawing on it.
I have now sorted this in another way, basically loading the image from RAW and saving a temporary file as JPEG, I then use this to work on.
Thanks for your response though
Mal
- Marked as answer by MalBall Wednesday, January 21, 2015 8:57 AM
Wednesday, January 21, 2015 8:57 AM -
Hi Mal,
The reason for the exception is that the ARW format is not supported by the Lumia Imaging SDK. If you enable native debugging for your application, you will get more informative error messages from the Imaging SDK. In this case, you should get the message "WinRT information: The image is corrupted or the wrong format."
Regards,
Jonas
Tuesday, February 17, 2015 10:31 AM -
Thanks, already marked this as answered.
I got round it by creating a temporary jpg image from the original ARW file to work on
Mal
Tuesday, February 17, 2015 10:33 AM